2 # GDB debugging support: aio/iohandler debug
4 # Copyright (c) 2015 Red Hat, Inc.
6 # Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2 or
9 # later. See the COPYING file in the top-level directory.
13 from qemugdb
import coroutine
16 return ptr
== gdb
.Value(0).cast(ptr
.type)
18 def dump_aiocontext(context
, verbose
):
19 '''Display a dump and backtrace for an aiocontext'''
20 cur
= context
['aio_handlers']['lh_first']
21 # Get pointers to functions we're going to process specially
22 sym_fd_coroutine_enter
= gdb
.parse_and_eval('fd_coroutine_enter')
24 while not isnull(cur
):
25 entry
= cur
.dereference()
26 gdb
.write('----\n%s\n' % entry
)
27 if verbose
and cur
['io_read'] == sym_fd_coroutine_enter
:
28 coptr
= (cur
['opaque'].cast(gdb
.lookup_type('FDYieldUntilData').pointer()))['co']
29 coptr
= coptr
.cast(gdb
.lookup_type('CoroutineUContext').pointer())
30 coroutine
.bt_jmpbuf(coptr
['env']['__jmpbuf'])
31 cur
= cur
['node']['le_next'];
35 class HandlersCommand(gdb
.Command
):
36 '''Display aio handlers'''
38 gdb
.Command
.__init
__(self
, 'qemu handlers', gdb
.COMMAND_DATA
,
41 def invoke(self
, arg
, from_tty
):
43 argv
= gdb
.string_to_argv(arg
)
45 if len(argv
) > 0 and argv
[0] == '--verbose':
50 gdb
.write('usage: qemu handlers [--verbose] [handler]\n')
54 handlers_name
= argv
[0]
56 handlers_name
= 'qemu_aio_context'
57 dump_aiocontext(gdb
.parse_and_eval(handlers_name
), verbose
)