O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

B​E​G​I​N​
{​
 ​ ​ ​ ​t​r​a​c​e​(​"​b​e​g​i​n​ ​t​h​e​ ​b​e​g​u​i​n​e​"​)​;​
 ​ ​ ​ ​e​x​i​t​(​0​)​;​
}​

E​N​D​
{​
 ​ ​ ​ ​t​r​a​c​e​ ​(​"​t​h​a​t​'​s​ ​a​l​l​,​ ​f​o​l​k​s​.​.​.​"​)​;​
}​

Run it:

$​ ​s​u​d​o​ ​d​t​r​a​c​e​ ​-​s​ ​b​e​g​i​n​-​e​n​d​.​d​ d​t​r​a​c​e​:​ ​s​c​r​i​p​t​ ​'​b​e​g​i​n​-​e​n​d​.​d​'​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required