Running DTrace on FreeBSD 7.1-RELEASE2009年02月15日 00時00分28秒

Before using dtrace(1) on FreeBSD, kernel has to be recompiled with appropriate options to enable dtrace.

options KDTRACE_HOOKS        # all architectures
options KDTRACE_FRAME        # amd64-only

Then, kernel MUST be compiled with WITH_CTF=1. It was said that this option cannot added to /etc/make.conf.


$ kldload dtraceall
This module (opensolaris) contains code covered by the
Common Development and Distribution License (CDDL)
see http://opensolaris.org/os/licensing/opensolaris_license/
$ dtrace -l | head -10
   ID   PROVIDER            MODULE                          FUNCTION NAME
    1     dtrace                                                     BEGIN
    2     dtrace                                                     END
    3     dtrace                                                     ERROR
    4   dtmalloc                                                 fbt malloc
    5   dtmalloc                                                 fbt free
    6   dtmalloc                                              cyclic malloc
    7   dtmalloc                                              cyclic free
    8   dtmalloc                                             solaris malloc
    9   dtmalloc                                             solaris free

Run kldload dtracell and dtrace -l to verify that it is probing.

If you encounter the following error, it is likely that you forget to compile kernel with WITH_CTF=1.


$ dtrace -n 'syscall::open:entry'
dtrace: invalid probe specifier syscall::open:entry: "/usr/lib/dtrace/psinfo.d",
 line 37: syntax error near "uid_t"

Enjoy hacking!