summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2019-04-26 10:28:17 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2019-04-28 01:04:32 +1000
commit59dee1c9a9522811292b55869a6ef07a77fc8e46 (patch)
treea0cb58735d607c6585a135ce23c6a56c3d47f69d /scripts
parent301503dfca48b35304a052cf028a6e8ebb504d0d (diff)
downloadlinux-next-59dee1c9a9522811292b55869a6ef07a77fc8e46.tar.gz
scripts-gdb-add-rb-tree-iterating-utilities-v2
Link: http://lkml.kernel.org/r/20190329220844.38234-4-swboyd@chromium.org Signed-off-by: Stephen Boyd <swboyd@chromium.org> Cc: Douglas Anderson <dianders@chromium.org> Cc: Nikolay Borisov <n.borisov.lkml@gmail.com> Cc: Kieran Bingham <kbingham@kernel.org> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Jackie Liu <liuyun01@kylinos.cn> Cc: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gdb/linux/rbtree.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/scripts/gdb/linux/rbtree.py b/scripts/gdb/linux/rbtree.py
index fd7b0b961ca1..39db889b874c 100644
--- a/scripts/gdb/linux/rbtree.py
+++ b/scripts/gdb/linux/rbtree.py
@@ -14,8 +14,7 @@ def rb_first(root):
if root.type == rb_root_type.get_type():
node = node.address.cast(rb_root_type.get_type().pointer())
elif root.type != rb_root_type.get_type().pointer():
- raise gdb.GdbError("Must be struct rb_root not {}"
- .format(root.type))
+ raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
node = root['rb_node']
if node is 0:
@@ -26,12 +25,12 @@ def rb_first(root):
return node
+
def rb_last(root):
if root.type == rb_root_type.get_type():
node = node.address.cast(rb_root_type.get_type().pointer())
elif root.type != rb_root_type.get_type().pointer():
- raise gdb.GdbError("Must be struct rb_root not {}"
- .format(root.type))
+ raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
node = root['rb_node']
if node is 0:
@@ -42,19 +41,21 @@ def rb_last(root):
return node
+
def rb_parent(node):
parent = gdb.Value(node['__rb_parent_color'] & ~3)
return parent.cast(rb_node_type.get_type().pointer())
+
def rb_empty_node(node):
return node['__rb_parent_color'] == node.address
+
def rb_next(node):
if node.type == rb_node_type.get_type():
node = node.address.cast(rb_node_type.get_type().pointer())
elif node.type != rb_node_type.get_type().pointer():
- raise gdb.GdbError("Must be struct rb_node not {}"
- .format(node.type))
+ raise gdb.GdbError("Must be struct rb_node not {}".format(node.type))
if rb_empty_node(node):
return None
@@ -72,12 +73,12 @@ def rb_next(node):
return parent
+
def rb_prev(node):
if node.type == rb_node_type.get_type():
node = node.address.cast(rb_node_type.get_type().pointer())
elif node.type != rb_node_type.get_type().pointer():
- raise gdb.GdbError("Must be struct rb_node not {}"
- .format(node.type))
+ raise gdb.GdbError("Must be struct rb_node not {}".format(node.type))
if rb_empty_node(node):
return None
@@ -112,8 +113,10 @@ If index is omitted, the root node is dereferenced and returned."""
return result
+
LxRbFirst()
+
class LxRbLast(gdb.Function):
"""Lookup and return a node from an RBTree.
@@ -130,8 +133,10 @@ If index is omitted, the root node is dereferenced and returned."""
return result
+
LxRbLast()
+
class LxRbNext(gdb.Function):
"""Lookup and return a node from an RBTree.
@@ -148,8 +153,10 @@ If index is omitted, the root node is dereferenced and returned."""
return result
+
LxRbNext()
+
class LxRbPrev(gdb.Function):
"""Lookup and return a node from an RBTree.
@@ -166,4 +173,5 @@ If index is omitted, the root node is dereferenced and returned."""
return result
+
LxRbPrev()