how to get backtrace of a coroutine's state from a ucontext_t?

finger@spacecurve.com finger@spacecurve.com
Thu Apr 24 22:05:00 GMT 2014


Hi.  I've got an in-house coroutine library that is built using
{get,make,swap}context.  I would like to be able to get a backtrace of
one of these coroutines (one not currently running).

Any pointers on doing this?

Relevant versions:
x86_64
gdb 7.7
gcc 4.7.3
centos 6.5
glibc from centos6.5 (glibc-2.12-1.132.el6.x86_64)
kernel from centos6.5 (2.6.32-431.el6.x86_64)

I'm not able to even figure out how to get the "frame" command to work
by passing a frame address.  Without coroutines (to simplify), I can do
an "info frame" to get what gdb claims is the frame address.  That
frequently doesn't work, I'm guessing because we're building with
frame-pointer omit.

I am more than happy to try and script something using python.  But I don't
see any python api docs that are pointing me in the right direction.  I was
looking for something that would let me backtrace a frame at a time given
an $sp/$pc.  Or something along those lines.  Not sure if there's nothing
available for manually building frame info so that gdb can backtrace, or if
I'm just not finding it.

Thanks
Jay Finger



More information about the Gdb mailing list