From: Fam Zheng <famz@redhat.com>
To: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] gdb command: qemu aios, qemu aiohandlers
Date: Fri, 23 Oct 2015 17:32:35 +0800 [thread overview]
Message-ID: <20151023093235.GA23646@ad.usersys.redhat.com> (raw)
In-Reply-To: <1445339117-16278-1-git-send-email-dgilbert@redhat.com>
On Tue, 10/20 12:05, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Two new gdb commands are added:
>
> qemu iohandlers
>
> that dumps the list of waiting iohandlers, this is particularly
> useful for trying to figure out where an incoming migration is
> blocked. For 'fd_coroutine_enter' cases we dump a full backtrace.
>
> qemu aios
> that dumps the qemu_aio_context list.
I'd assume "qemu aios" is a command to print the list of AioContext instances
rather than handlers in a particular context (qemu_aio_context). How about
"qemu handlers"?
>
> This is a rewrite of an earlier version prior to Fam's changes
> to the corresponding structures.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> (gdb) qemu aios
> ----
> {pfd = {fd = 12, events = 25, revents = 0}, io_read = 0x5634d4033cc0
> <qemu_laio_completion_cb>, io_write = 0x0, deleted = 0, opaque =
> 0x5634d601e8b8, node = {le_next = 0x5634d5fd2330, le_prev =
> 0x5634d5fd22a0}}
> ----
> {pfd = {fd = 6, events = 25, revents = 0}, io_read = 0x5634d3ff1750
> <event_notifier_dummy_cb>, io_write = 0x0, deleted = 0, opaque =
> 0x5634d5fd22e8, node = {le_next = 0x0, le_prev = 0x5634d5fe8458}}
> ----
>
> (gdb) qemu iohandlers
> ----
> {pfd = {fd = 15, events = 25, revents = 0}, io_read = 0x559a843bd850
> <fd_coroutine_enter>, io_write = 0x0, deleted = 0, opaque =
> 0x7fef1c5fed30, node = {le_next = 0x559a84e9d180, le_prev =
> 0x559a84e9c6b0}}
> #0 0x0000559a843bdcf0 in qemu_coroutine_switch
> (from_=from_@entry=0x559a865fd8e0, to_=to_@entry=0x7fef37774ac8,
> action=action@entry=COROUTINE_YIELD) at
> /home/dgilbert/git/qemu-world3/coroutine-ucontext.c:177
> #1 0x0000559a843bd0d0 in qemu_coroutine_yield () at
> /home/dgilbert/git/qemu-world3/qemu-coroutine.c:145
> #2 0x0000559a843bd9c5 in yield_until_fd_readable (fd=15) at
> /home/dgilbert/git/qemu-world3/qemu-coroutine-io.c:90
> #3 0x0000559a84362337 in socket_get_buffer (opaque=0x559a862f7a00,
> buf=0x559a84ea0a70 "", pos=<optimized out>, size=32768) at
> /home/dgilbert/git/qemu-world3/migration/qemu-file-unix.c:69
> #4 0x0000559a84360c9c in qemu_fill_buffer (f=0x559a84ea0a40)
> at /home/dgilbert/git/qemu-world3/migration/qemu-file.c:215
> #5 0x0000559a84361569 in qemu_peek_byte (f=0x559a84ea0a40, offset=0)
> at /home/dgilbert/git/qemu-world3/migration/qemu-file.c:448
> #6 0x0000559a843617d4 in qemu_get_be32 (f=0x559a84ea0a40)
> at /home/dgilbert/git/qemu-world3/migration/qemu-file.c:461
> #7 0x0000559a843617d4 in qemu_get_be32 (f=f@entry=0x559a84ea0a40)
> at /home/dgilbert/git/qemu-world3/migration/qemu-file.c:545
> #8 0x0000559a84187d92 in qemu_loadvm_state (f=f@entry=0x559a84ea0a40)
> at /home/dgilbert/git/qemu-world3/migration/savevm.c:1070
> #9 0x0000559a8435dc42 in process_incoming_migration_co
> (opaque=0x559a84ea0a40)
> at /home/dgilbert/git/qemu-world3/migration/migration.c:285
> #10 0x0000559a843bdd5a in coroutine_trampoline (i0=<optimized out>,
> i1=<optimized out>)
> at /home/dgilbert/git/qemu-world3/coroutine-ucontext.c:80
> #11 0x00007fef2a462f10 in __start_context () at /lib64/libc.so.6
> #12 0x00007fffb7437b50 in ()
> #13 0x0000000000000000 in ()
This sort of clutters the output, I'm wondering if making the backtrace
optional (only dumped when "qemu iohandlers --backtrace") is better? It's OK
if you decide to keep this, though.
> ----
> {pfd = {fd = 4, events = 25, revents = 0}, io_read = 0x559a843b7800
> <sigfd_handler>, io_write = 0x0, deleted = 0, opaque = 0x4, node =
> {le_next = 0x559a84e9c740, le_prev = 0x559a86325498}}
> ----
> {pfd = {fd = 5, events = 25, revents = 0}, io_read = 0x559a843ac750
> <event_notifier_dummy_cb>, io_write = 0x0, deleted = 0, opaque =
> 0x559a84e9c6f8, node = {le_next = 0x0, le_prev = 0x559a84e9d1a8}}
> ----
> ---
> scripts/qemu-gdb.py | 4 +++-
> scripts/qemugdb/aio.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 55 insertions(+), 1 deletion(-)
> create mode 100644 scripts/qemugdb/aio.py
>
> diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py
> index d6f2e5a..99344c7 100644
> --- a/scripts/qemu-gdb.py
> +++ b/scripts/qemu-gdb.py
> @@ -26,7 +26,7 @@ import os, sys
>
> sys.path.append(os.path.dirname(__file__))
>
> -from qemugdb import mtree, coroutine
> +from qemugdb import aio, mtree, coroutine
>
> class QemuCommand(gdb.Command):
> '''Prefix for QEMU debug support commands'''
> @@ -37,6 +37,8 @@ class QemuCommand(gdb.Command):
> QemuCommand()
> coroutine.CoroutineCommand()
> mtree.MtreeCommand()
> +aio.IOhandlersCommand()
> +aio.AIOsCommand()
>
> # Default to silently passing through SIGUSR1, because QEMU sends it
> # to itself a lot.
> diff --git a/scripts/qemugdb/aio.py b/scripts/qemugdb/aio.py
> new file mode 100644
> index 0000000..cda2c37
> --- /dev/null
> +++ b/scripts/qemugdb/aio.py
> @@ -0,0 +1,52 @@
> +#!/usr/bin/python
> +
> +# GDB debugging support: aio/iohandler debug
> +#
> +# Copyright (c) 2015 Red Hat, Inc.
> +#
> +# Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2 or
> +# later. See the COPYING file in the top-level directory.
> +#
> +
> +import gdb
> +from qemugdb import coroutine
> +
> +def isnull(ptr):
> + return ptr == gdb.Value(0).cast(ptr.type)
> +
> +def dump_aiocontext(context):
> + '''Display a dump and backtrace for an aiocontext'''
> + cur = context['aio_handlers']['lh_first']
> + # Get pointers to functions we're going to process specially
> + sym_fd_coroutine_enter = gdb.parse_and_eval('fd_coroutine_enter')
> +
> + while not isnull(cur):
> + entry = cur.dereference()
> + gdb.write('----\n%s\n' % entry)
> + if cur['io_read'] == sym_fd_coroutine_enter:
> + coptr = (cur['opaque'].cast(gdb.lookup_type('FDYieldUntilData').pointer()))['co']
> + coptr = coptr.cast(gdb.lookup_type('CoroutineUContext').pointer())
> + coroutine.bt_jmpbuf(coptr['env']['__jmpbuf'])
> + cur = cur['node']['le_next'];
> +
> + gdb.write('----\n')
> +
> +class AIOsCommand(gdb.Command):
> + '''Display aio handlers'''
Maybe also
s/aio handlers/aio handlers in main loop/
?
> + def __init__(self):
> + gdb.Command.__init__(self, 'qemu aios', gdb.COMMAND_DATA,
> + gdb.COMPLETE_NONE)
> +
> + def invoke(self, arg, from_tty):
> + dump_aiocontext(gdb.parse_and_eval('qemu_aio_context'))
> +
> +class IOhandlersCommand(gdb.Command):
> + '''Display io handlers'''
> + def __init__(self):
> + gdb.Command.__init__(self, 'qemu iohandlers', gdb.COMMAND_DATA,
> + gdb.COMPLETE_NONE)
> +
> + def invoke(self, arg, from_tty):
> + dump_aiocontext(gdb.parse_and_eval('iohandler_ctx'))
> --
> 2.5.0
>
next prev parent reply other threads:[~2015-10-23 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 11:05 [Qemu-devel] [PATCH] gdb command: qemu aios, qemu aiohandlers Dr. David Alan Gilbert (git)
2015-10-23 9:32 ` Fam Zheng [this message]
2015-10-23 10:09 ` Stefan Hajnoczi
2015-10-26 1:27 ` Fam Zheng
2015-10-26 3:14 ` Paolo Bonzini
2015-10-27 13:13 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151023093235.GA23646@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=dgilbert@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.