The patch titled Subject: scripts/gdb: add command to check list consistency has been added to the -mm tree. Its filename is scripts-gdb-add-command-to-check-list-consistency.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/scripts-gdb-add-command-to-check-list-consistency.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/scripts-gdb-add-command-to-check-list-consistency.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/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Thiébaud Weksteen <thiebaud@xxxxxxxxxxx> Subject: scripts/gdb: add command to check list consistency Add a gdb script to verify the consistency of lists. Signed-off-by: Thiébaud Weksteen <thiebaud@xxxxxxxxxxx> Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/gdb/linux/lists.py | 89 +++++++++++++++++++++++++++++++++++ scripts/gdb/vmlinux-gdb.py | 1 2 files changed, 90 insertions(+) diff -puN /dev/null scripts/gdb/linux/lists.py --- /dev/null +++ a/scripts/gdb/linux/lists.py @@ -0,0 +1,89 @@ +# +# gdb helper commands and functions for Linux kernel debugging +# +# list tools +# +# Copyright (c) Thiebaud Weksteen, 2015 +# +# Authors: +# Thiebaud Weksteen <thiebaud@xxxxxxxxxxx> +# +# This work is licensed under the terms of the GNU GPL version 2. +# + +import gdb + +from linux import utils + +list_head = utils.CachedType("struct list_head") + + +def list_check(head): + nb = 0 + c = head + if (c.type != list_head.get_type()): + raise gdb.GdbError('The argument should be of type (struct list_head)') + try: + gdb.write("Starting with: {}\n".format(c)) + except gdb.MemoryError: + gdb.write('head is not accessible\n') + return + while True: + p = c['prev'].dereference() + n = c['next'].dereference() + try: + if p['next'] != c.address: + gdb.write('prev.next != current: ' + 'current@{current_addr}={current} ' + 'prev@{p_addr}={p}\n'.format( + current_addr=c.address, + current=c, + p_addr=p.address, + p=p, + )) + return + except gdb.MemoryError: + gdb.write('prev is not accessible: ' + 'current@{current_addr}={current}\n'.format( + current_addr=c.address, + current=c + )) + return + try: + if n['prev'] != c.address: + gdb.write('next.prev != current: ' + 'current@{current_addr}={current} ' + 'next@{n_addr}={n}\n'.format( + current_addr=c.address, + current=c, + n_addr=n.address, + n=n, + )) + return + except gdb.MemoryError: + gdb.write('next is not accessible: ' + 'current@{current_addr}={current}\n'.format( + current_addr=c.address, + current=c + )) + return + c = n + nb += 1 + if c == head: + gdb.write("list is consistent: {} node(s)\n".format(nb)) + return + + +class LxListChk(gdb.Command): + """Verify a list consistency""" + + def __init__(self): + super(LxListChk, self).__init__("lx-list-check", gdb.COMMAND_DATA) + + def invoke(self, arg, from_tty): + argv = gdb.string_to_argv(arg) + if len(argv) != 1: + raise gdb.GdbError("lx-list-check takes one argument") + list_check(gdb.parse_and_eval(argv[0])) + +LxListChk() diff -puN scripts/gdb/vmlinux-gdb.py~scripts-gdb-add-command-to-check-list-consistency scripts/gdb/vmlinux-gdb.py --- a/scripts/gdb/vmlinux-gdb.py~scripts-gdb-add-command-to-check-list-consistency +++ a/scripts/gdb/vmlinux-gdb.py @@ -28,3 +28,4 @@ else: import linux.dmesg import linux.tasks import linux.cpus + import linux.lists _ Patches currently in -mm which might be from thiebaud@xxxxxxxxxxx are scripts-gdb-add-command-to-check-list-consistency.patch scripts-gdb-also-allow-list_head-pointer-as-lx-list-check-paramter.patch scripts-gdb-enable-completion-for-lx-list-check-parameter.patch scripts-gdb-fix-typo-in-exception-name.patch scripts-gdb-fix-pep8-compliance.patch scripts-gdb-add-ps-command.patch scripts-gdb-remove-useless-global-instruction.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html