summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_debug_memory.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-02-20 11:35:23 +0000
committerJosé Fonseca <jfonseca@vmware.com>2009-02-20 11:54:18 +0000
commitee4e4a6b964a3a91fcb922d4e82abff62da39102 (patch)
tree76a8593cc93253ce2c84e01db31e5a486bde99ed /src/gallium/auxiliary/util/u_debug_memory.c
parentd67bd60ecf13331ec5aa12bdb88b35f44dccdeb0 (diff)
util: Stack backtracing facilities.
Not much useful until we have symbol lookup.
Diffstat (limited to 'src/gallium/auxiliary/util/u_debug_memory.c')
-rw-r--r--src/gallium/auxiliary/util/u_debug_memory.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_debug_memory.c b/src/gallium/auxiliary/util/u_debug_memory.c
index f6c136f6e5..758541c282 100644
--- a/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/src/gallium/auxiliary/util/u_debug_memory.c
@@ -45,10 +45,12 @@
#endif
#include "util/u_debug.h"
+#include "util/u_debug_stack.h"
#include "util/u_double_list.h"
#define DEBUG_MEMORY_MAGIC 0x6e34090aU
+#define DEBUG_MEMORY_STACK 0 /* XXX: disabled until we have symbol lookup */
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
@@ -71,7 +73,9 @@ struct debug_memory_header
const char *file;
unsigned line;
const char *function;
+ struct debug_stack_frame backtrace[DEBUG_MEMORY_STACK];
size_t size;
+
unsigned magic;
};
@@ -136,6 +140,8 @@ debug_malloc(const char *file, unsigned line, const char *function,
hdr->size = size;
hdr->magic = DEBUG_MEMORY_MAGIC;
+ debug_backtrace_capture(hdr->backtrace, 0, DEBUG_MEMORY_STACK);
+
ftr = footer_from_header(hdr);
ftr->magic = DEBUG_MEMORY_MAGIC;
@@ -290,6 +296,7 @@ debug_memory_end(unsigned long start_no)
debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
hdr->file, hdr->line, hdr->function,
hdr->size, ptr);
+ debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK);
total_size += hdr->size;
}