aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2017-03-24 15:04:58 -0400
committerRob Clark <[email protected]>2017-04-03 11:32:17 -0400
commitc3c884c49ce6ab06df2e49aa39abbb051c9959b5 (patch)
treea295a55a4e2fa4f60e5cfb2cd1f4bb6c08b2007f /src/gallium/auxiliary
parent0c0b29591c264fa386b1354b6efb85375af3213a (diff)
gallium/util: clean up stack frame printing
Prep work for next patch. Ideally 'struct debug_stack_frame' would be opaque, but it is embedded in a bunch of places. But at least we can treat it opaquely. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_debug_refcnt.c27
-rw-r--r--src/gallium/auxiliary/util/u_debug_stack.c17
-rw-r--r--src/gallium/auxiliary/util/u_debug_stack.h5
3 files changed, 26 insertions, 23 deletions
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c b/src/gallium/auxiliary/util/u_debug_refcnt.c
index cb0158253e1..728dbee9735 100644
--- a/src/gallium/auxiliary/util/u_debug_refcnt.c
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.c
@@ -134,18 +134,6 @@ debug_serial_delete(void *p)
#define STACK_LEN 64
-static void
-dump_stack(const char *symbols[STACK_LEN])
-{
- unsigned i;
- for (i = 0; i < STACK_LEN; ++i) {
- if (symbols[i])
- fprintf(stream, "%s\n", symbols[i]);
- }
- fprintf(stream, "\n");
-}
-
-
/**
* Log a reference count change to the log file (if enabled).
* This is called via the pipe_reference() and debug_reference() functions,
@@ -180,7 +168,6 @@ debug_reference_slowpath(const struct pipe_reference *p,
if (debug_refcnt_state > 0) {
struct debug_stack_frame frames[STACK_LEN];
- const char *symbols[STACK_LEN];
char buf[1024];
unsigned i;
unsigned refcnt = p->count;
@@ -188,18 +175,12 @@ debug_reference_slowpath(const struct pipe_reference *p,
boolean existing = debug_serial((void *) p, &serial);
debug_backtrace_capture(frames, 1, STACK_LEN);
- for (i = 0; i < STACK_LEN; ++i) {
- if (frames[i].function)
- symbols[i] = debug_symbol_name_cached(frames[i].function);
- else
- symbols[i] = 0;
- }
get_desc(buf, p);
if (!existing) {
fprintf(stream, "<%s> %p %u Create\n", buf, (void *) p, serial);
- dump_stack(symbols);
+ debug_backtrace_print(stream, frames, STACK_LEN);
/* this is here to provide a gradual change even if we don't see
* the initialization
@@ -207,20 +188,20 @@ debug_reference_slowpath(const struct pipe_reference *p,
for (i = 1; i <= refcnt - change; ++i) {
fprintf(stream, "<%s> %p %u AddRef %u\n", buf, (void *) p,
serial, i);
- dump_stack(symbols);
+ debug_backtrace_print(stream, frames, STACK_LEN);
}
}
if (change) {
fprintf(stream, "<%s> %p %u %s %u\n", buf, (void *) p, serial,
change > 0 ? "AddRef" : "Release", refcnt);
- dump_stack(symbols);
+ debug_backtrace_print(stream, frames, STACK_LEN);
}
if (!refcnt) {
debug_serial_delete((void *) p);
fprintf(stream, "<%s> %p %u Destroy\n", buf, (void *) p, serial);
- dump_stack(symbols);
+ debug_backtrace_print(stream, frames, STACK_LEN);
}
fflush(stream);
diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c
index 1faa1903a76..f941234de20 100644
--- a/src/gallium/auxiliary/util/u_debug_stack.c
+++ b/src/gallium/auxiliary/util/u_debug_stack.c
@@ -162,3 +162,20 @@ debug_backtrace_dump(const struct debug_stack_frame *backtrace,
}
}
+
+void
+debug_backtrace_print(FILE *f,
+ const struct debug_stack_frame *backtrace,
+ unsigned nr_frames)
+{
+ unsigned i;
+
+ for (i = 0; i < nr_frames; ++i) {
+ const char *symbol;
+ if (!backtrace[i].function)
+ break;
+ symbol = debug_symbol_name_cached(backtrace[i].function);
+ if (symbol)
+ fprintf(f, "%s\n", symbol);
+ }
+}
diff --git a/src/gallium/auxiliary/util/u_debug_stack.h b/src/gallium/auxiliary/util/u_debug_stack.h
index b1848ddefa8..04eba08f89a 100644
--- a/src/gallium/auxiliary/util/u_debug_stack.h
+++ b/src/gallium/auxiliary/util/u_debug_stack.h
@@ -28,6 +28,7 @@
#ifndef U_DEBUG_STACK_H_
#define U_DEBUG_STACK_H_
+#include <stdio.h>
/**
* @file
@@ -64,6 +65,10 @@ void
debug_backtrace_dump(const struct debug_stack_frame *backtrace,
unsigned nr_frames);
+void
+debug_backtrace_print(FILE *f,
+ const struct debug_stack_frame *backtrace,
+ unsigned nr_frames);
#ifdef __cplusplus
}