diff options
author | Jakob Bornecrantz <[email protected]> | 2009-04-19 16:09:10 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2009-04-19 16:24:41 +0100 |
commit | f2d2b3d8e2d9059c162ae7215344b9171f68632b (patch) | |
tree | be2ff9fac5f57d5299e1021bdc2e5ddaad546b68 /src/gallium/drivers/trace | |
parent | 439c42ae8b652f4fce59e5157c7e598280959684 (diff) |
trace: Enable dumping to be turned on and off
Diffstat (limited to 'src/gallium/drivers/trace')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump.c | 159 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump.h | 33 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_screen.c | 2 |
4 files changed, 191 insertions, 5 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 38646f8aad3..47280459a75 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1089,7 +1089,7 @@ trace_context_create(struct pipe_screen *_screen, if(!pipe) goto error1; - if(!trace_dump_enabled()) + if(!trace_dump_trace_enabled()) goto error1; tr_scr = trace_screen(_screen); diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index d2a7664ed9b..63811b7c81e 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -61,6 +61,7 @@ static struct util_stream *stream = NULL; static unsigned refcount = 0; static pipe_mutex call_mutex; static long unsigned call_no = 0; +static boolean dumping = FALSE; static INLINE void @@ -258,7 +259,7 @@ boolean trace_dump_trace_begin() return TRUE; } -boolean trace_dump_enabled(void) +boolean trace_dump_trace_enabled(void) { return stream ? TRUE : FALSE; } @@ -270,9 +271,71 @@ void trace_dump_trace_end(void) trace_dump_trace_close(); } -void trace_dump_call_begin(const char *klass, const char *method) +/* + * Call lock + */ + +void trace_dump_call_lock(void) +{ + pipe_mutex_lock(call_mutex); +} + +void trace_dump_call_unlock(void) +{ + pipe_mutex_unlock(call_mutex); +} + +/* + * Dumping control + */ + +void trace_dumping_start_locked(void) +{ + dumping = TRUE; +} + +void trace_dumping_stop_locked(void) +{ + dumping = FALSE; +} + +boolean trace_dumping_enabled_locked(void) +{ + return dumping; +} + +void trace_dumping_start(void) +{ + pipe_mutex_lock(call_mutex); + trace_dumping_start_locked(); + pipe_mutex_unlock(call_mutex); +} + +void trace_dumping_stop(void) { pipe_mutex_lock(call_mutex); + trace_dumping_stop_locked(); + pipe_mutex_unlock(call_mutex); +} + +boolean trace_dumping_enabled(void) +{ + boolean ret; + pipe_mutex_lock(call_mutex); + ret = trace_dumping_enabled_locked(); + pipe_mutex_unlock(call_mutex); + return ret; +} + +/* + * Dump functions + */ + +void trace_dump_call_begin_locked(const char *klass, const char *method) +{ + if (!dumping) + return; + ++call_no; trace_dump_indent(1); trace_dump_writes("<call no=\'"); @@ -285,56 +348,94 @@ void trace_dump_call_begin(const char *klass, const char *method) trace_dump_newline(); } -void trace_dump_call_end(void) +void trace_dump_call_end_locked(void) { + if (!dumping) + return; + trace_dump_indent(1); trace_dump_tag_end("call"); trace_dump_newline(); util_stream_flush(stream); +} + +void trace_dump_call_begin(const char *klass, const char *method) +{ + pipe_mutex_lock(call_mutex); + trace_dump_call_begin_locked(klass, method); +} + +void trace_dump_call_end(void) +{ + trace_dump_call_end_locked(); pipe_mutex_unlock(call_mutex); } void trace_dump_arg_begin(const char *name) { + if (!dumping) + return; + trace_dump_indent(2); trace_dump_tag_begin1("arg", "name", name); } void trace_dump_arg_end(void) { + if (!dumping) + return; + trace_dump_tag_end("arg"); trace_dump_newline(); } void trace_dump_ret_begin(void) { + if (!dumping) + return; + trace_dump_indent(2); trace_dump_tag_begin("ret"); } void trace_dump_ret_end(void) { + if (!dumping) + return; + trace_dump_tag_end("ret"); trace_dump_newline(); } void trace_dump_bool(int value) { + if (!dumping) + return; + trace_dump_writef("<bool>%c</bool>", value ? '1' : '0'); } void trace_dump_int(long long int value) { + if (!dumping) + return; + trace_dump_writef("<int>%lli</int>", value); } void trace_dump_uint(long long unsigned value) { + if (!dumping) + return; + trace_dump_writef("<uint>%llu</uint>", value); } void trace_dump_float(double value) { + if (!dumping) + return; + trace_dump_writef("<float>%g</float>", value); } @@ -344,6 +445,10 @@ void trace_dump_bytes(const void *data, static const char hex_table[16] = "0123456789ABCDEF"; const uint8_t *p = data; long unsigned i; + + if (!dumping) + return; + trace_dump_writes("<bytes>"); for(i = 0; i < size; ++i) { uint8_t byte = *p++; @@ -357,6 +462,9 @@ void trace_dump_bytes(const void *data, void trace_dump_string(const char *str) { + if (!dumping) + return; + trace_dump_writes("<string>"); trace_dump_escape(str); trace_dump_writes("</string>"); @@ -364,6 +472,9 @@ void trace_dump_string(const char *str) void trace_dump_enum(const char *value) { + if (!dumping) + return; + trace_dump_writes("<enum>"); trace_dump_escape(value); trace_dump_writes("</enum>"); @@ -371,51 +482,81 @@ void trace_dump_enum(const char *value) void trace_dump_array_begin(void) { + if (!dumping) + return; + trace_dump_writes("<array>"); } void trace_dump_array_end(void) { + if (!dumping) + return; + trace_dump_writes("</array>"); } void trace_dump_elem_begin(void) { + if (!dumping) + return; + trace_dump_writes("<elem>"); } void trace_dump_elem_end(void) { + if (!dumping) + return; + trace_dump_writes("</elem>"); } void trace_dump_struct_begin(const char *name) { + if (!dumping) + return; + trace_dump_writef("<struct name='%s'>", name); } void trace_dump_struct_end(void) { + if (!dumping) + return; + trace_dump_writes("</struct>"); } void trace_dump_member_begin(const char *name) { + if (!dumping) + return; + trace_dump_writef("<member name='%s'>", name); } void trace_dump_member_end(void) { + if (!dumping) + return; + trace_dump_writes("</member>"); } void trace_dump_null(void) { + if (!dumping) + return; + trace_dump_writes("<null/>"); } void trace_dump_ptr(const void *value) { + if (!dumping) + return; + if(value) trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value); else @@ -424,6 +565,9 @@ void trace_dump_ptr(const void *value) void trace_dump_buffer_ptr(struct pipe_buffer *_buffer) { + if (!dumping) + return; + if (_buffer) { struct trace_buffer *tr_buf = trace_buffer(_buffer); trace_dump_ptr(tr_buf->buffer); @@ -434,6 +578,9 @@ void trace_dump_buffer_ptr(struct pipe_buffer *_buffer) void trace_dump_texture_ptr(struct pipe_texture *_texture) { + if (!dumping) + return; + if (_texture) { struct trace_texture *tr_tex = trace_texture(_texture); trace_dump_ptr(tr_tex->texture); @@ -444,6 +591,9 @@ void trace_dump_texture_ptr(struct pipe_texture *_texture) void trace_dump_surface_ptr(struct pipe_surface *_surface) { + if (!dumping) + return; + if (_surface) { struct trace_surface *tr_surf = trace_surface(_surface); trace_dump_ptr(tr_surf->surface); @@ -454,6 +604,9 @@ void trace_dump_surface_ptr(struct pipe_surface *_surface) void trace_dump_transfer_ptr(struct pipe_transfer *_transfer) { + if (!dumping) + return; + if (_transfer) { struct trace_transfer *tr_tran = trace_transfer(_transfer); trace_dump_ptr(tr_tran->transfer); diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h index 26409f26c66..8b72b5c9fc0 100644 --- a/src/gallium/drivers/trace/tr_dump.h +++ b/src/gallium/drivers/trace/tr_dump.h @@ -42,11 +42,42 @@ struct pipe_texture; struct pipe_surface; struct pipe_transfer; +/* + * Low level dumping controls. + * + * Opening the trace file and checking if that is opened. + */ boolean trace_dump_trace_begin(void); -boolean trace_dump_enabled(void); +boolean trace_dump_trace_enabled(void); void trace_dump_trace_end(void); + +/* + * Lock and unlock the call mutex. + * + * It used by the none locked version of dumping control + * and begin/end call dump functions. + * + * Begin takes the lock while end unlocks it. Use the _locked + * version to avoid locking/unlocking it. + */ +void trace_dump_call_lock(void); +void trace_dump_call_unlock(void); + +/* + * High level dumping control. + */ +void trace_dumping_start_locked(void); +void trace_dumping_stop_locked(void); +boolean trace_dumping_enabled_locked(void); +void trace_dumping_start(void); +void trace_dumping_stop(void); +boolean trace_dumping_enabled(void); + +void trace_dump_call_begin_locked(const char *klass, const char *method); +void trace_dump_call_end_locked(void); void trace_dump_call_begin(const char *klass, const char *method); void trace_dump_call_end(void); + void trace_dump_arg_begin(const char *name); void trace_dump_arg_end(void); void trace_dump_ret_begin(void); diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 7205dfd1d99..549525b82a5 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -843,6 +843,8 @@ trace_screen_create(struct pipe_screen *screen) if(!trace_dump_trace_begin()) goto error1; + trace_dumping_start(); + trace_dump_call_begin("", "pipe_screen_create"); tr_scr = CALLOC_STRUCT(trace_screen); |