Random Leftovers

The C preprocessor

DTrace can run your script through the C preprocessor before the code is compiled. You can use all of the standard preprocessor features to make macros with common code and include C header files to include type definitions of library types. The D compiler automatically loads the set of C type descriptions for the kernel.


DTrace has a number of tunable parameters you can change via pragmas. Some useful ones:

#pragma D option quiet

same as passing -q on the command-line

#pragma D option flowindent

dtrace prints the name of the function if an action is empty. If you turn on this pragma, DTrace will indent function call names based on call depth, giving you a call trace.

Example 9.14 is a script that traces ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.