From 81db15a2ef6235d3154b112698d2504ba8db0cfc Mon Sep 17 00:00:00 2001 From: Scott D Phillips Date: Tue, 17 May 2016 15:29:07 -0700 Subject: trace: Add `va_TracePrint`, `va_TraceVPrint` static functions These functions are similar to va_TraceMsg() but without emitting a timestamp. Signed-off-by: Scott D Phillips Reviewed-by: Sean V Kelley --- va/va_trace.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/va/va_trace.c b/va/va_trace.c index f632176..5c345f2 100644 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -877,10 +877,9 @@ void va_TraceEnd(VADisplay dpy) ((VADisplayContextP)dpy)->vatrace = NULL; } -static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...) +static void va_TraceVPrint(struct trace_context *trace_ctx, const char *msg, va_list args) { FILE *fp = NULL; - va_list args; if (!(trace_flag & VA_TRACE_FLAG_LOG) || !trace_ctx->plog_file) @@ -888,25 +887,44 @@ static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...) fp = trace_ctx->plog_file->fp_log; if (msg) { - struct timeval tv; - - if (gettimeofday(&tv, NULL) == 0) - fprintf(fp, "[%04d.%06d]", - (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec); - - if(trace_ctx->trace_context != VA_INVALID_ID) - fprintf(fp, - "[ctx 0x%08x]", trace_ctx->trace_context); - else - fprintf(fp, "[ctx none]"); - - va_start(args, msg); vfprintf(fp, msg, args); - va_end(args); } else fflush(fp); } +static void va_TracePrint(struct trace_context *trace_ctx, const char *msg, ...) +{ + va_list args; + va_start(args, msg); + va_TraceVPrint(trace_ctx, msg, args); + va_end(args); +} + +static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...) +{ + va_list args; + struct timeval tv; + + if (!msg) { + va_TracePrint(trace_ctx, msg); + return; + } + + if (gettimeofday(&tv, NULL) == 0) + va_TracePrint(trace_ctx, "[%04d.%06d]", + (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec); + + if(trace_ctx->trace_context != VA_INVALID_ID) + va_TracePrint(trace_ctx, + "[ctx 0x%08x]", trace_ctx->trace_context); + else + va_TracePrint(trace_ctx, "[ctx none]"); + + va_start(args, msg); + va_TraceVPrint(trace_ctx, msg, args); + va_end(args); +} + static void va_TraceSurface(VADisplay dpy, VAContextID context) { unsigned int i, j; -- cgit v1.2.1