From: Stefan Hajnoczi <stefanha@gmail.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, gdb@sourceware.org
Subject: Re: [Qemu-devel] [PATCH] scripts/qemugdb: support coroutine backtrace in coredumps
Date: Tue, 10 Apr 2018 02:08:00 -0000 [thread overview]
Message-ID: <20180410020823.GB11203@stefanha-x1.localdomain> (raw)
In-Reply-To: <008ac6e8-1e68-b0f6-7e75-77453721d031@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 2474 bytes --]
On Mon, Apr 09, 2018 at 04:01:24PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> 04.04.2018 13:34, Stefan Hajnoczi wrote:
> > Use the 'select-frame' GDB command to switch stacks instead of manually
> > setting the debugged thread's registers (this only works when debugging
> > a live process, not in a coredump).
> >
> > Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> > Vladimir: Does this work for you?
> >
> > scripts/qemugdb/coroutine.py | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
> > index ab699794ab..ed96434aee 100644
> > --- a/scripts/qemugdb/coroutine.py
> > +++ b/scripts/qemugdb/coroutine.py
> > @@ -77,13 +77,11 @@ def bt_jmpbuf(jmpbuf):
> > for i in regs:
> > old[i] = gdb.parse_and_eval('(uint64_t)$%s' % i)
> > - for i in regs:
> > - gdb.execute('set $%s = %s' % (i, regs[i]))
> > + gdb.execute('select-frame %s %s' % (regs['rsp'], regs['rip']))
> > gdb.execute('bt')
> > - for i in regs:
> > - gdb.execute('set $%s = %s' % (i, old[i]))
> > + gdb.execute('select-frame %s %s' % (old['rsp'], old['rip']))
> > def coroutine_to_jmpbuf(co):
> > coroutine_pointer = co.cast(gdb.lookup_type('CoroutineUContext').pointer())
>
> strange, but it doesn't work. it prints the same backtrace, as if I just
> call bt.
> (I applied it onto "[PATCH 2/4] scripts/qemugdb: improve "qemu coroutine"
> command")
>
> also, I can just call select-frame with zeros or any garbage in gdb, with
> same effect:
> (gdb) select-frame 0 0
> (gdb) bt
>
> and get same backtrace.
>
> so, bt command not related to selected frame. also, up and down commands
> don't help too, they go to frames in current bt, instead of moving
> relatively to selected frame.
I wonder what the point of select-frame is then...
I have CCed the GDB mailing list. Maybe someone can help us. Context:
QEMU implements coroutines using jmpbuf. We'd like to print coroutine
call stacks in GDB and have a script that works when a process is being
debugged (it sets the registers).
Now we'd like to extend the script to work on core dumps where it's not
possible to set registers (since there is no process being debugged).
Is there a way to backtrace an arbitrary call stack in a core dump?
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next parent reply other threads:[~2018-04-10 2:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180404103440.19546-1-stefanha@redhat.com>
[not found] ` <008ac6e8-1e68-b0f6-7e75-77453721d031@virtuozzo.com>
2018-04-10 2:08 ` Stefan Hajnoczi [this message]
2018-04-23 9:33 ` Simon Marchi
2018-04-23 9:48 ` Stefan Hajnoczi
2018-04-23 13:28 ` Vladimir Sementsov-Ogievskiy
2018-04-23 13:45 ` Pedro Alves
2018-12-27 17:36 ` Vladimir Sementsov-Ogievskiy
2019-01-02 14:01 ` Stefan Hajnoczi
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=20180410020823.GB11203@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=gdb@sourceware.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox