Getting a thread-dump

M

Matt Mower

Hi folks,

Is there a way I can get the Ruby interpreter to dump a stack trace
for all running threads? I have some code hang during I/O and I want
to see the callstack when it does.

On Windows the Java interpreter will do something like this when you
hit ctrl+break. I'm using the 1.8.2-final one-click installer on
Windows XP.

Thanks,

Matt
 
R

Robert Klemme

Matt Mower said:
Hi folks,

Is there a way I can get the Ruby interpreter to dump a stack trace
for all running threads? I have some code hang during I/O and I want
to see the callstack when it does.

On Windows the Java interpreter will do something like this when you
hit ctrl+break. I'm using the 1.8.2-final one-click installer on
Windows XP.

I don't know such a thing (you're probably thinking of JVM's Ctrl-C).
However, there are some options: One thing you could do is set
Thread.abort_on_exception = true - maybe your thread dies silently from an
uncaught exception. Or you wrap all threads in "begin ... rescue Exception
=> e; puts e.backtrace end" if you have access to the code.

Third option would be to trace execution via set_trace_func and record calls
and returns in a file (or to console if that doesn't clutter too much). But
this is likely to be slow unless you can narrow it down to a certain class
or instance.

Kind regards

robert
 
L

Lothar Scholz

Hello Matt,

MM> Hi folks,

MM> Is there a way I can get the Ruby interpreter to dump a stack trace
MM> for all running threads? I have some code hang during I/O and I want
MM> to see the callstack when it does.

You can do this with Arachno Ruby.

Use the "Stop all threads" command from the debug menu and then use the debugger
state window to view all stack frames.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top