You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/02/26 06:32:55 UTC

[incubator-nuttx] 05/06: mm/memdump: fix print backtrace abnormal

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 168074fe2eddd1e6265c6378af980e165e3dc55d
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Wed Feb 9 15:27:22 2022 +0800

    mm/memdump: fix print backtrace abnormal
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 mm/mm_heap/mm_memdump.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/mm_heap/mm_memdump.c b/mm/mm_heap/mm_memdump.c
index 4cea66d6..cc99a8e 100644
--- a/mm/mm_heap/mm_memdump.c
+++ b/mm/mm_heap/mm_memdump.c
@@ -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",