diff options
| author | Siluxsept <ronny.horn.rh@gmail.com> | 2025-08-09 19:41:03 +0200 |
|---|---|---|
| committer | Siluxsept <ronny.horn.rh@gmail.com> | 2025-08-09 19:41:03 +0200 |
| commit | c69ee9b7a5588044978ced5f143f55312f56c44f (patch) | |
| tree | d1adf91be92a2c86b7441c0adb58907d8e4a558c /scripts/gdb/linux/lists.py | |
| parent | 8e8137ac800bdc27181743ec73d0e90e28b4e8af (diff) | |
cleanup for new import
Change-Id: I97ce2459d8c4b401f67efa15581a5dfd1875bc76
Diffstat (limited to 'scripts/gdb/linux/lists.py')
| -rw-r--r-- | scripts/gdb/linux/lists.py | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py deleted file mode 100644 index 2f335fbd86fd..000000000000 --- a/scripts/gdb/linux/lists.py +++ /dev/null @@ -1,113 +0,0 @@ -# -# gdb helper commands and functions for Linux kernel debugging -# -# list tools -# -# Copyright (c) Thiebaud Weksteen, 2015 -# -# Authors: -# Thiebaud Weksteen <thiebaud@weksteen.fr> -# -# 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_for_each(head): - if head.type == list_head.get_type().pointer(): - head = head.dereference() - elif head.type != list_head.get_type(): - raise gdb.GdbError("Must be struct list_head not {}" - .format(head.type)) - - node = head['next'].dereference() - while node.address != head.address: - yield node.address - node = node['next'].dereference() - - -def list_for_each_entry(head, gdbtype, member): - for node in list_for_each(head): - if node.type != list_head.get_type().pointer(): - raise TypeError("Type {} found. Expected struct list_head *." - .format(node.type)) - yield utils.container_of(node, gdbtype, member) - - -def list_check(head): - nb = 0 - if (head.type == list_head.get_type().pointer()): - head = head.dereference() - elif (head.type != list_head.get_type()): - raise gdb.GdbError('argument must be of type (struct list_head [*])') - c = 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, - gdb.COMPLETE_EXPRESSION) - - 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() |
