[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240723064902.124154-3-kuan-ying.lee@canonical.com>
Date: Tue, 23 Jul 2024 14:48:58 +0800
From: Kuan-Ying Lee <kuan-ying.lee@...onical.com>
To: kuan-ying.lee@...onical.com,
Andrew Morton <akpm@...ux-foundation.org>,
Jan Kiszka <jan.kiszka@...mens.com>,
Kieran Bingham <kbingham@...nel.org>,
Miklos Szeredi <mszeredi@...hat.com>,
Christian Brauner <brauner@...nel.org>,
Ian Kent <raven@...maw.net>
Cc: linux-mm@...ck.org,
stable@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 2/5] scripts/gdb: add iteration function for rbtree
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@...r.kernel.org>
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@...onical.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
Powered by blists - more mailing lists