From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpYiM-0001ZZ-4i for qemu-devel@nongnu.org; Fri, 23 Oct 2015 05:32:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpYiF-0004vo-Ts for qemu-devel@nongnu.org; Fri, 23 Oct 2015 05:32:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpYiF-0004vS-JX for qemu-devel@nongnu.org; Fri, 23 Oct 2015 05:32:39 -0400 Date: Fri, 23 Oct 2015 17:32:35 +0800 From: Fam Zheng Message-ID: <20151023093235.GA23646@ad.usersys.redhat.com> References: <1445339117-16278-1-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445339117-16278-1-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH] gdb command: qemu aios, qemu aiohandlers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com On Tue, 10/20 12:05, Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" > > 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 > > (gdb) qemu aios > ---- > {pfd = {fd = 12, events = 25, revents = 0}, io_read = 0x5634d4033cc0 > , io_write = 0x0, deleted = 0, opaque = > 0x5634d601e8b8, node = {le_next = 0x5634d5fd2330, le_prev = > 0x5634d5fd22a0}} > ---- > {pfd = {fd = 6, events = 25, revents = 0}, io_read = 0x5634d3ff1750 > , 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 > , 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=, 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=, > i1=) > 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 > , io_write = 0x0, deleted = 0, opaque = 0x4, node = > {le_next = 0x559a84e9c740, le_prev = 0x559a86325498}} > ---- > {pfd = {fd = 5, events = 25, revents = 0}, io_read = 0x559a843ac750 > , 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 > +# > +# 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 >