This section describes tracing that is not associated with any DTrace consumer. Anonymous tracing is used in situations when no DTrace consumer processes can run. Only the super user may create an anonymous enabling. Only one anonymous enabling can exist at any time.
To create an anonymous enabling, use the
A
option
with a dtrace command invocation that specifies the desired
probes, predicates, actions and options. The dtrace command
adds a series of driver properties that represent your request to the configuration
file for the
dtrace
(
7D
)
driver.
The configuration file is typically /kernel/drv/dtrace.conf
.
The dtrace
driver reads these properties when the driver
is loaded. The driver enables the specified probes with the specified actions
and creates an anonymous state to associate with the
new enabling. The dtrace
driver is normally loaded on
demand, along with any drivers that act as dtrace providers.
To allow tracing during boot, the dtrace
driver must
be loaded as early as possible. The dtrace command adds
the necessary forceload
statements to /etc/system
(see
system
(
4
)
for each required dtrace provider and for the dtrace
driver.
When the system boots, the dtrace
driver sends
a message indicating that the configuration file has been successfully processed.
An anonymous enabling can set any of the options that are available during
normal use of the dtrace command.
To remove an anonymous enabling, specify the
A
option
to the dtrace command without any probe descriptions.
When the machine has completely booted, you can claim an existing
anonymous state by specifying the
a
option with the dtrace command. By default, the
a
option claims the anonymous
state and processes the existing data, then continues to run. To consume the
anonymous state and exit, add the
e
option.
When the anonymous state has been consumed from the kernel, the anonymous state cannot be replaced. If you attempt to claim an anonymous tracing state that does not exist, the dtrace command generates a message that is similar to the following example:
dtrace: could not enable tracing: No anonymous tracing state
If drops or errors occur, the dtrace command generates the appropriate messages when the anonymous state is claimed. The messages for drops and errors are the same for both anonymous and non-anonymous state.
The following example shows an anonymous DTrace enabling for every probe in the iprb ( 7D ) module:
#dtrace -A -m iprb
dtrace: saved anonymous enabling in /kernel/drv/dtrace.conf dtrace: added forceload directives to /etc/system dtrace: run update_drv(1M) or reboot to enable changes #reboot
After rebooting, the dtrace
driver prints a message
on the console to indicate that the driver is enabling the specified probes:
... Copyright 1983-2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. NOTICE: enabling probe 0 (:iprb::) NOTICE: enabling probe 1 (dtrace:::ERROR) configuring IPv4 interfaces: iprb0. ...
After rebooting the machine, specifying the
a
option
with the dtrace command consumes the anonymous state:
# dtrace -a
CPU ID FUNCTION:NAME
0 22954 _init:entry
0 22955 _init:return
0 22800 iprbprobe:entry
0 22934 iprb_get_dev_type:entry
0 22935 iprb_get_dev_type:return
0 22801 iprbprobe:return
0 22802 iprbattach:entry
0 22874 iprb_getprop:entry
0 22875 iprb_getprop:return
0 22934 iprb_get_dev_type:entry
0 22935 iprb_get_dev_type:return
0 22870 iprb_self_test:entry
0 22871 iprb_self_test:return
0 22958 iprb_hard_reset:entry
0 22959 iprb_hard_reset:return
0 22862 iprb_get_eeprom_size:entry
0 22826 iprb_shiftout:entry
0 22828 iprb_raiseclock:entry
0 22829 iprb_raiseclock:return
...
The following example focuses only on functions that are called from iprbattach
.
fbt::iprbattach:entry { self->trace = 1; } fbt::: /self->trace/ {} fbt::iprbattach:return { self->trace = 0; }
Run the following commands to clear the previous settings from the driver configuration file, install the new anonymous tracing request, and reboot:
#dtrace -AFs iprb.d
dtrace: cleaned up old anonymous enabling in /kernel/drv/dtrace.conf dtrace: cleaned up forceload directives in /etc/system dtrace: saved anonymous enabling in /kernel/drv/dtrace.conf dtrace: added forceload directives to /etc/system dtrace: run update_drv(1M) or reboot to enable changes #reboot
After rebooting, the dtrace driver prints a different message on the console to indicate the slightly different enabling:
... Copyright 1983-2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. NOTICE: enabling probe 0 (fbt::iprbattach:entry) NOTICE: enabling probe 1 (fbt:::) NOTICE: enabling probe 2 (fbt::iprbattach:return) NOTICE: enabling probe 3 (dtrace:::ERROR) configuring IPv4 interfaces: iprb0. ...
After the machine has finished booting, run the dtrace command
with the
a
and the
e
options to consume
the anonymous data and then exit.
# dtrace -ae
CPU FUNCTION
0 -> iprbattach
0 -> gld_mac_alloc
0 -> kmem_zalloc
0 -> kmem_cache_alloc
0 -> kmem_cache_alloc_debug
0 -> verify_and_copy_pattern
0 <- verify_and_copy_pattern
0 -> tsc_gethrtime
0 <- tsc_gethrtime
0 -> getpcstack
0 <- getpcstack
0 -> kmem_log_enter
0 <- kmem_log_enter
0 <- kmem_cache_alloc_debug
0 <- kmem_cache_alloc
0 <- kmem_zalloc
0 <- gld_mac_alloc
0 -> kmem_zalloc
0 -> kmem_alloc
0 -> vmem_alloc
0 -> highbit
0 <- highbit
0 -> lowbit
0 <- lowbit
0 -> vmem_xalloc
0 -> highbit
0 <- highbit
0 -> lowbit
0 <- lowbit
0 -> segkmem_alloc
0 -> segkmem_xalloc
0 -> vmem_alloc
0 -> highbit
0 <- highbit
0 -> lowbit
0 <- lowbit
0 -> vmem_seg_alloc
0 -> highbit
0 <- highbit
0 -> highbit
0 <- highbit
0 -> vmem_seg_create
...