core/mem: better dprintf()
authorH. Peter Anvin <hpa@zytor.com>
Thu, 25 Feb 2010 02:25:58 +0000 (18:25 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 25 Feb 2010 02:25:58 +0000 (18:25 -0800)
Add a few dprintf() statements to the core malloc/free which makes it
easier to track down bugs.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/mem/free.c
core/mem/malloc.c

index 79ab58f..0becb9e 100644 (file)
@@ -15,8 +15,6 @@ __free_block(struct free_arena_header *ah)
     struct free_arena_header *head =
        &__malloc_head[ARENA_HEAP_GET(ah->a.attrs)];
 
-    dprintf("free(%p)\n", (struct arena_header *)ah + 1);
-
     pah = ah->a.prev;
     nah = ah->a.next;
     if ( ARENA_TYPE_GET(pah->a.attrs) == ARENA_TYPE_FREE &&
@@ -70,6 +68,8 @@ void free(void *ptr)
 {
     struct free_arena_header *ah;
 
+    dprintf("free(%p) @ %p\n", ptr, __builtin_return_address(0));
+
     if ( !ptr )
         return;
 
index 20d5dfc..78f7b41 100644 (file)
@@ -63,7 +63,8 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
     struct free_arena_header *head = &__malloc_head[heap];
     void *p = NULL;
 
-    dprintf("_malloc(%zu, %u, %u) = ", size, heap, tag);
+    dprintf("_malloc(%zu, %u, %u) @ %p = ",
+           size, heap, tag, __builtin_return_address(0));
 
     if (size) {
        /* Add the obligatory arena header, and round up */