Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Link: https://lkml.kernel.org/r/20240723064902.124154-3-kuan-ying.lee@canonical.com
Fixes: 2eea9ce4310d ("mounts: keep list of mounts in an rbtree")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kuan-Ying Lee and committed by
Andrew Morton
0c77e103 a633a4b8

+12
+12
scripts/gdb/linux/rbtree.py
··· 9 9 rb_root_type = utils.CachedType("struct rb_root") 10 10 rb_node_type = utils.CachedType("struct rb_node") 11 11 12 + def rb_inorder_for_each(root): 13 + def inorder(node): 14 + if node: 15 + yield from inorder(node['rb_left']) 16 + yield node 17 + yield from inorder(node['rb_right']) 18 + 19 + yield from inorder(root['rb_node']) 20 + 21 + def rb_inorder_for_each_entry(root, gdbtype, member): 22 + for node in rb_inorder_for_each(root): 23 + yield utils.container_of(node, gdbtype, member) 12 24 13 25 def rb_first(root): 14 26 if root.type == rb_root_type.get_type():