--- wikisrc/tutorials/how_to_enable_and_run_dtrace.mdwn 2015/11/28 19:23:12 1.13 +++ wikisrc/tutorials/how_to_enable_and_run_dtrace.mdwn 2017/04/08 21:38:18 1.18 @@ -1,4 +1,5 @@ -DTrace is a Dynamic Tracing framework developed by Sun and ported to NetBSD. It enables extensive instrumentation of the kernel and user space. See the [DTrace Community Page](http://dtrace.org) for more information. Also see [DTrace Introduction](http://dtrace.org/guide/preface.html). +DTrace is a Dynamic Tracing framework developed by Sun and ported to NetBSD. It enables extensive instrumentation of the kernel and user space. See the [DTrace Community Page](http://dtrace.org) for more information. +Also see [DTrace Introduction](http://dtrace.org/guide/preface.html), Brendan Gregg's [DTrace one liners](http://www.brendangregg.com/DTrace/dtrace_oneliners.txt) and his notes for [DTrace on FreeBSD](https://wiki.freebsd.org/DTrace/). # Current status @@ -7,15 +8,16 @@ DTrace is a Dynamic Tracing framework de DTrace is a work-in-progress effort and it is for x86 systems and some arm boards. * i386 and amd64 -* evbarm - * BEAGLEBONE and SHEEVAPLUG +* earm* (evbarm and armv4 based ports) ## Supported providers * SDT: Statically Defined Tracing * FBT: Function Boundary Tracing - -You can currently run a hello world DScript. +* Lockstat: Kernel Lock Statistics +* Profile: Time based interrupt event source for Profiling +* Syscall: System Calls +* Syscall Linux (32bit & 64 bit): System calls via the Linux binary emulation layer ## TODO for netbsd-7 @@ -36,29 +38,29 @@ Candidates: You need the following options in your kernel: - options INSECURE options KDTRACE_HOOKS # kernel DTrace hooks options MODULAR - -You also need to build distribution with the options `MKDTRACE=yes` and `MKCTF=yes`. +Optionally: -## Running hello world + options INSECURE # permit modules to loaded from user space once system has gone multiuser and securelevel has been raised. -Load the solaris and dtrace modules, and the SDT (Statically Defined Tracing) and FBT (Function Boundary Tracing) modules: - - modload solaris - modload dtrace - modload dtrace_sdt - modload dtrace_fbt - +A Distribution needs to be built with the options `MKDTRACE=yes` and `MKCTF=yes`, this is taken care of automatically and doesn't need to be specified manually. The list of platforms it is applied to automatically is set in `src/share/mk/bsd.own.mk` -Make the dtrace device node: +Set the system to load the solaris and dtrace related modules in `/etc/modules.conf`, for a list of available modules, see `/stand/$MACHINE/$VERSION/modules/` + +For example, add the following to `/etc/modules.conf` (the file may not exist already on a system): - cd /dev - sh MAKEDEV dtrace + solaris + dtrace + dtrace_sdt + dtrace_fbt + dtrace_lockstat + dtrace_profile + dtrace_syscall + +A `dtrace` device node is created automatically in `/dev/dtrace` when the modules are loaded into place. - List the dtrace probes dtrace -l @@ -81,10 +83,9 @@ List the dtrace probes . 29140 proc lwp_start 29141 proc lwp_exit - - +## Running hello world Put the following into the file hello.d: