As shown in the examples in this guide thus far, a D program source file consists of one or more probe clauses that describe the instrumentation to be enabled by DTrace. Each probe clause uses the following general form:
probe descriptions
/predicate
/ {action statements
}
Note that the predicate and list of action statements may be
omitted. Any directives that are found outside of probe clauses
are referred to as declarations.
Declarations may only be used outside of probe clauses. No
declarations are permitted inside of the enclosing braces
({}
). Also, declarations may not be
interspersed between the elements of the probe clause in
previous example. You can use white space to separate any D
program elements and to indent action statements.
Declarations can be used to declare D variables and external C
symbols or to define new types for use in D. For more details,
see Section 2.9, “Variables” and
Section 2.13, “Type and Constant Definitions”. Special D
compiler directives, called pragmas, may
also appear anywhere in a D program, including outside of probe
clauses. D pragmas are specified on lines beginning with a
#
character. For example, D pragmas are used
to set DTrace runtime options. See
Chapter 10, Options and Tunables for more details.