Dtrace on Leopard

Leopard got what's considered to be the best debugging tool in the world, dtrace, coming directly from the Open Solaris kernel. Dtrace lets you probe your kernel in an unprecedented and dynamic way (ie, without recompiling.)

Here you can find the dtrace solaris guide if you want to delve deep in its syntax and probes.

Almost everyone (myself included) blogged or wrote about the Ruby dtrace probes being in Leopard, so I immediately tried a bunch of scripts to give them a run. Interestingly, you can find dtrace ruby examples right in the /Developer directory.

<rant>That probably means a shift in Apple developer support from Java to Ruby, which sounds a bit strange if you really think about that: how cool and useful could be a java 6 JVM with a lot of dtrace probes? Yep, I like Ruby. I like it a lot for fast object oriented scripting, I like the dynamic part, I like the Smalltalkness and whatever. But, seriously, java is THE platform to support. Come on. We are all waiting for exciting java news from you, Apple. </rant>

Well, let's go back in topic now.

sudo dtrace -s /Developer/Examples/Ruby/DTrace/print_calls.d

says that

dtrace: failed to compile script /Developer/Examples/Ruby/DTrace/print_calls.d: line 4: probe description ruby*:::function-entry does not match any probes

and infact with a simple grep

sudo dtrace -l | grep -i object-free

you can see that it doesn't show one the expected ruby probes.

So, are the Ruby dtraces probe really there or the Gold Master lost something?

<update> Ok, just found this a few minutes after publishing :).

Being dynamic, you should attach it to a running ruby interpreter. Can't still explain why the dtrace -l doesn't show the ruby probes...

sudo dtrace -s /Developer/Examples/Ruby/DTrace/print_memory_usage.d -p <pid> PID number</pid>

</update>
Comments