mm: Do not abort on allocation failue with CONFIG_DEBUG_MM

When allocation failed, it isn't too uncommon for the caller
to fall back to other allocation method.
(eg. esp32 textheap code tries iram heap when an allocation from rtc heap
failed.)
DEBUGASSERT(false) is too much in that case.

This commit removes the DEBUGASSERT, and also makes the heap dump
a separate option.
This commit is contained in:
YAMAMOTO Takashi 2022-05-20 17:20:10 +09:00 committed by Xiang Xiao
parent 2f03b42bfc
commit c546c0b647
2 changed files with 9 additions and 1 deletions

View File

@ -191,4 +191,9 @@ config MM_BACKTRACE_DEFAULT
default n
depends on DEBUG_MM
config MM_DUMP_ON_FAILURE
bool "Dump heap info on allocation failure"
default n
depends on DEBUG_MM
source "mm/iob/Kconfig"

View File

@ -244,15 +244,18 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
#ifdef CONFIG_DEBUG_MM
else
{
#ifdef CONFIG_MM_DUMP_ON_FAILURE
struct mallinfo minfo;
#endif
mwarn("WARNING: Allocation failed, size %zu\n", alignsize);
#ifdef CONFIG_MM_DUMP_ON_FAILURE
mm_mallinfo(heap, &minfo);
mwarn("Total:%d, used:%d, free:%d, largest:%d, nused:%d, nfree:%d\n",
minfo.arena, minfo.uordblks, minfo.fordblks,
minfo.mxordblk, minfo.aordblks, minfo.ordblks);
mm_memdump(heap, -1);
DEBUGASSERT(false);
#endif
}
#endif