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