diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 67cffc44e8..46afac384e 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "tlsf/tlsf.h" @@ -144,9 +145,15 @@ struct memdump_backtrace_s static void memdump_backtrace(FAR struct mm_heap_s *heap, FAR struct memdump_backtrace_s *dump) { +# if CONFIG_MM_BACKTRACE > 0 + FAR struct tcb_s *tcb; +# endif + dump->pid = getpid(); # if CONFIG_MM_BACKTRACE > 0 - if (heap->mm_procfs.backtrace) + tcb = nxsched_get_tcb(dump->pid); + if (heap->mm_procfs.backtrace || + (tcb && tcb->flags & TCB_FLAG_HEAPDUMP)) { int ret = backtrace(dump->backtrace, CONFIG_MM_BACKTRACE); while (ret < CONFIG_MM_BACKTRACE)