aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Crestez <[email protected]>2019-05-14 15:46:05 -0700
committerLinus Torvalds <[email protected]>2019-05-14 19:52:52 -0700
commit47d0d12855c9eee9dac72d2359f2ccfac3f7f501 (patch)
tree2b5de8525f229a02432c8edc6a2aad79ca7ce103
parent494dbe02b6df0bd98f7353c21e0b9849a25d2dce (diff)
scripts/gdb: add hlist utilities
This allows easily examining kernel hlists in python. Link: http://lkml.kernel.org/r/Message-ID: Signed-off-by: Leonard Crestez <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Cc: Jason Wessel <[email protected]> Cc: Jan Kiszka <[email protected]> Cc: Kieran Bingham <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--scripts/gdb/linux/lists.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 1987d756b36b..55356b66f8ea 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -16,6 +16,8 @@ import gdb
from linux import utils
list_head = utils.CachedType("struct list_head")
+hlist_head = utils.CachedType("struct hlist_head")
+hlist_node = utils.CachedType("struct hlist_node")
def list_for_each(head):
@@ -39,6 +41,27 @@ def list_for_each_entry(head, gdbtype, member):
yield utils.container_of(node, gdbtype, member)
+def hlist_for_each(head):
+ if head.type == hlist_head.get_type().pointer():
+ head = head.dereference()
+ elif head.type != hlist_head.get_type():
+ raise gdb.GdbError("Must be struct hlist_head not {}"
+ .format(head.type))
+
+ node = head['first'].dereference()
+ while node.address:
+ yield node.address
+ node = node['next'].dereference()
+
+
+def hlist_for_each_entry(head, gdbtype, member):
+ for node in hlist_for_each(head):
+ if node.type != hlist_node.get_type().pointer():
+ raise TypeError("Type {} found. Expected struct hlist_head *."
+ .format(node.type))
+ yield utils.container_of(node, gdbtype, member)
+
+
def list_check(head):
nb = 0
if (head.type == list_head.get_type().pointer()):