I have a ruby program that spawns two threads. Rarely, it appears to be hanging on the main thread, and I'm trying to use gdb to figure out why.
Using the blog post here, I have used gdb to attach to to the process, and call rb_backtrace()
to get the backtrace.
Problem is, the backtrace is always from one of the spawned worker threads, not the main thread where I experience the hang.
Is there a way to get a backtrace from a particular thread?
I have tried using the gdb commands info threads
and thread 2
to change the active thread, but it has no effect. I have also tried using a ruby_eval
definition in gdb as described here, but any time I try to evaluate a line of ruby code, I get the error No symbol table is loaded. Use the "file" command.
Because I am working on an embedded system, I can't easily recompile ruby with gdb symbols.