aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/lists.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gdb/linux/lists.py')
-rw-r--r--scripts/gdb/linux/lists.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 2f335fbd86fd..c487ddf09d38 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -16,13 +16,15 @@ import gdb
16from linux import utils 16from linux import utils
17 17
18list_head = utils.CachedType("struct list_head") 18list_head = utils.CachedType("struct list_head")
19hlist_head = utils.CachedType("struct hlist_head")
20hlist_node = utils.CachedType("struct hlist_node")
19 21
20 22
21def list_for_each(head): 23def list_for_each(head):
22 if head.type == list_head.get_type().pointer(): 24 if head.type == list_head.get_type().pointer():
23 head = head.dereference() 25 head = head.dereference()
24 elif head.type != list_head.get_type(): 26 elif head.type != list_head.get_type():
25 raise gdb.GdbError("Must be struct list_head not {}" 27 raise TypeError("Must be struct list_head not {}"
26 .format(head.type)) 28 .format(head.type))
27 29
28 node = head['next'].dereference() 30 node = head['next'].dereference()
@@ -33,9 +35,24 @@ def list_for_each(head):
33 35
34def list_for_each_entry(head, gdbtype, member): 36def list_for_each_entry(head, gdbtype, member):
35 for node in list_for_each(head): 37 for node in list_for_each(head):
36 if node.type != list_head.get_type().pointer(): 38 yield utils.container_of(node, gdbtype, member)
37 raise TypeError("Type {} found. Expected struct list_head *." 39
38 .format(node.type)) 40
41def hlist_for_each(head):
42 if head.type == hlist_head.get_type().pointer():
43 head = head.dereference()
44 elif head.type != hlist_head.get_type():
45 raise TypeError("Must be struct hlist_head not {}"
46 .format(head.type))
47
48 node = head['first'].dereference()
49 while node.address:
50 yield node.address
51 node = node['next'].dereference()
52
53
54def hlist_for_each_entry(head, gdbtype, member):
55 for node in hlist_for_each(head):
39 yield utils.container_of(node, gdbtype, member) 56 yield utils.container_of(node, gdbtype, member)
40 57
41 58
@@ -110,4 +127,5 @@ class LxListChk(gdb.Command):
110 raise gdb.GdbError("lx-list-check takes one argument") 127 raise gdb.GdbError("lx-list-check takes one argument")
111 list_check(gdb.parse_and_eval(argv[0])) 128 list_check(gdb.parse_and_eval(argv[0]))
112 129
130
113LxListChk() 131LxListChk()