DTrace on FreeBSD
This page contains a quick-start guide to DTrace and links to useful examples of how to use DTrace to instrument your kernel for performance or functional analysis.
Quick-start guide
- Compile KDTRACE_HOOKS, DDB_CTF, and for amd64 KDTRACE_FRAME, into your kernel:
options KDTRACE_HOOKS # all architectures - enable general DTrace hooks options DDB_CTF # all architectures - kernel ELF linker loads CTF data options KDTRACE_FRAME # amd64-only
- Recompile your kernel using WITH_CTF=1 on the command line; note: this will not work in make.conf or src.conf, it must be on the buildkernel or make command line. You will need to specify it every time you rebuild your kernel (for now):
make buildkernel KERNCONF=DTRACE WITH_CTF=1
- Install new kernel and reboot:
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.
Links
Useful examples of how to use DTrace to instrument your kernel for performance or functional analysis: /Examples
Howto add SDT probes to DTrace in the kernel: /HowToAddSDTProbes
FreeBSD Handbook section on DTrace: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/dtrace.html