From: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
To: kuan-ying.lee@canonical.com,
Andrew Morton <akpm@linux-foundation.org>,
Jan Kiszka <jan.kiszka@siemens.com>,
Kieran Bingham <kbingham@kernel.org>,
Miklos Szeredi <mszeredi@redhat.com>,
Christian Brauner <brauner@kernel.org>,
Ian Kent <raven@themaw.net>
Cc: linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/5] scripts/gdb: add iteration function for rbtree
Date: Tue, 23 Jul 2024 14:48:58 +0800 [thread overview]
Message-ID: <20240723064902.124154-3-kuan-ying.lee@canonical.com> (raw)
In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com>
Add inorder iteration function for rbtree usage.
This is a preparation patch for the next patch to
fix the gdb mounts issue.
Fixes: 2eea9ce4310d ("mounts: keep list of mounts in an rbtree")
Cc: <stable@vger.kernel.org>
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
scripts/gdb/linux/rbtree.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/scripts/gdb/linux/rbtree.py b/scripts/gdb/linux/rbtree.py
index fe462855eefd..fcbcc5f4153c 100644
--- a/scripts/gdb/linux/rbtree.py
+++ b/scripts/gdb/linux/rbtree.py
@@ -9,6 +9,18 @@ from linux import utils
rb_root_type = utils.CachedType("struct rb_root")
rb_node_type = utils.CachedType("struct rb_node")
+def rb_inorder_for_each(root):
+ def inorder(node):
+ if node:
+ yield from inorder(node['rb_left'])
+ yield node
+ yield from inorder(node['rb_right'])
+
+ yield from inorder(root['rb_node'])
+
+def rb_inorder_for_each_entry(root, gdbtype, member):
+ for node in rb_inorder_for_each(root):
+ yield utils.container_of(node, gdbtype, member)
def rb_first(root):
if root.type == rb_root_type.get_type():
--
2.34.1
next prev parent reply other threads:[~2024-07-23 6:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 6:48 [PATCH v3 0/5] Fix some GDB command error and add some GDB commands Kuan-Ying Lee
2024-07-23 6:48 ` [PATCH v3 1/5] scripts/gdb: fix timerlist parsing issue Kuan-Ying Lee
2024-07-23 6:48 ` Kuan-Ying Lee [this message]
2024-07-23 6:48 ` [PATCH v3 3/5] scripts/gdb: fix lx-mounts command error Kuan-Ying Lee
2024-07-23 6:49 ` [PATCH v3 4/5] scripts/gdb: Add 'lx-stack_depot_lookup' command Kuan-Ying Lee
2024-07-23 6:49 ` [PATCH v3 5/5] scripts/gdb: Add 'lx-kasan_mem_to_shadow' command Kuan-Ying Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240723064902.124154-3-kuan-ying.lee@canonical.com \
--to=kuan-ying.lee@canonical.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=jan.kiszka@siemens.com \
--cc=kbingham@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox