]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - usr.bin/ktrace/ktrace.1
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / usr.bin / ktrace / ktrace.1
1 .\" Copyright (c) 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)ktrace.1    8.1 (Berkeley) 6/6/93
29 .\" $FreeBSD$
30 .\"
31 .Dd August 26, 2014
32 .Dt KTRACE 1
33 .Os
34 .Sh NAME
35 .Nm ktrace
36 .Nd enable kernel process tracing
37 .Sh SYNOPSIS
38 .Nm
39 .Op Fl aCcdi
40 .Op Fl f Ar trfile
41 .Op Fl g Ar pgrp | Fl p Ar pid
42 .Op Fl t Ar trstr
43 .Nm
44 .Op Fl adi
45 .Op Fl f Ar trfile
46 .Op Fl t Ar trstr
47 .Ar command
48 .Sh DESCRIPTION
49 The
50 .Nm
51 utility enables kernel trace logging for the specified processes.
52 Kernel trace data is logged to the file
53 .Pa ktrace.out .
54 The kernel operations that are traced include system calls, namei
55 translations, signal processing, and
56 .Tn I/O .
57 .Pp
58 Once tracing is enabled on a process, trace data will be logged until
59 either the process exits or the trace point is cleared.
60 A traced process can generate enormous amounts of log data quickly;
61 It is strongly suggested that users memorize how to disable tracing before
62 attempting to trace a process.
63 The following command is sufficient to disable tracing on all user-owned
64 processes, and, if executed by root, all processes:
65 .Pp
66 .Dl \&$ ktrace -C
67 .Pp
68 The trace file is not human readable; use
69 .Xr kdump 1
70 to decode it.
71 .Pp
72 The utility may be used only with a kernel that has been built with the
73 .Dq KTRACE
74 option in the kernel configuration file.
75 .Pp
76 The options are:
77 .Bl -tag -width indent
78 .It Fl a
79 Append to the trace file instead of recreating it.
80 .It Fl C
81 Disable tracing on all user-owned processes, and, if executed by root, all
82 processes in the system.
83 .It Fl c
84 Clear the specified trace points associated with the given file or processes.
85 .It Fl d
86 Descendants; perform the operation for all current children of the
87 designated processes.
88 .It Fl f Ar trfile
89 Log trace records to
90 .Ar trfile
91 instead of
92 .Pa ktrace.out .
93 .It Fl g Ar pgid
94 Enable (disable) tracing on all processes in the process group (only one
95 .Fl g
96 flag is permitted).
97 .It Fl i
98 Inherit; pass the trace flags to all future children of the designated
99 processes.
100 .It Fl p Ar pid
101 Enable (disable) tracing on the indicated process id (only one
102 .Fl p
103 flag is permitted).
104 .It Fl t Ar trstr
105 Specify the list of trace points to enable or disable, one per letter.
106 If an explicit list is not specified, the default set of trace points is used.
107 .Pp
108 The following trace points are supported:
109 .Pp
110 .Bl -tag -width flag -compact
111 .It Cm c
112 trace system calls
113 .It Cm f
114 trace page faults
115 .It Cm i
116 trace
117 .Tn I/O
118 .It Cm n
119 trace namei translations
120 .It Cm p
121 trace capability check failures
122 .It Cm s
123 trace signal processing
124 .It Cm t
125 trace various structures
126 .It Cm u
127 userland traces
128 .It Cm w
129 context switches
130 .It Cm y
131 trace
132 .Xr sysctl 3
133 requests
134 .It Cm +
135 trace the default set of trace points -
136 .Cm c , i , n , p , s , t , u , y
137 .El
138 .It Ar command
139 Execute
140 .Ar command
141 with the specified trace flags.
142 .El
143 .Pp
144 The
145 .Fl p ,
146 .Fl g ,
147 and
148 .Ar command
149 options are mutually exclusive.
150 .Sh EXAMPLES
151 # trace all kernel operations of process id 34
152 .Dl $ ktrace -p 34
153 .Pp
154 # trace all kernel operations of processes in process group 15 and
155 # pass the trace flags to all current and future children
156 .Dl $ ktrace -idg 15
157 .Pp
158 # disable all tracing of process 65
159 .Dl $ ktrace -cp 65
160 .Pp
161 # disable tracing signals on process 70 and all current children
162 .Dl $ ktrace -t s -cdp 70
163 .Pp
164 # enable tracing of
165 .Tn I/O
166 on process 67
167 .Dl $ ktrace -ti -p 67
168 .Pp
169 # run the command "w", tracing only system calls
170 .Dl $ ktrace -tc w
171 .Pp
172 # disable all tracing to the file "tracedata"
173 .Dl $ ktrace -c -f tracedata
174 .Pp
175 # disable tracing of all user-owned processes
176 .Dl $ ktrace -C
177 .Sh SEE ALSO
178 .Xr kdump 1
179 .Sh HISTORY
180 The
181 .Nm
182 command appeared in
183 .Bx 4.4 .
184 .Sh BUGS
185 Only works if
186 .Ar trfile
187 is a regular file.