util: Enable assembly breakpointt on x86_64.
[mesa.git] / src / gallium / auxiliary / util / u_debug_memory.c
index f6c136f6e5a32a7a21cfad8d6dcb7d080d681973..7623cb93981b5beaf1d18403a2b82189b30a6ee5 100644 (file)
 #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,11 @@ struct debug_memory_header
    const char *file;
    unsigned line;
    const char *function;
+#if DEBUG_MEMORY_STACK
+   struct debug_stack_frame backtrace[DEBUG_MEMORY_STACK];
+#endif
    size_t size;
+   
    unsigned magic;
 };
 
@@ -136,6 +142,10 @@ debug_malloc(const char *file, unsigned line, const char *function,
    hdr->size = size;
    hdr->magic = DEBUG_MEMORY_MAGIC;
 
+#if DEBUG_MEMORY_STACK
+   debug_backtrace_capture(hdr->backtrace, 0, DEBUG_MEMORY_STACK);
+#endif
+
    ftr = footer_from_header(hdr);
    ftr->magic = DEBUG_MEMORY_MAGIC;
    
@@ -290,6 +300,9 @@ 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);
+#if DEBUG_MEMORY_STACK
+        debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK);
+#endif
         total_size += hdr->size;
       }