diff options
author | Leonard Crestez <leonard.crestez@nxp.com> | 2019-05-14 18:46:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-14 22:52:52 -0400 |
commit | 47d0d12855c9eee9dac72d2359f2ccfac3f7f501 (patch) | |
tree | 2b5de8525f229a02432c8edc6a2aad79ca7ce103 /scripts/gdb/linux/lists.py | |
parent | 494dbe02b6df0bd98f7353c21e0b9849a25d2dce (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 <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb/linux/lists.py')
-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()): |