remove TRACE_SCOPE_FMT to simplify tracing API

As we transition to perfetto, there are more efficient ways
of adding metadata to traces that we can use when it is
needed.

Signed-off-by: John Bates <jbates@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
macos/master
John Bates 4 years ago
parent fab5e73314
commit 0621329415
  1. 41
      src/virgl_util.c
  2. 19
      src/virgl_util.h
  3. 2
      src/vrend_decode.c

@ -126,24 +126,13 @@ void trace_init(void)
vperfetto_min_startTracing(&config); vperfetto_min_startTracing(&config);
} }
char *trace_begin(const char* scope) const char *trace_begin(const char *scope)
{ {
vperfetto_min_beginTrackEvent_VMM(scope); vperfetto_min_beginTrackEvent_VMM(scope);
return (void *)1; return scope;
} }
char *trace_begin_fmt(const char* format, ...) void trace_end(const char **dummy)
{
char buffer[1024];
va_list args;
va_start (args, format);
vsnprintf (buffer, sizeof(buffer), format, args);
va_end (args);
vperfetto_min_beginTrackEvent_VMM(buffer);
return (void *)1;
}
void trace_end(char **dummy)
{ {
(void)dummy; (void)dummy;
vperfetto_min_endTrackEvent_VMM(); vperfetto_min_endTrackEvent_VMM();
@ -156,38 +145,22 @@ void trace_init(void)
{ {
} }
char *trace_begin_fmt(const char* format, ...) const char *trace_begin(const char *scope)
{ {
for (int i = 0; i < nesting_depth; ++i) for (int i = 0; i < nesting_depth; ++i)
fprintf(stderr, " "); fprintf(stderr, " ");
fprintf(stderr, "ENTER:"); fprintf(stderr, "ENTER:%s\n", scope);
char *buffer;
va_list args;
va_start (args, format);
int size = vasprintf(&buffer, format, args);
if (size < 0)
buffer=strdup("error");
va_end (args);
fprintf(stderr, "%s\n", buffer);
nesting_depth++; nesting_depth++;
return buffer; return scope;
}
char *trace_begin(const char* scope)
{
return trace_begin_fmt("%s", scope);
} }
void trace_end(char **func_name) void trace_end(const char **func_name)
{ {
--nesting_depth; --nesting_depth;
for (int i = 0; i < nesting_depth; ++i) for (int i = 0; i < nesting_depth; ++i)
fprintf(stderr, " "); fprintf(stderr, " ");
fprintf(stderr, "LEAVE %s\n", *func_name); fprintf(stderr, "LEAVE %s\n", *func_name);
free(*func_name);
} }
#endif #endif

@ -63,29 +63,20 @@ void flush_eventfd(int fd);
#ifdef ENABLE_TRACING #ifdef ENABLE_TRACING
void trace_init(void); void trace_init(void);
char *trace_begin(const char* scope); const char *trace_begin(const char *scope);
char *trace_begin_fmt(const char* format, ...); void trace_end(const char **dummy);
void trace_end(char **dummy);
#define TRACE_INIT() trace_init() #define TRACE_INIT() trace_init()
#define TRACE_FUNC() \ #define TRACE_FUNC() TRACE_SCOPE(__func__)
char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \
trace_begin(__func__)
#define TRACE_SCOPE(SCOPE) \ #define TRACE_SCOPE(SCOPE) \
char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \ const char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \
trace_begin(SCOPE) trace_begin(SCOPE)
#define TRACE_SCOPE_FMT(FORMAT, ...) \
char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \
trace_begin_fmt(FORMAT, __VA_ARGS__)
#else #else
#define TRACE_INIT() #define TRACE_INIT()
#define TRACE_FUNC() #define TRACE_FUNC()
#define TRACE_SCOPE(FORMAT, ...) #define TRACE_SCOPE(SCOPE)
#define TRACE_SCOPE_FMT(FORMAT, ...)
#endif #endif
#endif /* VIRGL_UTIL_H */ #endif /* VIRGL_UTIL_H */

@ -756,7 +756,7 @@ static int vrend_decode_create_object(struct vrend_context *ctx, const uint32_t
VREND_DEBUG(dbg_object, ctx," CREATE %-18s handle:0x%x len:%d\n", VREND_DEBUG(dbg_object, ctx," CREATE %-18s handle:0x%x len:%d\n",
vrend_get_object_type_name(obj_type), handle, length); vrend_get_object_type_name(obj_type), handle, length);
TRACE_SCOPE_FMT("CREATE %-18s", vrend_get_object_type_name(obj_type)); TRACE_SCOPE(vrend_get_object_type_name(obj_type));
switch (obj_type){ switch (obj_type){
case VIRGL_OBJECT_BLEND: case VIRGL_OBJECT_BLEND:

Loading…
Cancel
Save