Stack unwinding for green threads

Botond Dénes
Fri Jul 3 09:50:54 GMT 2020


I'm working on Scylla [1], an application which is built using the
seastar framework [2]. This framework provides green threads [3] that
have their own stacks. These threads are created with `setcontext()`
and later we switch in/out using `setjmp()`/`longjmp()`.

We have a collection of python scripts [4] to help debug Scylla, among
these we have a utility command which allows switching in/out of these
green threads in gdb. This command basically (tries) to emulate
`setjmp()`/`longjmp()` in python, saving and restoring registers. There
are several problems with this method. For starters it crashes gdb for
some time now, and also it doesn't work in coredumps, where gdb refuses
to write to registers (even after `set write on`). So for these reasons
I started to look for alternative ways to unwind the stacks of our
green threads. However after going through the gdb documentation [5],
reading all I could find about threads, stacks, frames and the Python
API I haven't found an entry point to call which would unwind a stack
located at a custom address (not the current $rsp). Is there such an
API that I haven't found? Is there another way to achive what I want?
Alternatively, how hard would it be to implement such an API?



More information about the Gdb mailing list