mm/memdump: fix print backtrace abnormal

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-02-09 15:27:22 +08:00 committed by Xiang Xiao
parent 7ae3c572dc
commit 168074fe2e
1 changed files with 4 additions and 2 deletions

View File

@ -77,12 +77,14 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
((FAR char *)node + SIZEOF_MM_ALLOCNODE));
#else
int i;
FAR const char *format = " %0*p";
char buf[MM_BACKTRACE_DEPTH * MM_PTR_FMT_WIDTH + 1];
buf[0] = '\0';
for (i = 0; i < MM_BACKTRACE_DEPTH && node->backtrace[i]; i++)
{
sprintf(buf + i * MM_PTR_FMT_WIDTH, " %*p",
MM_PTR_FMT_WIDTH - 3, node->backtrace[i]);
sprintf(buf + i * MM_PTR_FMT_WIDTH, format,
MM_PTR_FMT_WIDTH - 1, node->backtrace[i]);
}
syslog(LOG_INFO, "%6d%12zu%*p%s\n",