| @@ -1,281 +1,281 @@ | | | @@ -1,281 +1,281 @@ |
1 | .\" $NetBSD: ktrace.1,v 1.42 2011/06/01 22:17:43 wiz Exp $ | | 1 | .\" $NetBSD: ktrace.1,v 1.42.4.1 2015/04/14 13:36:26 msaitoh Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1990, 1993 | | 3 | .\" Copyright (c) 1990, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | | 4 | .\" The Regents of the University of California. All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" 1. Redistributions of source code must retain the above copyright | | 9 | .\" 1. Redistributions of source code must retain the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer. | | 10 | .\" notice, this list of conditions and the following disclaimer. |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer in the | | 12 | .\" notice, this list of conditions and the following disclaimer in the |
13 | .\" documentation and/or other materials provided with the distribution. | | 13 | .\" documentation and/or other materials provided with the distribution. |
14 | .\" 3. Neither the name of the University nor the names of its contributors | | 14 | .\" 3. Neither the name of the University nor the names of its contributors |
15 | .\" may be used to endorse or promote products derived from this software | | 15 | .\" may be used to endorse or promote products derived from this software |
16 | .\" without specific prior written permission. | | 16 | .\" without specific prior written permission. |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | .\" SUCH DAMAGE. | | 28 | .\" SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .\" @(#)ktrace.1 8.1 (Berkeley) 6/6/93 | | 30 | .\" @(#)ktrace.1 8.1 (Berkeley) 6/6/93 |
31 | .\" | | 31 | .\" |
32 | .Dd June 1, 2011 | | 32 | .Dd January 8, 2015 |
33 | .Dt KTRACE 1 | | 33 | .Dt KTRACE 1 |
34 | .Os | | 34 | .Os |
35 | .Sh NAME | | 35 | .Sh NAME |
36 | .Nm ktrace , ktruss | | 36 | .Nm ktrace , ktruss |
37 | .Nd enable kernel process tracing | | 37 | .Nd enable kernel process tracing |
38 | .Sh SYNOPSIS | | 38 | .Sh SYNOPSIS |
39 | .Nm | | 39 | .Nm |
40 | .Op Fl aCcdins | | 40 | .Op Fl aCcdins |
41 | .Op Fl f Ar trfile | | 41 | .Op Fl f Ar trfile |
42 | .Op Fl g Ar pgrp | | 42 | .Op Fl g Ar pgrp |
43 | .Op Fl p Ar pid | | 43 | .Op Fl p Ar pid |
44 | .Op Fl t Ar trstr | | 44 | .Op Fl t Ar trstr |
45 | .Nm | | 45 | .Nm |
46 | .Op Fl adis | | 46 | .Op Fl adis |
47 | .Op Fl f Ar trfile | | 47 | .Op Fl f Ar trfile |
48 | .Op Fl t Ar trstr | | 48 | .Op Fl t Ar trstr |
49 | .Ar command | | 49 | .Ar command |
50 | .Nm ktruss | | 50 | .Nm ktruss |
51 | .Op Fl aCcdilnRT | | 51 | .Op Fl aCcdilnRT |
52 | .Op Fl e Ar emulation | | 52 | .Op Fl e Ar emulation |
53 | .Op Fl f Ar infile | | 53 | .Op Fl f Ar infile |
54 | .Op Fl g Ar pgrp | | 54 | .Op Fl g Ar pgrp |
55 | .Op Fl m Ar maxdata | | 55 | .Op Fl m Ar maxdata |
56 | .Op Fl o Ar outfile | | 56 | .Op Fl o Ar outfile |
57 | .Op Fl p Ar pid | | 57 | .Op Fl p Ar pid |
58 | .Op Fl t Ar trstr | | 58 | .Op Fl t Ar trstr |
59 | .Nm ktruss | | 59 | .Nm ktruss |
60 | .Op Fl adinRT | | 60 | .Op Fl adinRT |
61 | .Op Fl e Ar emulation | | 61 | .Op Fl e Ar emulation |
62 | .Op Fl m Ar maxdata | | 62 | .Op Fl m Ar maxdata |
63 | .Op Fl o Ar outfile | | 63 | .Op Fl o Ar outfile |
64 | .Op Fl t Ar trstr | | 64 | .Op Fl t Ar trstr |
65 | .Op Fl v Ar vers | | 65 | .Op Fl v Ar vers |
66 | command | | 66 | command |
67 | .Sh DESCRIPTION | | 67 | .Sh DESCRIPTION |
68 | .Nm | | 68 | .Nm |
69 | enables kernel trace logging for the specified processes. | | 69 | enables kernel trace logging for the specified processes. |
70 | Kernel trace data is logged to the file | | 70 | Kernel trace data is logged to the file |
71 | .Pa ktrace.out . | | 71 | .Pa ktrace.out . |
72 | The kernel operations that are traced include system calls, namei | | 72 | The kernel operations that are traced include system calls, namei |
73 | translations, signal processing, and | | 73 | translations, signal processing, and |
74 | .Tn I/O . | | 74 | .Tn I/O . |
75 | .Pp | | 75 | .Pp |
76 | Once tracing is enabled on a process, trace data will be logged until | | 76 | Once tracing is enabled on a process, trace data will be logged until |
77 | either the process exits or the trace point is cleared. | | 77 | either the process exits or the trace point is cleared. |
78 | A traced process can generate enormous amounts of log data quickly; | | 78 | A traced process can generate enormous amounts of log data quickly; |
79 | It is strongly suggested that users memorize how to disable tracing before | | 79 | It is strongly suggested that users memorize how to disable tracing before |
80 | attempting to trace a process. | | 80 | attempting to trace a process. |
81 | The following command is sufficient to disable tracing on all user owned | | 81 | The following command is sufficient to disable tracing on all user owned |
82 | processes, and, if executed by root, all processes: | | 82 | processes, and, if executed by root, all processes: |
83 | .Pp | | 83 | .Pp |
84 | .Dl \&$ ktrace -C | | 84 | .Dl \&$ ktrace -C |
85 | .Pp | | 85 | .Pp |
86 | The trace file is not human readable; use | | 86 | The trace file is not human readable; use |
87 | .Xr kdump 1 | | 87 | .Xr kdump 1 |
88 | to decode it. | | 88 | to decode it. |
89 | .Pp | | 89 | .Pp |
90 | .Nm ktruss | | 90 | .Nm ktruss |
91 | is functionally the same as | | 91 | is functionally the same as |
92 | .Nm ktrace | | 92 | .Nm ktrace |
93 | except that trace output is printed | | 93 | except that trace output is printed |
94 | on standard output or to the file specified with the | | 94 | on standard output or to the file specified with the |
95 | .Fl o | | 95 | .Fl o |
96 | option. | | 96 | option. |
97 | .Nm ktruss | | 97 | .Nm ktruss |
98 | is useful to see the kernel operations interleaved with | | 98 | is useful to see the kernel operations interleaved with |
99 | the program output. | | 99 | the program output. |
100 | .Pp | | 100 | .Pp |
101 | The options are as follows: | | 101 | The options are as follows: |
102 | .Bl -tag -width indent | | 102 | .Bl -tag -width indent |
103 | .It Fl a | | 103 | .It Fl a |
104 | Append to the trace file instead of truncating it. | | 104 | Append to the trace file instead of truncating it. |
105 | .It Fl C | | 105 | .It Fl C |
106 | Disable tracing on all user owned processes, and, if executed by root, all | | 106 | Disable tracing on all user owned processes, and, if executed by root, all |
107 | processes in the system. | | 107 | processes in the system. |
108 | .It Fl c | | 108 | .It Fl c |
109 | Clear the trace points associated with the specified file or processes. | | 109 | Clear the trace points associated with the specified file or processes. |
110 | .It Fl d | | 110 | .It Fl d |
111 | Descendants; perform the operation for all current children of the | | 111 | Descendants; perform the operation for all current children of the |
112 | designated processes. | | 112 | designated processes. |
113 | .It Fl f Ar trfile | | 113 | .It Fl f Ar trfile |
114 | Log trace records to | | 114 | Log trace records to |
115 | .Ar trfile | | 115 | .Ar trfile |
116 | instead of | | 116 | instead of |
117 | .Pa ktrace.out . | | 117 | .Pa ktrace.out . |
118 | .It Fl f Ar infile | | 118 | .It Fl f Ar infile |
119 | Read the trace records from | | 119 | Read the trace records from |
120 | .Ar infile | | 120 | .Ar infile |
121 | and print them in a human readable format to standard out. | | 121 | and print them in a human readable format to standard out. |
122 | .It Fl g Ar pgid | | 122 | .It Fl g Ar pgid |
123 | Enable (disable) tracing on all processes in the process group (only one | | 123 | Enable (disable) tracing on all processes in the process group (only one |
124 | .Fl g | | 124 | .Fl g |
125 | flag is permitted). | | 125 | flag is permitted). |
126 | .It Fl i | | 126 | .It Fl i |
127 | Inherit; pass the trace flags to all future children of the designated | | 127 | Inherit; pass the trace flags to all future children of the designated |
128 | processes. | | 128 | processes. |
129 | .It Fl l | | 129 | .It Fl l |
130 | Poll the trace file for new data and print it to standard out. | | 130 | Poll the trace file for new data and print it to standard out. |
131 | Only for use together with the | | 131 | Only for use together with the |
132 | .Fl f | | 132 | .Fl f |
133 | option. | | 133 | option. |
134 | .It Fl m Ar maxdata | | 134 | .It Fl m Ar maxdata |
135 | Print at most | | 135 | Print at most |
136 | .Ar maxdata | | 136 | .Ar maxdata |
137 | bytes of data. | | 137 | bytes of data. |
138 | This is used for pointer type arguments, e.g., strings. | | 138 | This is used for pointer type arguments, e.g., strings. |
139 | The data will be escaped in C-style unless | | 139 | The data will be escaped in C-style unless |
140 | .Fl x | | 140 | .Fl x |
141 | is specified when it will be output in hex and ascii. | | 141 | is specified when it will be output in hex and ascii. |
142 | .It Fl n | | 142 | .It Fl n |
143 | Stop tracing if attempts to write to the trace file would block. | | 143 | Stop tracing if attempts to write to the trace file would block. |
144 | This option always affects | | 144 | This option always affects |
145 | .Nm ktruss | | 145 | .Nm ktruss |
146 | and only affects | | 146 | and only affects |
147 | .Nm ktrace | | 147 | .Nm ktrace |
148 | when writing to | | 148 | when writing to |
149 | .Dv stdout . | | 149 | .Dv stdout . |
150 | If this flag is not set, then the traced program will block until it can | | 150 | If this flag is not set, then the traced program will block until it can |
151 | write more data to the trace file descriptor. | | 151 | write more data to the trace file descriptor. |
152 | .It Fl o Ar outfile | | 152 | .It Fl o Ar outfile |
153 | Log trace records to | | 153 | Log trace records to |
154 | .Ar outfile . | | 154 | .Ar outfile . |
155 | Without this option | | 155 | Without this option |
156 | .Nm ktruss | | 156 | .Nm ktruss |
157 | will print its output in a human | | 157 | will print its output in a human |
158 | readable format to standard out. | | 158 | readable format to standard out. |
159 | .It Fl p Ar pid | | 159 | .It Fl p Ar pid |
160 | Enable (disable) tracing on the indicated process id (only one | | 160 | Enable (disable) tracing on the indicated process id (only one |
161 | .Fl p | | 161 | .Fl p |
162 | flag is permitted). | | 162 | flag is permitted). |
163 | .It Fl s | | 163 | .It Fl s |
164 | Write to the trace file with synchronized I/O. | | 164 | Write to the trace file with synchronized I/O. |
165 | .It Fl R | | 165 | .It Fl R |
166 | Display relative time stamps to output. | | 166 | Display relative time stamps to output. |
167 | .It Fl T | | 167 | .It Fl T |
168 | Same as the | | 168 | Same as the |
169 | .Fl R | | 169 | .Fl R |
170 | option, but use absolute timestamps instead. | | 170 | option, but use absolute timestamps instead. |
171 | .It Fl t Ar trstr | | 171 | .It Fl t Ar trstr |
172 | The string argument represents the kernel trace points, one per letter. | | 172 | The string argument represents the kernel trace points, one per letter. |
173 | The following table equates the letters with the tracepoints: | | 173 | The following table equates the letters with the tracepoints: |
174 | .Pp | | 174 | .Pp |
175 | .Bl -tag -width flag -compact | | 175 | .Bl -tag -width flag -compact |
176 | .It Cm A | | 176 | .It Cm A |
177 | trace all tracepoints | | 177 | trace all tracepoints |
178 | .It Cm a | | 178 | .It Cm a |
179 | trace exec arguments | | 179 | trace exec arguments |
180 | .It Cm c | | 180 | .It Cm c |
181 | trace system calls | | 181 | trace system calls |
182 | .It Cm e | | 182 | .It Cm e |
183 | trace emulation changes | | 183 | trace emulation changes |
184 | .It Cm f | | 184 | .It Cm f |
185 | trace open file descriptors after exec | | 185 | trace open file descriptors after exec |
186 | .It Cm i | | 186 | .It Cm i |
187 | trace | | 187 | trace |
188 | .Tn I/O | | 188 | .Tn I/O |
189 | .It Cm n | | 189 | .It Cm n |
190 | trace namei translations | | 190 | trace namei translations |
191 | .It Cm S | | 191 | .It Cm S |
192 | trace MIB access (sysctl) | | 192 | trace MIB access (sysctl) |
193 | .It Cm s | | 193 | .It Cm s |
194 | trace signal processing | | 194 | trace signal processing |
195 | .\" .It Cm U | | 195 | .\" .It Cm U |
196 | .\" trace scheduler activations upcall data | | 196 | .\" trace scheduler activations upcall data |
197 | .It Cm u | | 197 | .It Cm u |
198 | trace user data | | 198 | trace user data |
199 | .It Cm v | | 199 | .It Cm v |
200 | trace exec environment | | 200 | trace exec environment |
201 | .It Cm w | | 201 | .It Cm w |
202 | trace context switches | | 202 | trace context switches |
203 | .It Cm + | | 203 | .It Cm + |
204 | trace the default set of trace points (c, e, i, l, m, n, s, u) | | 204 | trace the default set of trace points (c, e, i, n, s, u) |
205 | .It Cm - | | 205 | .It Cm - |
206 | do not trace following trace points | | 206 | do not trace following trace points |
207 | .El | | 207 | .El |
208 | .It Fl e Ar emulation | | 208 | .It Fl e Ar emulation |
209 | If an emulation of a process is unknown, | | 209 | If an emulation of a process is unknown, |
210 | interpret system call maps assuming the named emulation instead of | | 210 | interpret system call maps assuming the named emulation instead of |
211 | default "netbsd". | | 211 | default "netbsd". |
212 | .It Ar command | | 212 | .It Ar command |
213 | Execute | | 213 | Execute |
214 | .Ar command | | 214 | .Ar command |
215 | with the specified trace flags. | | 215 | with the specified trace flags. |
216 | .It Fl v Ar version | | 216 | .It Fl v Ar version |
217 | Determines the | | 217 | Determines the |
218 | .Ar version | | 218 | .Ar version |
219 | of the file generated. | | 219 | of the file generated. |
220 | Version 0 is the compatible ktrace format, and | | 220 | Version 0 is the compatible ktrace format, and |
221 | version 1 is the new format with lwp IDs and nanosecond (instead of | | 221 | version 1 is the new format with lwp IDs and nanosecond (instead of |
222 | microsecond) timestamps. | | 222 | microsecond) timestamps. |
223 | .El | | 223 | .El |
224 | .Pp | | 224 | .Pp |
225 | The | | 225 | The |
226 | .Fl p , | | 226 | .Fl p , |
227 | .Fl g , | | 227 | .Fl g , |
228 | and | | 228 | and |
229 | .Ar command | | 229 | .Ar command |
230 | options are mutually exclusive. | | 230 | options are mutually exclusive. |
231 | The | | 231 | The |
232 | .Fl R | | 232 | .Fl R |
233 | and | | 233 | and |
234 | .Fl T | | 234 | .Fl T |
235 | options are also mutually exclusive. | | 235 | options are also mutually exclusive. |
236 | .Sh EXAMPLES | | 236 | .Sh EXAMPLES |
237 | # trace all kernel operations of process id 34 | | 237 | # trace all kernel operations of process id 34 |
238 | .Dl $ ktrace -p 34 | | 238 | .Dl $ ktrace -p 34 |
239 | .Pp | | 239 | .Pp |
240 | .Bd -literal | | 240 | .Bd -literal |
241 | # trace all kernel operations of processes in process group 15 and | | 241 | # trace all kernel operations of processes in process group 15 and |
242 | # pass the trace flags to all current and future children | | 242 | # pass the trace flags to all current and future children |
243 | .Ed | | 243 | .Ed |
244 | .Dl $ ktrace -idg 15 | | 244 | .Dl $ ktrace -idg 15 |
245 | .Pp | | 245 | .Pp |
246 | # disable all tracing of process 65 | | 246 | # disable all tracing of process 65 |
247 | .Dl $ ktrace -cp 65 | | 247 | .Dl $ ktrace -cp 65 |
248 | .Pp | | 248 | .Pp |
249 | # disable tracing signals on process 70 and all current children | | 249 | # disable tracing signals on process 70 and all current children |
250 | .Dl $ ktrace -t s -cdp 70 | | 250 | .Dl $ ktrace -t s -cdp 70 |
251 | .Pp | | 251 | .Pp |
252 | # enable tracing of | | 252 | # enable tracing of |
253 | .Tn I/O | | 253 | .Tn I/O |
254 | on process 67 | | 254 | on process 67 |
255 | .Dl $ ktrace -ti -p 67 | | 255 | .Dl $ ktrace -ti -p 67 |
256 | .Pp | | 256 | .Pp |
257 | # run the command "w", tracing only system calls | | 257 | # run the command "w", tracing only system calls |
258 | .Dl $ ktrace -tc w | | 258 | .Dl $ ktrace -tc w |
259 | .Pp | | 259 | .Pp |
260 | # disable all tracing to the file "tracedata" | | 260 | # disable all tracing to the file "tracedata" |
261 | .Dl $ ktrace -c -f tracedata | | 261 | .Dl $ ktrace -c -f tracedata |
262 | .Pp | | 262 | .Pp |
263 | # disable tracing of all processes owned by the user | | 263 | # disable tracing of all processes owned by the user |
264 | .Dl $ ktrace -C | | 264 | .Dl $ ktrace -C |
265 | .Pp | | 265 | .Pp |
266 | # run the command "w", displaying to standard output | | 266 | # run the command "w", displaying to standard output |
267 | .Dl $ ktruss w | | 267 | .Dl $ ktruss w |
268 | .Pp | | 268 | .Pp |
269 | # trace process 42 and log the records to "ktruss.out" | | 269 | # trace process 42 and log the records to "ktruss.out" |
270 | .Dl $ ktruss -p 42 -o ktruss.out | | 270 | .Dl $ ktruss -p 42 -o ktruss.out |
271 | .Pp | | 271 | .Pp |
272 | # poll ktruss.out for available records and print them | | 272 | # poll ktruss.out for available records and print them |
273 | .Dl $ ktruss -lf ktruss.out | | 273 | .Dl $ ktruss -lf ktruss.out |
274 | .Sh SEE ALSO | | 274 | .Sh SEE ALSO |
275 | .Xr kdump 1 , | | 275 | .Xr kdump 1 , |
276 | .Xr ktrace 2 | | 276 | .Xr ktrace 2 |
277 | .Sh HISTORY | | 277 | .Sh HISTORY |
278 | The | | 278 | The |
279 | .Nm | | 279 | .Nm |
280 | command appears in | | 280 | command appears in |
281 | .Bx 4.4 . | | 281 | .Bx 4.4 . |