vfio-ccw: add force unlimited prefetch property
[qemu/ar7.git] / scripts / qemugdb / aio.py
blob2ba00c4444254da28bae6bbc4685be0f29e49d15
1 #!/usr/bin/python
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.
13 import gdb
14 from qemugdb import coroutine
16 def isnull(ptr):
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'];
34 gdb.write('----\n')
36 class HandlersCommand(gdb.Command):
37 '''Display aio handlers'''
38 def __init__(self):
39 gdb.Command.__init__(self, 'qemu handlers', gdb.COMMAND_DATA,
40 gdb.COMPLETE_NONE)
42 def invoke(self, arg, from_tty):
43 verbose = False
44 argv = gdb.string_to_argv(arg)
46 if len(argv) > 0 and argv[0] == '--verbose':
47 verbose = True
48 argv.pop(0)
50 if len(argv) > 1:
51 gdb.write('usage: qemu handlers [--verbose] [handler]\n')
52 return
54 if len(argv) == 1:
55 handlers_name = argv[0]
56 else:
57 handlers_name = 'qemu_aio_context'
58 dump_aiocontext(gdb.parse_and_eval(handlers_name), verbose)