gdb multiple stacks

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

gdb multiple stacks

Sourceware - gdb list mailing list
Hi,
I am trying to extend gdb using the Python API for a C++ program that
uses Boost.Context from the boost C++ libraries.

This program has multiple stacks for a single thread and I want to walk
these different stacks. I can easily list the stacks using the Python
API in gdb and can display the address of the start of the stack, the
limit of the stack, the current stack-pointer, frame-pointer and program
counter of all the stacks.

Is there some gdb command or gdb API that I can use to change the
current stack, similarly to the thread command?


The programming language Go uses a similar system: goroutines. Looking
at its extension file(https://golang.org/src/runtime/runtime-gdb.py), I
can see it uses the following trick to print backtraces :

# In GDB, assignments to sp must be done from the
# top-most frame, so select frame 0 first.
gdb.execute('select-frame 0')
gdb.parse_and_eval('$sp = {0}'.format(str(sp)))
gdb.parse_and_eval('$pc = {0}'.format(str(pc)))

This trick does not work for core dumps, gdb requires a live process to
assign to registers.

Is there some other way to change the current stack, instead of directly
writing to the registers?

Thank you for your time,

Thierry