Providers
A provider is a facility that publishes the probes that you use in your D script. There are a number of built-in providers.
BEGIN and END providers
These are actually called dtrace:::BEGIN and dtrace:::END, but they are usually used as just BEGIN and END. The BEGIN probe fires when the D script begins execution, and the END probe fires when the script finishes. Example 9.2 shows using the BEGIN and END probes.
Example 9.2. begin-end.d
BEGIN { trace("begin the beguine"); exit(0); } END { trace ("that's all, folks..."); }
Run it:
$ sudo dtrace -s begin-end.d
dtrace: script 'begin-end.d' ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.