public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb multiple stacks
       [not found] <2t4kut8g15.fsf@plg2.cs.uwaterloo.ca>
@ 2020-03-12 21:11 ` Thierry Delisle
  0 siblings, 0 replies; only message in thread
From: Thierry Delisle @ 2020-03-12 21:11 UTC (permalink / raw)
  To: gdb

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-12 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2t4kut8g15.fsf@plg2.cs.uwaterloo.ca>
2020-03-12 21:11 ` gdb multiple stacks Thierry Delisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).