From 9ce07efd0b1b2cc2493dc0c022d8d8b984160d6d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 24 Feb 2010 18:25:58 -0800 Subject: [PATCH] core/mem: better dprintf() Add a few dprintf() statements to the core malloc/free which makes it easier to track down bugs. Signed-off-by: H. Peter Anvin --- core/mem/free.c | 4 ++-- core/mem/malloc.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/mem/free.c b/core/mem/free.c index 79ab58f..0becb9e 100644 --- a/core/mem/free.c +++ b/core/mem/free.c @@ -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; diff --git a/core/mem/malloc.c b/core/mem/malloc.c index 20d5dfc..78f7b41 100644 --- a/core/mem/malloc.c +++ b/core/mem/malloc.c @@ -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 */ -- 2.7.4