summaryrefslogtreecommitdiff
path: root/scripts/gdb/linux/lists.py
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-06-08 14:02:16 +0300
committerIngo Molnar <mingo@kernel.org>2016-06-08 14:02:16 +0300
commit8e8c668927b029f6ccc350eb1aa936864cc4eb6f (patch)
treef91ec6d49e2b01de5b4b3d517209d13b216a3f0f /scripts/gdb/linux/lists.py
parentf0133acc7d4835cfbb86393b7d2a4fba7519585b (diff)
parent970442c599b22ccd644ebfe94d1d303bf6f87c05 (diff)
downloadlinux-8e8c668927b029f6ccc350eb1aa936864cc4eb6f.tar.xz
Merge branch 'x86/urgent' into x86/cpu, to pick up dependency
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'scripts/gdb/linux/lists.py')
-rw-r--r--scripts/gdb/linux/lists.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 3a3775bc162b..2f335fbd86fd 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -18,6 +18,27 @@ from linux import utils
list_head = utils.CachedType("struct list_head")
+def list_for_each(head):
+ if head.type == list_head.get_type().pointer():
+ head = head.dereference()
+ elif head.type != list_head.get_type():
+ raise gdb.GdbError("Must be struct list_head not {}"
+ .format(head.type))
+
+ node = head['next'].dereference()
+ while node.address != head.address:
+ yield node.address
+ node = node['next'].dereference()
+
+
+def list_for_each_entry(head, gdbtype, member):
+ for node in list_for_each(head):
+ if node.type != list_head.get_type().pointer():
+ raise TypeError("Type {} found. Expected struct list_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()):