From ee4e4a6b964a3a91fcb922d4e82abff62da39102 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 20 Feb 2009 11:35:23 +0000 Subject: util: Stack backtracing facilities. Not much useful until we have symbol lookup. --- src/gallium/auxiliary/util/u_debug_memory.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium/auxiliary/util/u_debug_memory.c') diff --git a/src/gallium/auxiliary/util/u_debug_memory.c b/src/gallium/auxiliary/util/u_debug_memory.c index f6c136f6e5a..758541c2829 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; } -- cgit v1.2.3