Skip to content

Commit

Permalink
core: dprintf on malloc/free if -DDEBUG_MALLOC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ErwanAliasr1 committed Sep 2, 2015
1 parent 73bb370 commit 8f17572
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/mem/free.c
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions core/mem/malloc.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8f17572

Please sign in to comment.