2 # gdb helper commands and functions for Linux kernel debugging
6 # Copyright (c) Thiebaud Weksteen, 2015
9 # Thiebaud Weksteen <thiebaud@weksteen.fr>
11 # This work is licensed under the terms of the GNU GPL version 2.
16 from linux
import utils
18 list_head
= utils
.CachedType("struct list_head")
23 if (head
.type == list_head
.get_type().pointer()):
24 head
= head
.dereference()
25 elif (head
.type != list_head
.get_type()):
26 raise gdb
.GdbError('argument must be of type (struct list_head [*])')
29 gdb
.write("Starting with: {}\n".format(c
))
30 except gdb
.MemoryError:
31 gdb
.write('head is not accessible\n')
34 p
= c
['prev'].dereference()
35 n
= c
['next'].dereference()
37 if p
['next'] != c
.address
:
38 gdb
.write('prev.next != current: '
39 'current@{current_addr}={current} '
40 'prev@{p_addr}={p}\n'.format(
41 current_addr
=c
.address
,
47 except gdb
.MemoryError:
48 gdb
.write('prev is not accessible: '
49 'current@{current_addr}={current}\n'.format(
50 current_addr
=c
.address
,
55 if n
['prev'] != c
.address
:
56 gdb
.write('next.prev != current: '
57 'current@{current_addr}={current} '
58 'next@{n_addr}={n}\n'.format(
59 current_addr
=c
.address
,
65 except gdb
.MemoryError:
66 gdb
.write('next is not accessible: '
67 'current@{current_addr}={current}\n'.format(
68 current_addr
=c
.address
,
75 gdb
.write("list is consistent: {} node(s)\n".format(nb
))
79 class LxListChk(gdb
.Command
):
80 """Verify a list consistency"""
83 super(LxListChk
, self
).__init
__("lx-list-check", gdb
.COMMAND_DATA
,
84 gdb
.COMPLETE_EXPRESSION
)
86 def invoke(self
, arg
, from_tty
):
87 argv
= gdb
.string_to_argv(arg
)
89 raise gdb
.GdbError("lx-list-check takes one argument")
90 list_check(gdb
.parse_and_eval(argv
[0]))
This page took 0.032012 seconds and 5 git commands to generate.