ERROR
Probe
The ERROR
probe fires when a run-time error occurs in executing a clause for a DTrace probe. For example, if a clause attempts to dereference a NULL
pointer, the ERROR
probe will fire, as shown in the following example.
Example 11-7 Showing How to Record Errors
BEGIN { *(char *)NULL; } ERROR { printf("Hit an error!"); }
When you run this program, you will see the following output:
# .dtrace -s ./error.d
dtrace: script './error.d' matched 2 probes
CPU ID FUNCTION:NAME
2 3 :ERROR Hit an error!
dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address
(0x0) in action #1 at DIF offset 12
dtrace: 1 error on CPU 2
The output shows that the ERROR
probe fired, and also illustrates dtrace
reporting the error. dtrace
has its own enabling of the ERROR
probe to allow it to report errors. Use the ERROR
probe to customize error handling.
The arguments to the ERROR
probe are as follows:
-
arg1
– Enabled probe identifier (EPID) of the probe that caused the error -
arg2
– Index of the action that caused the fault -
arg3
– DIF offset into that action or-1
if not applicable -
arg4
– Fault type -
arg5
– Value particular to the fault type
The following table describes the arg4
fault types and the value and its meaning for the arg5
.
Table 11-2 ERROR Probe Fault Types and Values
arg4 Value | Description | arg5 Meaning |
---|---|---|
|
Unknown fault type |
None |
|
Access to unmapped or invalid address |
Address accessed |
|
Unaligned memory access |
Address accessed |
|
Illegal or invalid operation |
None |
|
Integer divide by zero |
None |
|
Insufficient scratch space to satisfy scratch allocation |
None |
|
Attempt to access a kernel address or property without sufficient privileges |
Address accessed or |
|
Attempt to access a user address or property without sufficient privileges |
Address accessed or |
|
DTrace internal parameter stack overflow |
None |
|
Invalid user process stack |
Address of invalid stack pointer |
If the error actions taken in the ERROR
probe cause an error, the error is dropped and the ERROR
probe is not recursively invoked.