# Any tool for examine ruby's thread?

**URL:** <https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224>\
**Category:** Ruby\
**Created:** [August 5, 2009, 8:49am UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224 "2009-08-05T08:49:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 5, 2009, 8:49am UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/1 "2009-08-05T08:49:01Z")

</div>

Hello all,I’m doing a multithreaded ruby application,  
I want to examine the thread because the application’s logic is quite  
complex,  
so it helps if I can see each thread clearly,  
but the problem is, if I use IDE with ruby-debug-ide, when pause at  
breakpoint,  
it always seems to just have two threads(there’s not a thread view?),  
not like previously when I develop java application, when you pause,  
you can see there’s how many threads very easily.  
Is there anytool for examining ruby’s thread?

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 5, 2009, 2:56pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/2 "2009-08-05T14:56:00Z")

</div>

2009/8/5 femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hello all,I’m doing a multithreaded ruby application,  
> I want to examine the thread because the application’s logic is quite complex,  
> so it helps if I can see each thread clearly,  
> but the problem is, if I use IDE with ruby-debug-ide, when pause at breakpoint,  
> it always seems to just have two threads(there’s not a thread view?),  
> not like previously when I develop java application, when you pause,  
> you can see there’s how many threads very easily.  
> Is there anytool for examining ruby’s thread?

What kind of examination do you want to do? Do you want to see how  
many threads there are? Do you want to know what each thread does  
(e.g. current stack trace)?

Cheers

robert

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 5, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/3 "2009-08-05T17:10:04Z")

</div>

Yes, at least I need how many threads there are,  
and if stacktrace of each thread would be better.

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 11:39am UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/4 "2009-08-06T11:39:14Z")

</div>

On Thu, Aug 6, 2009 at 4:17 PM, Robert  
Klemme[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Please do not top post.
> 
> 2009/8/5 femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Yes, at least I need how many threads there are,  
> > and if stacktrace of each thread would be better.
> 
> Did you look at the documentation?  
> Yes,I’ve found the Thread.list fulfills my needs,Thanks.  
> do you have any means for examning every thread’s stacktrace?  
> by the way, reply at the top is very easy because I’m using gmail,  
> so I can collapse other’s reply very easily,  
> 🙂

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 3:39pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/5 "2009-08-06T15:39:53Z")

</div>

2009/8/6 femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> by the way, reply at the top is very easy because I’m using gmail,  
> so I can collapse other’s reply very easily,  
> 🙂

You can do so as well when not top posting. Please also consider that  
others may be reading the same content via different media / tools  
which might not provide this capability.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 10:18am UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/6 "2009-08-06T10:18:27Z")

</div>

Please do not top post.

2009/8/5 femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Yes, at least I need how many threads there are,  
> and if stacktrace of each thread would be better.

Did you look at the documentation?

[http://www.ruby-doc.org/core-1.9/classes/Thread.html](http://www.ruby-doc.org/core-1.9/classes/Thread.html)  
[http://www.ruby-doc.org/core-1.9/classes/ThreadGroup.html](http://www.ruby-doc.org/core-1.9/classes/ThreadGroup.html)

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/7 "2009-08-06T18:16:10Z")

</div>

On 8/6/09, femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes,I’ve found the Thread.list fulfills my needs,Thanks.  
> do you have any means for examning every thread’s stacktrace?

There does not seem to be a way to get the backtrace of another thread  
– even from within the debugger. This is a shame, because as you say  
it’s useful for debugging. There ought to be a Thread#caller or  
Thread#backtrace method, which works like #caller but on another  
thread.

I would have thought that you’d at least be able to use the ‘thread  
switch’ command in the debugger, and then ‘where’ once you’re in that  
thread to see its backtrace, but that doesn’t seem to work either.

> by the way, reply at the top is very easy because I’m using gmail,  
> so I can collapse other’s reply very easily,  
> 🙂

Don’t let me get started on the evils of bottom-quoting. Just let me  
note that it’s not the approved style on this list.

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/8 "2009-08-06T18:47:47Z")

</div>

2009/8/6 Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I would have thought that you’d at least be able to use the ‘thread  
> switch’ command in the debugger, and then ‘where’ once you’re in that  
> thread to see its backtrace, but that doesn’t seem to work either.

You can certainly cook up something with set\_trace\_func. This is  
however a bit slow.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![femto\_Zheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@femto\_Zheng](https://www.ruby-forum.com/u/femto_Zheng)\
**Post date:** [August 6, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/any-tool-for-examine-rubys-thread/173224/9 "2009-08-06T18:23:12Z")

</div>

Caleb C. wrote:

> On 8/6/09, femto Zheng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Yes,I’ve found the Thread.list fulfills my needs,Thanks.  
> > do you have any means for examning every thread’s stacktrace?
> 
> There does not seem to be a way to get the backtrace of another thread  
> – even from within the debugger. This is a shame, because as you say  
> it’s useful for debugging. There ought to be a Thread#caller or  
> Thread#backtrace method, which works like #caller but on another  
> thread.

IIRC this has been requested and discussed a few times, and it might be  
available in development versions of 1.9.2[1], but not 1.8.x, AFAIK.

[1] [http://redmine.ruby-lang.org/issues/show/977](http://redmine.ruby-lang.org/issues/show/977)

[2] google “ruby Thread#backtrace” for more discussion.
