The patch titled Subject: scripts/gdb: add hlist utilities has been added to the -mm tree. Its filename is scripts-gdb-add-hlist-utilities.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/scripts-gdb-add-hlist-utilities.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/scripts-gdb-add-hlist-utilities.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Leonard Crestez <leonard.crestez@xxxxxxx> Subject: 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@xxxxxxx> Cc: Stephen Boyd <swboyd@xxxxxxxxxxxx> Cc: Jason Wessel <jason.wessel@xxxxxxxxxxxxx> Cc: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> Cc: Kieran Bingham <kbingham@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/gdb/linux/lists.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) --- a/scripts/gdb/linux/lists.py~scripts-gdb-add-hlist-utilities +++ a/scripts/gdb/linux/lists.py @@ -16,6 +16,8 @@ import gdb from linux import utils 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): @@ -38,6 +40,27 @@ def list_for_each_entry(head, gdbtype, m .format(node.type)) 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): nb = 0 _ Patches currently in -mm which might be from leonard.crestez@xxxxxxx are scripts-gdb-add-hlist-utilities.patch scripts-gdb-initial-clk-support-lx-clk-summary.patch scripts-gdb-add-lx_clk_core_lookup-function.patch