From 8f17572be0a5a572f94bd476811087f634c26de6 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Fri, 14 Aug 2015 07:35:21 +0200 Subject: core: dprintf on malloc/free if -DDEBUG_MALLOC When dynamic debug is engaged, the output is pretty flooded by malloc/free messages while you are looking at other traces. As devel.mk have a DEBUG_MALLOC option, it seems pretty logical to enable the malloc/free dprintf() only if this option is engaged. That patch make the dynamic debug output less floody while letting the choice to get the malloc/free dprintf() messages. --- core/mem/free.c | 2 ++ core/mem/malloc.c | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'core') diff --git a/core/mem/free.c b/core/mem/free.c index 2d16cd1c..21f9b59f 100644 --- a/core/mem/free.c +++ b/core/mem/free.c @@ -87,7 +87,9 @@ void bios_free(void *ptr) __export void free(void *ptr) { +#ifdef DEBUG_MALLOC dprintf("free(%p) @ %p\n", ptr, __builtin_return_address(0)); +#endif if ( !ptr ) return; diff --git a/core/mem/malloc.c b/core/mem/malloc.c index b40c2f21..836c2fe3 100644 --- a/core/mem/malloc.c +++ b/core/mem/malloc.c @@ -93,14 +93,18 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag) { void *p; +#ifdef DEBUG_MALLOC dprintf("_malloc(%zu, %u, %u) @ %p = ", size, heap, tag, __builtin_return_address(0)); +#endif sem_down(&__malloc_semaphore, 0); p = firmware->mem->malloc(size, heap, tag); sem_up(&__malloc_semaphore); +#ifdef DEBUG_MALLOC dprintf("%p\n", p); +#endif return p; } -- cgit v1.2.1