PDA

View Full Version : DTrace - Thanks for the breakage




Macabee
Oct 24, 2007, 11:09 AM
So Apple put DTrace into OSX Leopard. It's pretty cool. Have been playing with it for a large chunk of the day.

Of course - useless without enabling it some of the languages we all use (PHP, Python and Ruby).

So - I spent a while hacking it about with the source code....

Now I have things like:

class Something:
def foo(self):
print "In the class"

def foobar():
print "Nothing"

def helloworld():
print "Hello World!"
foobar()

helloworld()
a = Something()
a.foo()


#!/usr/sbin/dtrace -ZCs

#pragma D option quiet

python$target:::function-entry,python$target:::function-return
{
printf("%s %s (%s:%d)\n", probename == "function-entry" ? "->" : "<-",
copyinstr(arg1), copyinstr(arg0), arg2);
}


-> <module> (foo.py:1)
-> Something (foo.py:1)
<- Something (foo.py:2)
-> helloworld (foo.py:8)
-> foobar (foo.py:5)
<- foobar (foo.py:6)
<- helloworld (foo.py:10)
-> foo (foo.py:2)
<- foo (foo.py:3)
<- <module> (foo.py:14)

Would anybody be interested in the patches for the dtrace PEAR module for PHP and the MacPorts versions of Python and Ruby? Not sure if they'll accept the patches upstream - so I want to gauge whether people want that or not.



toddburch
Oct 24, 2007, 11:38 AM
Ruby - absolutely.

Macabee
Oct 24, 2007, 12:05 PM
Ruby - absolutely.

yeah the Ruby one by Joyenet appears to be broken on OSX. I have created a fix patch and the mini-site will go up shortly with all the details for patching/making dtrace work with these scripting languages.

Macabee
Oct 24, 2007, 02:19 PM
http://leenux.org.uk/dtrace-with-ruby-on-osx/

Have fun!

HiRez
Oct 24, 2007, 05:18 PM
This sounds interesting. Can you explain how DTrace is different from other profiling tools? Does it integrate with compilers/debuggers or is it separate? Would it also be used for Objective-C/C/Cocoa?

Macabee
Oct 25, 2007, 02:39 AM
This sounds interesting. Can you explain how DTrace is different from other profiling tools? Does it integrate with compilers/debuggers or is it separate? Would it also be used for Objective-C/C/Cocoa?

http://video.google.com/videoplay?docid=-8002801113289007228

The author/inventor can do it a lot better than I can.