In the simplest case, TNF_PROBE_0, you give no argument types:
TNF_PROBE_0 (name, keys, detail);
The variables are:
name -- The name of the probe, following all the syntax guidelines for identifiers in ANSI C. The use of name declares it, so no separate declaration is necessary. This is a block scope declaration, so it does not affect the name space of the program.
keys -- A list of groups to which the probe belongs. The list is a string containing space-separated keywords and cannot contain a semicolon, an equal sign, or a single quotation mark.( ;= ` ). When any of the groups are enabled, the probe point is enabled. keys cannot be a variable--it must be an in-line string.
detail -- Provides a way for you to define your own attributes and values. The detail string is made up of attribute-value pairs separated from each other by semicolons, although the value is optional. The first word (up to a space) is considered to be the attribute and the rest of the string (up to the semicolon) is considered to be the value. Spaces around the semicolon delimiter are allowed. Single quotation marks and the equal sign are not allowed in the detail statement.
Prefix the attribute name with a vendor stock symbol followed by the % character to avoid name collisions. In the following example, four attributes are defined: sunw%debug, comX%exception, comY%func_entry, and comY%color. Since prex tokenizes the value on spaces, multiword values can be matched on any of the words, but not on the entire string. For example:
sunw%debug entering function A; comX%exception no file; comY%func_entry; comY%color red blue
Table 1-8 gives the values that are matched on for the command shown above:
Table 1-8 Examples of User-Defined Attributes
Attribute |
Value |
Values prex matches on |
---|---|---|
sunw%debug |
entering function A |
entering or function or A |
comX%exception |
no file |
no or file |
comY%func_entry |
|
/.*/ (regular expression) |
comY%color |
red blue |
red or blue |
libtnfprobe reserves all attribute names that are not prefixed by a vendor symbol (it reserves all attributes that do not have the % character in them). The code for cookie.c in "A Sample C Program" contains the following use of TNF_PROBE_0:
TNF_PROBE_0(start, "cookie main", "sunw%debug starting main");
Compiling with the preprocessor option -DNPROBE (see cc(1)), or with the preprocessor control statement #define NPROBE ahead of the #include <tnf/probe.h> statement, stops probe points as well as TNF type extension code from being compiled into the program.