mm: Dump all memory blocks on allocation failure
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
484d349fe3
commit
aad2f97587
@ -298,6 +298,11 @@ config MM_DUMP_ON_FAILURE
|
||||
default n
|
||||
depends on DEBUG_MM
|
||||
|
||||
config MM_DUMP_DETAILS_ON_FAILURE
|
||||
bool "Dump all used memory blocks on allocation failure"
|
||||
default n
|
||||
depends on MM_DUMP_ON_FAILURE
|
||||
|
||||
config MM_PANIC_ON_FAILURE
|
||||
bool "Panic on allocation failure"
|
||||
default n
|
||||
|
@ -273,6 +273,12 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
|
||||
{
|
||||
#ifdef CONFIG_MM_DUMP_ON_FAILURE
|
||||
struct mallinfo minfo;
|
||||
# ifdef CONFIG_MM_DUMP_DETAILS_ON_FAILURE
|
||||
struct mm_memdump_s dump =
|
||||
{
|
||||
MM_BACKTRACE_ALLOC_PID, 0, ULONG_MAX
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
mwarn("WARNING: Allocation failed, size %zu\n", alignsize);
|
||||
@ -291,7 +297,9 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
|
||||
mempool_multiple_foreach(heap->mm_mpool,
|
||||
mm_mempool_dump_handle, NULL);
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_MM_DUMP_DETAILS_ON_FAILURE
|
||||
mm_memdump(heap, &dump);
|
||||
# endif
|
||||
#endif
|
||||
#ifdef CONFIG_MM_PANIC_ON_FAILURE
|
||||
PANIC();
|
||||
|
Loading…
Reference in New Issue
Block a user