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/nuttx.git

commit 160f61cd4dd941ebdc12fb3aabcb79070de2a334
Author: anjiahao <[email protected]>
AuthorDate: Thu Sep 12 17:11:44 2024 +0800

    memdump.py:add some error info to mmforeach and try dump mempool frist
    
    Signed-off-by: anjiahao <[email protected]>
---
 tools/gdb/memdump.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/gdb/memdump.py b/tools/gdb/memdump.py
index a5c1e7c408..b925aa80db 100644
--- a/tools/gdb/memdump.py
+++ b/tools/gdb/memdump.py
@@ -83,6 +83,9 @@ def mm_foreach(heap):
             yield node
             next = int(node) + mm_nodesize(node["size"])
             next = gdb.Value(next).cast(mm_allocnode_type.pointer())
+            if node == next:
+                gdb.write(f"Error: maybe have memory fault on {hex(node)}\n")
+                break
             node = next
 
 
@@ -460,6 +463,12 @@ class Memdump(gdb.Command):
         mempool_node = []
 
         heap = gdb.parse_and_eval("g_mmheap")
+        if heap.type.has_key("mm_mpool"):
+            if self.mempool_dump(
+                heap["mm_mpool"], pid, seqmin, seqmax, address, simple, detail
+            ):
+                return
+
         prev_node = None
 
         for gdb_node in mm_foreach(heap):
@@ -492,12 +501,6 @@ class Memdump(gdb.Command):
             else:
                 free_node.append(node)
 
-        if heap.type.has_key("mm_mpool"):
-            if self.mempool_dump(
-                heap["mm_mpool"], pid, seqmin, seqmax, address, simple, detail
-            ):
-                return
-
         title_dict = {
             PID_MM_ALLOC: "Dump all used memory node info, use 
'\x1b[33;1m*\x1b[m' mark pid does not exist:\n",
             PID_MM_MEMPOOL: "Dump mempool:\n",

Reply via email to