Diff for /wikisrc/tutorials/how_to_enable_and_run_dtrace.mdwn between versions 1.17 and 1.24

version 1.17, 2017/03/22 16:04:46 version 1.24, 2018/05/24 17:38:58
Line 8  Also see [DTrace Introduction](http://dt Line 8  Also see [DTrace Introduction](http://dt
 DTrace is a work-in-progress effort and it is for x86 systems and some arm boards.  DTrace is a work-in-progress effort and it is for x86 systems and some arm boards.
   
 * i386 and amd64  * i386 and amd64
 * earm* (evbarm and armv4 based ports (armv4 side requires further testing but system is built with CTF)  * earm* (evbarm and armv4 based ports)
   
 ## Supported providers  ## Supported providers
   
Line 51  Set the system to load the solaris and d Line 51  Set the system to load the solaris and d
   
 For example, add the following to `/etc/modules.conf` (the file may not exist already on a system):  For example, add the following to `/etc/modules.conf` (the file may not exist already on a system):
           
     solaris  - `solaris`
     dtrace  - `dtrace`
     dtrace_sdt  - `dtrace_sdt`
     dtrace_fbt  - `dtrace_fbt`
     dtrace_lockstat  - `dtrace_lockstat`
     dtrace_profile  - `dtrace_profile`
     dtrace_syscall  - `dtrace_syscall`
           
 A `dtrace` device node is created automatically in `/dev/dtrace` when the modules are loaded into place.  A `dtrace` device node is created automatically in `/dev/dtrace` when the modules are loaded into place.
           
Line 85  List the dtrace probes  Line 85  List the dtrace probes 
     29141       proc                                                     lwp_exit      29141       proc                                                     lwp_exit
   
   
 ##  Running hello world   ## Running hello world 
   
 Put the following into the file hello.d:  Put the following into the file hello.d:
           
Line 105  Run the hello world script:  Line 105  Run the hello world script: 
       0      1                           :BEGIN   Hello world        0      1                           :BEGIN   Hello world
           
   
 A more complex example that traces the execution of a sleep operation  ## A more complex example
   
   The following script traces the execution of a sleep operation
 in the kernel. Put it in sleep.d:  in the kernel. Put it in sleep.d:
           
     #pragma D option flowindent      #pragma D option flowindent
       
     fbt::syscall:entry      syscall::nanosleep:entry
     /execname == "sleep" && guard++ == 0/      /execname == "sleep" && guard++ == 0/
     {      {
             self->traceme = 1;              self->traceme = 1;
             printf("fd: %d", arg0);  
     }      }
       
     fbt::syscall:entry /self->traceme/ {}      fbt:::
           /self->traceme/
     fbt::syscall:return      {}
   
       syscall::nanosleep:return
     /self->traceme/      /self->traceme/
     {      {
             self->traceme = 0;              self->traceme = 0;
             exit(0);              exit(0);
     }      }
       
   
 Start the script running (dtrace -s sleep.d) and then execute a "sleep 2" in another shell.   Start the script running:
   
       dtrace -s sleep.d
   
   This will take a while as the script instruments every function in the
   kernel. When it's ready, it will print a message like "dtrace: script
   'sleep.d' matched 59268 probes".  Then execute a "sleep 2" in another
   shell.
   
   ## Tools included in base
   
   Starting with NetBSD-8, on builds where `MKDTRACE=yes` is set, scripts from
   [Brendan Gregg's DTrace toolkit](https://github.com/opendtrace/toolkit/) are installed in base as standard.
   
   At present, the following scripts are installed in `/usr/sbin`: 
   
   - `dtruss` - An implementation of the truss utility in DTrace which traces the system calls
   made by a process
   - `execsnoop` - snoop on execution of processes as they occur
   - `opensnoop` - snoop on openning of files as they occur
   - `procsystime` -  print process system call time details.

Removed from v.1.17  
changed lines
  Added in v.1.24


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb