/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/debugging/profiling/dtrace.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
D scripting language
 
2
--------------------
 
3
 Rules
 
4
 
 
5
 BEGIN
 
6
 {
 
7
    actions
 
8
 }
 
9
 
 
10
 provider:module:function:name
 
11
 /test/
 
12
 {
 
13
    actions
 
14
 }
 
15
 
 
16
 provider:module:function:name
 
17
 /another test/
 
18
 {
 
19
    actions
 
20
 }
 
21
 
 
22
 
 
23
 * Supported providers: syscall, pid<num>, sysinfo
 
24
 Examples:
 
25
  syscall::open*:entry          - called on entry in open family syscalls
 
26
  pid4092:::entry               - called on entry in any syscall by process 4092
 
27
    
 
28
 * Tests
 
29
        cpu == 0 && pid = 1029  - Process 1029 running on the first CPU
 
30
        execname != "sched"     - Process is not scheduller
 
31
    - cpu, pid, execname are builtin variables
 
32
    
 
33
 * Actions
 
34
    Formated and unformated output, variable assignment...
 
35
 
 
36
 Syntaxes
 
37
 --------
 
38
    - Semicolon terminated commands;
 
39
    - Variables var. Declaration is not needed, but good idea to set to zero
 
40
    to deallocate space occupied.
 
41
        var = 1
 
42
            ... usage in this or next probes ...
 
43
        var = 0
 
44
    - Arrays: arr[idx] = 1
 
45
 
 
46
 
 
47
Builtin Variables
 
48
=================
 
49
 execname                       - executable name
 
50
 probemod                       - library/executable name
 
51
 probefunc                      - function name
 
52
 timestamp                      - current timestamp in nanoseconds
 
53
 cpu                            - processor executing code (index)
 
54
 pid                            - process
 
55
 uid                            - process owner
 
56
 
 
57
 self                           - thread specific store, usage (self->var = 1)
 
58
 
 
59
 
 
60
 
 
61
Providers
 
62
=========
 
63
 Syscall & pid providers
 
64
 -----------------------
 
65
    module      - object: a.out, libc, libds, and so on...
 
66
    function    - symbol
 
67
    name        - place: entry, return
 
68
 
 
69
 Sysinfo
 
70
 -------
 
71
    :::pswitch          - fired when a process is switched to run
 
72
    :::exec-success     - fired when a new process is started
 
73
 
 
74
 Proc
 
75
 ----
 
76
    Process and thread creation and termination, signals...
 
77
    
 
78
    :::signal-send      - signal send
 
79
                            args[1]             - psinfo_t of receiving process
 
80
                                ->pr_fname      - process file name
 
81
                            args[2]             - signal number
 
82
 
 
83
 Sched
 
84
 -----
 
85
    Scheduling events
 
86
    :::on-cpu                                   - got on cpu
 
87
    :::off-cpu                                  - got off cpu
 
88
 
 
89
 Io
 
90
 --
 
91
    :::start            - I/O operation started
 
92
                        args[0]
 
93
                            ->b_flag            B_READ bit (1 - read : 0 - write)
 
94
                        args[1]
 
95
                            ->dev_statname      device name
 
96
                        args[2]
 
97
                            ->fi_pathname       file name
 
98
 
 
99
 
 
100
Actions
 
101
=======
 
102
    printf()                    - C style printf
 
103
    ustack()                    - user level stack
 
104
    trace                       - value of give variable
 
105
    var=val                     - variable assignments
 
106
    system("ls %s", var)        - call shell command using printf syntax
 
107
    
 
108
 
 
109
Aggregators
 
110
===========
 
111
 Allows to collect tables of information. The format is following
 
112
 @name[indexes]=aggregate_function()
 
113
 
 
114
 Aggegators: count(), sum(val)
 
115
 
 
116
 - Aggegated values are reported on dtrace termination (Ctrl+C)
 
117
 - Only single table is supported (?)
 
118
 - multiline functions could be used as indexes, i.e. @name[ustack()]=...
 
119
 
 
120
 Example:
 
121
    pid4092:libc::entry { @count_table[probefunc] = count(); }
 
122
 
 
123
 
 
124
 
 
125
 
 
126
 
 
127
 
 
128
 
 
129
Calling Dtrace
 
130
--------------
 
131
    dtrace -s <script_file>
 
132
    dtrace -s <script_file> -c command          Trace command from start to end
 
133
        -w                                      Permit destructive actions
 
134
        -q                                      Quite
 
135
        
 
 
b'\\ No newline at end of file'