How to backtrace an separate stack?
Pedro Alves
pedro@palves.net
Mon Mar 7 10:49:47 GMT 2022
On 2022-03-03 11:22, Stefan Hajnoczi wrote:
> Hi,
> The QEMU emulator uses coroutines with separate stacks. It can be
> challenging to debug coroutines that have yielded because GDB is not
> aware of them (no thread is currently executing them).
>
> QEMU has a GDB Python script that helps. It "creates" a stack frame for
> a given coroutine by temporarily setting register values and then using
> the "bt" command. This works on a live process under ptrace control but
> not for coredumps where registers can't be set.
>
> Here is the script (or see the bottom of this email for an inline copy
> of the relevant code):
> https://gitlab.com/qemu-project/qemu/-/blob/master/scripts/qemugdb/coroutine.py
>
> I hoped that "select-frame address ADDRESS" could be used instead so
> this would work on coredumps too. Unfortunately "select-frame" only
> searches stack frames that GDB is already aware of, so it cannot be used
> to backtrace coroutine stacks.
>
> Is there a way to backtrace a stack at an arbitrary address in GDB?
I don't think there's an easy/great answer. Maybe it could
be done with a Python unwinder [1]? See gdb.python/py-unwind-user-regs.py
in the GDB testsuite for an example you could probably start with.
As for something built-in to GDB, this reminded me of a discussion a while ago
around a "frame create" command. Here were my thoughts back then, I think
still valid:
https://sourceware.org/legacy-ml/gdb-patches/2015-09/msg00658.html
[1] https://sourceware.org/gdb/onlinedocs/gdb/Unwinding-Frames-in-Python.html
More information about the Gdb
mailing list