diff options
Diffstat (limited to 'scripts/gdb')
-rw-r--r-- | scripts/gdb/linux/lists.py | 23 |
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 | |||
16 | from linux import utils | 16 | from linux import utils |
17 | 17 | ||
18 | list_head = utils.CachedType("struct list_head") | 18 | list_head = utils.CachedType("struct list_head") |
19 | hlist_head = utils.CachedType("struct hlist_head") | ||
20 | hlist_node = utils.CachedType("struct hlist_node") | ||
19 | 21 | ||
20 | 22 | ||
21 | def list_for_each(head): | 23 | def list_for_each(head): |
@@ -39,6 +41,27 @@ def list_for_each_entry(head, gdbtype, member): | |||
39 | yield utils.container_of(node, gdbtype, member) | 41 | yield utils.container_of(node, gdbtype, member) |
40 | 42 | ||
41 | 43 | ||
44 | def hlist_for_each(head): | ||
45 | if head.type == hlist_head.get_type().pointer(): | ||
46 | head = head.dereference() | ||
47 | elif head.type != hlist_head.get_type(): | ||
48 | raise gdb.GdbError("Must be struct hlist_head not {}" | ||
49 | .format(head.type)) | ||
50 | |||
51 | node = head['first'].dereference() | ||
52 | while node.address: | ||
53 | yield node.address | ||
54 | node = node['next'].dereference() | ||
55 | |||
56 | |||
57 | def hlist_for_each_entry(head, gdbtype, member): | ||
58 | for node in hlist_for_each(head): | ||
59 | if node.type != hlist_node.get_type().pointer(): | ||
60 | raise TypeError("Type {} found. Expected struct hlist_head *." | ||
61 | .format(node.type)) | ||
62 | yield utils.container_of(node, gdbtype, member) | ||
63 | |||
64 | |||
42 | def list_check(head): | 65 | def list_check(head): |
43 | nb = 0 | 66 | nb = 0 |
44 | if (head.type == list_head.get_type().pointer()): | 67 | if (head.type == list_head.get_type().pointer()): |