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 c70f3e3f984f1e837d03bca5444373d6ff94e96d Author: Zhe Weng <[email protected]> AuthorDate: Sat Sep 14 17:40:14 2024 +0800 tools/gdb: Add check for tail when checking a queue Tested for: dq: &g_notifier_pending in both good and bad state (tail goes wrong) sq: &g_sigfreeaction in good state Signed-off-by: Zhe Weng <[email protected]> --- tools/gdb/nuttxgdb/lists.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/gdb/nuttxgdb/lists.py b/tools/gdb/nuttxgdb/lists.py index 7fc6154c73..932b66ed4f 100644 --- a/tools/gdb/nuttxgdb/lists.py +++ b/tools/gdb/nuttxgdb/lists.py @@ -214,15 +214,27 @@ def sq_check(sq): gdb.write("sq_queue head is empty {}\n".format(sq.address)) return + nodes = set() entry = sq["head"].dereference() try: while entry.address: nb += 1 + if int(entry.address) in nodes: + gdb.write("sq_queue is circular: {}\n".format(entry.address)) + return + nodes.add(int(entry.address)) entry = entry["flink"].dereference() except gdb.MemoryError: gdb.write("entry address is unaccessible {}\n".format(entry.address)) return + if int(sq["tail"]) not in nodes: + gdb.write("sq_queue tail is not in the list {}\n".format(sq["tail"])) + return + if sq["tail"]["flink"] != 0: + gdb.write("sq_queue tail->flink is not null {}\n".format(sq["tail"])) + return + gdb.write("sq_queue is consistent: {} node(s)\n".format(nb)) @@ -257,15 +269,28 @@ def dq_check(dq): if dq["head"] == 0: gdb.write("dq_queue head is empty {}\n".format(dq.address)) return + + nodes = set() entry = dq["head"].dereference() try: while entry.address: nb += 1 + if int(entry.address) in nodes: + gdb.write("dq_queue is circular: {}\n".format(entry.address)) + return + nodes.add(int(entry.address)) entry = entry["flink"].dereference() except gdb.MemoryError: gdb.write("entry address is unaccessible {}\n".format(entry.address)) return + if int(dq["tail"]) not in nodes: + gdb.write("dq_queue tail is not in the list {}\n".format(dq["tail"])) + return + if dq["tail"]["flink"] != 0: + gdb.write("dq_queue tail->flink is not null {}\n".format(dq["tail"])) + return + gdb.write("dq_queue is consistent: {} node(s)\n".format(nb))
