Specifying Classes in Dtrace commands

On page 242 there is a reference to tracing and instance with multiple arguments:


When I run the following script:

#pragma D option quiet

        start[probemod] = timestamp;

        printf("%30s %10s Execution time: %u us\n", probemod, probefunc, (timestamp - start[probemod]) / 1000);

I get an error message:
dtrace: failed to compile script gorillatrace.d: line 4: invalid probe description “objc$1:Carthage_EAGLView:-renderWithSquareVertices?textureVertices?:entry”: Undefined macro variable in probe description

However, if I replace the name of the class (Carthage_EAGLView) with ‘target’ -->

        start[probemod] = timestamp;

        printf("%30s %10s Execution time: %u us\n", probemod, probefunc, (timestamp - start[probemod]) / 1000);

The program executes fine and replaces target with the class name :

Carthage_EAGLView -renderWithSquareVertices:textureVertices: Execution time: 18455 us
Carthage_EAGLView -renderWithSquareVertices:textureVertices: Execution time: 20417 us
Carthage_EAGLView -renderWithSquareVertices:textureVertices: Execution time: 34697 us

How come I can not use the class name in the dtrace command as you have done? Am I misinterpreting the concept of class name as it pertains to Dtrace?

DTrace can be a bit twitchy with the objc provider - if you supply a class name (without wildcards), and the method is in a category, the probe descriptions won’t match.

Get a listing of all the available objc probes with:

% sudo dtrace -l -c /Path/To/Your.app/Contents/MacOS/Your > probes.txt

And then search in your Favorite Text Editor for renderWithSquareVertices and see what it would be wanting.

Thanks for the reply Mark.

]The app runs fine in the iOS Simulator.

This command:

sudo dtrace -l -c /Users/toddbarker2002/Library/Developer/Xcode/DerivedData/Athens-bizdhmbleqcmmndbevbzdnftynfw/Build/Products/Release-iphonesimulator/Athens.app/Athens > probes.txt

results in this error:
dyld: Library not loaded: /System/Library/Frameworks/OpenGLES.framework/OpenGLES
Referenced from: /Users/toddbarker2002/Library/Developer/Xcode/DerivedData/Athens-bizdhmbleqcmmndbevbzdnftynfw/Build/Products/Release-iphonesimulator/Athens.app/Athens
Reason: image not found
dtrace: failed to control pid 11561: process exited with status 0

Does dtrace need a path to my frameworks even if the app runs ok in the simulator? If so where would I insert in the dtrace command?


Ah, didn’t know it was for the simulator. Since it’s not really a runnable program dtrace can’t load it directly (at least that’s my theory). So you’ll need to catch it when running. Assuming the app named ‘Blah’, and running in the simulator

% ps auxww | grep Blah markd 2031 0.0 0.0 2425480 180 p4 R+ 7:08PM 0:00.00 grep Blah markd 2022 0.0 0.3 872444 23248 ?? SX 7:07PM 0:00.32 /Users/markd/Lib...B2C0/Blah.app/Blah % sudo dtrace -l -n 'objc2022:::entry' > probes.txt

Where 2022 is the process ID of the app.


This command works really well!:

I modified and verified that I was using the correct class and method.

7811 objc12096 Carthage_EAGLView -renderWithSquareVertices:textureVertices: entry

My dtrace script was extremely buggy :open_mouth:

The correct format is:

I can really see the power in dtrace … With all the data available (especially the statistics) you could write your
own custom performance tool and use in real time :bulb: