hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/scripts/gdb/linux/lists.py
....@@ -16,13 +16,15 @@
1616 from linux import utils
1717
1818 list_head = utils.CachedType("struct list_head")
19
+hlist_head = utils.CachedType("struct hlist_head")
20
+hlist_node = utils.CachedType("struct hlist_node")
1921
2022
2123 def list_for_each(head):
2224 if head.type == list_head.get_type().pointer():
2325 head = head.dereference()
2426 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 {}"
2628 .format(head.type))
2729
2830 node = head['next'].dereference()
....@@ -33,9 +35,24 @@
3335
3436 def list_for_each_entry(head, gdbtype, member):
3537 for node in list_for_each(head):
36
- if node.type != list_head.get_type().pointer():
37
- raise TypeError("Type {} found. Expected struct list_head *."
38
- .format(node.type))
38
+ yield utils.container_of(node, gdbtype, member)
39
+
40
+
41
+def 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
+
54
+def hlist_for_each_entry(head, gdbtype, member):
55
+ for node in hlist_for_each(head):
3956 yield utils.container_of(node, gdbtype, member)
4057
4158
....@@ -110,4 +127,5 @@
110127 raise gdb.GdbError("lx-list-check takes one argument")
111128 list_check(gdb.parse_and_eval(argv[0]))
112129
130
+
113131 LxListChk()