Commit 47d0d128 authored by Leonard Crestez's avatar Leonard Crestez Committed by Linus Torvalds

scripts/gdb: add hlist utilities

This allows easily examining kernel hlists in python.

Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: default avatarStephen 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 494dbe02
...@@ -16,6 +16,8 @@ import gdb ...@@ -16,6 +16,8 @@ import gdb
from linux import utils from linux import utils
list_head = utils.CachedType("struct list_head") list_head = utils.CachedType("struct list_head")
hlist_head = utils.CachedType("struct hlist_head")
hlist_node = utils.CachedType("struct hlist_node")
def list_for_each(head): def list_for_each(head):
...@@ -39,6 +41,27 @@ def list_for_each_entry(head, gdbtype, member): ...@@ -39,6 +41,27 @@ def list_for_each_entry(head, gdbtype, member):
yield utils.container_of(node, gdbtype, member) yield utils.container_of(node, gdbtype, member)
def hlist_for_each(head):
if head.type == hlist_head.get_type().pointer():
head = head.dereference()
elif head.type != hlist_head.get_type():
raise gdb.GdbError("Must be struct hlist_head not {}"
.format(head.type))
node = head['first'].dereference()
while node.address:
yield node.address
node = node['next'].dereference()
def hlist_for_each_entry(head, gdbtype, member):
for node in hlist_for_each(head):
if node.type != hlist_node.get_type().pointer():
raise TypeError("Type {} found. Expected struct hlist_head *."
.format(node.type))
yield utils.container_of(node, gdbtype, member)
def list_check(head): def list_check(head):
nb = 0 nb = 0
if (head.type == list_head.get_type().pointer()): if (head.type == list_head.get_type().pointer()):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment