[MacRuby-devel] dtrace and macruby

Laurent Sansonetti lsansonetti at apple.com
Fri Dec 18 14:33:14 PST 2009


Hi Scott,

I'm not a DTrace expert but in my experience, dtrace takes a short  
time to attach to a given process, and if the process exists  
prematurely it won't work. I'm not aware of any way to work around  
that, except by patching the process to make it wait a bit more, as  
you did.

This might be a good question for the DTrace list (if there is one!).

Laurent

On Dec 17, 2009, at 12:21 PM, Scott Thompson wrote:

> I'm trying to learn a bit more about dtrace and I thought that using  
> it to add probes to macruby would be fun.
>
> I pulled up the sample dtrace scripts from the Macruby 0.5 b2 source  
> and was working with the script:
>
> class World
>   def say(message)
>     puts message
>   end
> end
>
> world = World.new
> world.say('hello')
>
> (taken from http://redartisan.com/2008/5/18/dtrace-ruby)
>
> I tried to run the trace as:
>
> $ sudo dtrace -s methods_count.d -c "macruby world.rb"
>
> (where methods_count.d is one of the sample dtrace scripts)
>
> This doesn't produce any meaningful results.
>
> After playing around for a bit, I have learned that if I add a bit  
> to the end of my ruby script:
>
> while(true)
> 	sleep 1
> end
>
> What I take from that is if the ruby script runs for a longer time,  
> dtrace has a chance plugging into the ruby application which it does  
> not have when the script exits quickly.
>
> Am I doing something the wrong way?  Is there a better way to ask  
> dtrace to attach to my ruby application and catch information?
>
> Scott
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list