Re: [Qemu-devel] [PATCH] scripts/qemugdb: support coroutine backtrace in coredumps

Stefan Hajnoczi <[email protected]>
Newsgroups gmane.comp.gdb.devel,gmane.comp.emulators.qemu
Message-ID <[email protected]>
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 <[email protected]>
> > Signed-off-by: Stefan Hajnoczi <[email protected]>
> > ---
> > 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
signature.asc (application/pgp-signature, 455 B)
-----BEGIN PGP SIGNATURE-----

iQEcBAEBAgAGBQJazByXAAoJEJykq7OBq3PI9TEH/jIozpJTO3kOtpzgYRSApTW6
p/k4xuQ051XgdOXGF+YXkl4LDOD4dbD33Dr8aAxnRJOy1SmNetnSozU8GXFNQDic
NKp+J2QjWpTNdEE0TYKGwhXxZyBwGz8AbeNvkS6blrEVZOPSIm7asR4OmhMAVWST
FPFaEftZFqUFv0kurEx3CQRSH+g+anJ/q+VQKD6pPXfqRAhOLoL0M+A3syU8V9Wx
xqOgkFt7gXVlpikxMjohgWAPMNWPzzu5LXssKzSz8yDYv/BnZ7BEaTuOf+QgiYSt
67kMiLNxMb4LT5i9niB95Ui7b63NORlcSk/Iu8Z5sSkf6FDRs48Wvjx9KLGB0ys=
=IOqm
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.