qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to backtrace an separate stack?


From: Pedro Alves
Subject: Re: How to backtrace an separate stack?
Date: Mon, 7 Mar 2022 10:49:47 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]