Quick-start guide
FreeBSD 9-CURRENT (or later)
- Compile KDTRACE_HOOKS and DDB_CTF into your kernel. On AMD64 you'll also need KDTRACE_FRAME and enable gdb(1) debug symbols.
options KDTRACE_HOOKS # all architectures - enable general DTrace hooks
options DDB_CTF # all architectures - kernel ELF linker loads CTF data
options KDTRACE_FRAME # amd64 - ensure frames are compiled in
makeoptions DEBUG="-g" # amd64? - build kernel with gdb(1) debug symbols
makeoptions WITH_CTF=1
Note: WITH_CTF=1 has to be defined in the kernel config file. It will not be picked up from make.conf or src.conf for the kernel build. - Recompile and install your kernel; then reboot:
make buildkernel KERNCONF=DTRACE
make installkernel KERNCONF=DTRACE shutdown -r NOW
- Load some or all DTrace kernel modules:
kldload dtraceall
- Confirm that you have piles of available DTrace hooks:
dtrace -l | head
You'll need to su to root in order to use DTrace, which may be fixed once we add a more comprehensive fine-grained privilege policy. - For userland DTrace support add the following to your make.conf: (optional)
STRIP= CFLAGS+=-fno-omit-frame-pointer
This allows stack traces to work and display even more information. - Rebuild and install world with 'WITH_CTF=1' in either make.conf (if you also want to have it for ports) or src.conf: (optional)
make buildworld shutdown -r NOW boot -s
make installworld reboot
FreeBSD 8-STABLE (or earlier)
- Compile KDTRACE_HOOKS and DDB_CTF into your kernel. On AMD64 you'll also need KDTRACE_FRAME and enable gdb(1) debug symbols.
options KDTRACE_HOOKS # all architectures - enable general DTrace hooks
options DDB_CTF # all architectures - kernel ELF linker loads CTF data
options KDTRACE_FRAME # amd64 - ensure frames are compiled in
makeoptions DEBUG="-g" # amd64? - build kernel with gdb(1) debug symbols
Note: WITH_CTF=1 has to be specified on the command line. It will not be picked up from either make.conf, src.conf or inside the kernel config file for the kernel build. - Recompile and install your kernel; then reboot:
make buildkernel WITH_CTF=1 KERNCONF=DTRACE
make installkernel KERNCONF=DTRACE shutdown -r NOW
- Load some or all DTrace kernel modules:
kldload dtraceall
- Confirm that you have piles of available DTrace hooks:
dtrace -l | head
You'll need to su to root in order to use DTrace, which may be fixed once we add a more comprehensive fine-grained privilege policy. - For userland DTrace support add the following to your make.conf: (optional)
STRIP= CFLAGS+=-fno-omit-frame-pointer
This allows stack traces to work and display even more information. - Rebuild and install world: (optional)
make WITH_CTF=1 buildworld shutdown -r NOW boot -s
make installworld
Using DTrace
Before making use of DTrace functionality, the DTrace device must exist. To load the device, issue the following command:# kldload dtraceall
DTrace support should now be available. To view all probes the administrator may now execute the following command:# dtrace -l | more
Probes
• Data is generated from instrumentation points called “probes”. • DTrace provides thousands of probes.
• Probe examples: Probe Name Description syscall::read:entry A read() syscall began proc:::exec-success A process created successfully io:::start An I/O was issued (disk/vol/NFS) io:::done An I/O completed
Probe Names • Probe names are a four-tuple,
Provider:Module:Function:Name
syscall::exece:return
> Provider : A library of related probes. > Module :The module the function belongs to,either a kernel module or user segment. > Function : The function name that contains the probe. > Name : The name of the probe.
No comments:
Post a Comment