In sys/dtrace.h
The header file containing the definitions of DTrace fault types.
A dtrace provider for begin, end, and error probes
dtrace:::BEGIN
dtrace:::END
dtrace:::ERROR
The dtrace provider implements three special probes related to the life cycle of the DTrace program itself.
The dtrace:::BEGIN probe fires at the beginning of a dtrace(1), program before tracing has begun. It provides a convenient place for initializing variables and printing column headers.
Variables such as stack or execname cannot be relied upon in the execution context of the dtrace:::BEGIN probe.
The dtrace:::END probe fires at the end of a dtrace(1) program, when all tracing has stopped.
The dtrace:::ERROR probe fires when an unexpected runtime error occurs in another probe.
The following table describes the arguments to dtrace:::ERROR.
| Argument | Definition |
| arg1 | Enabled probe identifier (EPID) |
| arg2 | Index of the action statement that caused the error |
| arg3 | DIF offset into the action if available (otherwise -1) |
| arg4 | Fault type |
| arg5 | Accessed address (or 0 if not applicable) when |
The fault types are:
Unknown fault
Bad address
Bad alignment
Illegal operation
Divide-by-zero
Out of scratch space
Illegal kernel access
Illegal user access
Tuple stack overflow
Bad stack
In sys/dtrace.h
The header file containing the definitions of DTrace fault types.
The following script uses the dtrace:::BEGIN probe to print column headers. Note the pragma line setting the ‘quiet’ option to disable the default column headers.
#pragma D option quiet
dtrace:::BEGIN
{
printf(" %12s %-20s %-20s %s\n",
"DELTA(us)", "OLD", "NEW", "TIMESTAMP");
}
The following script causes a runtime error by dereferencing a pointer on address 19930908 in the BEGIN probe. As a result, the ERROR probe fires and prints out “Oops” along with the probe arguments. At that point, the program ends and fires the END probe.
ERROR
{
printf("Oops\n");
printf("EPID (arg1): %d\n", arg1);
printf("Action index (arg2): %d\n", arg2);
printf("DIF offset (arg3): %d\n", arg3);
printf("Fault type (arg4): %d\n", arg4);
printf("Accessed address (arg5): %X\n", arg5);
exit(1);
}
BEGIN
{
*(int *)0x19931101;
}
END {
printf("Bye");
}
This script will result in the following output:
CPU ID FUNCTION:NAME 2 3 :ERROR Oops EPID (arg1): 2 Action index (arg2): 1 DIF offset (arg3): 16 Fault type: 1 arg5: 19931101 dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address (0x19931101) in action #1 at DIF offset 16 2 2 :END Bye
The dtrace:::ERROR probe arguments cannot be accessed through the typed args[] array.
dtrace(1) will not fire the dtrace:::ERROR probe recursively. If an error occurs in one of the action statements of the dtrace:::ERROR, then dtrace(1) will abort further processing of the dtrace:::ERROR probe's actions.
Unchanged in 3 releases since FreeBSD 15.0-RELEASE.