views:

444

answers:

3
% sudo dtrace -p 2446 'objc$target:NSObject:-init:entry { trace(); }'
dtrace: no probes specified

The manpage suggests that this is the correct format with which to specify a probe on an Objective-C method. I tried -Z, but (unsurprisingly) that just didn't print anything.

[Added] It's not even specific to Objective-C probes. I tried it with a C function from AppKit:

sudo dtrace -p 2446 'pid$target::NSPopAutoreleasePool:entry { trace(); }'
dtrace: no probes specified

So what's wrong? Why does DTrace think I have not specified any probes?

A: 

Does the process in question allow dtrace? Apple doesn't always allow dtrace on os x.

Sean Reilly
As far as I know, yes. It's an open-source app I work on, not anything by Apple, and I'm not aware of zsh setting `P_LNOATTACH` on my own processes.
Peter Hosey
+2  A: 

I think you mean:

sudo dtrace -p 2446 -n 'objc$target:NSObject:-init:entry { trace(); }'
Graham Lee
A: 

In addition to what Graham said, your original statement will only find instances of NSObject, not its descendents. You could try

sudo dtrace -p 2446 -n 'objc$target::-init*:entry {}'

to catch all -init variants by all NSObject-derived instances.

Brad Larson
It wouldn't catch the `[super init]` message by a subclass?
Peter Hosey
I don't think so. It's my impression that the module is always set to be the instance's class, even when it's calling a method via super. I just tried the command line I suggested with NSObject instead of a blank module and got no matching probes, while leaving the module out hits ~3400 on the application I tried.
Brad Larson