xref: /freebsd/usr.bin/ktrace/ktrace.1 (revision 9bedbe6c7dcc2578c7c8f1327d0005adf50258f8)
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.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)ktrace.1	8.1 (Berkeley) 6/6/93
33.\"
34.Dd June 6, 1993
35.Dt KTRACE 1
36.Os BSD 4.4
37.Sh NAME
38.Nm ktrace
39.Nd enable kernel process tracing
40.Sh SYNOPSIS
41.Nm ktrace
42.Op Fl aCcdi
43.Op Fl f Ar trfile
44.Op Fl g Ar pgrp
45.Op Fl p Ar pid
46.Op Fl t Ar trstr
47.Nm ktrace
48.Op Fl adi
49.Op Fl f Ar trfile
50.Op Fl t Ar trstr
51command
52.Sh DESCRIPTION
53.Nm Ktrace
54enables kernel trace logging for the specified processes.
55Kernel trace data is logged to the file
56.Pa ktrace.out .
57The kernel operations that are traced include system calls, namei
58translations, signal processing, and
59.Tn I/O .
60.Pp
61Once tracing is enabled on a process, trace data will be logged until
62either the process exits or the trace point is cleared.
63A traced process can generate enormous amounts of log data quickly;
64It is strongly suggested that users memorize how to disable tracing before
65attempting to trace a process.
66The following command is sufficient to disable tracing on all user owned
67processes, and, if executed by root, all processes:
68.Pp
69.Dl \&$ ktrace -C
70.Pp
71The trace file is not human readable; use
72.Xr kdump 1
73to decode it.
74.Pp
75The options are as follows:
76.Bl -tag -width indent
77.It Fl a
78Append to the trace file instead of recreating it.
79.It Fl C
80Disable tracing on all user owned processes, and, if executed by root, all
81processes in the system.
82.It Fl c
83Clear the trace points associated with the specified file or processes.
84.It Fl d
85Descendants; perform the operation for all current children of the
86designated processes.
87.It Fl f Ar file
88Log trace records to
89.Ar file
90instead of
91.Pa ktrace.out .
92.It Fl g Ar pgid
93Enable (disable) tracing on all processes in the process group (only one
94.Fl g
95flag is permitted).
96.It Fl i
97Inherit; pass the trace flags to all future children of the designated
98processes.
99.It Fl p Ar pid
100Enable (disable) tracing on the indicated process id (only one
101.Fl p
102flag is permitted).
103.It Fl t Ar trstr
104The string argument represents the kernel trace points, one per letter.
105The following table equates the letters with the tracepoints:
106.Pp
107.Bl -tag -width flag -compact
108.It Cm c
109trace system calls
110.It Cm n
111trace namei translations
112.It Cm i
113trace
114.Tn I/O
115.It Cm s
116trace signal processing
117.It Cm u
118userland traces
119.It Cm w
120context switches
121.El
122.It Ar command
123Execute
124.Ar command
125with the specified trace flags.
126.El
127.Pp
128The
129.Fl p ,
130.Fl g ,
131and
132.Ar command
133options are mutually exclusive.
134.Sh EXAMPLES
135# trace all kernel operations of process id 34
136.Dl $ ktrace -p 34
137.Pp
138# trace all kernel operations of processes in process group 15 and
139# pass the trace flags to all current and future children
140.Dl $ ktrace -idg 15
141.Pp
142# disable all tracing of process 65
143.Dl $ ktrace -cp 65
144.Pp
145# disable tracing signals on process 70 and all current children
146.Dl $ ktrace -t s -cdp 70
147.Pp
148# enable tracing of
149.Tn I/O
150on process 67
151.Dl $ ktrace -ti -p 67
152.Pp
153# run the command "w", tracing only system calls
154.Dl $ ktrace -tc w
155.Pp
156# disable all tracing to the file "tracedata"
157.Dl $ ktrace -c -f tracedata
158.Pp
159# disable tracing of all processes owned by the user
160.Dl $ ktrace -C
161.Sh SEE ALSO
162.Xr kdump 1
163.Sh BUGS
164Only works if
165.Ar file
166is a regular file.
167.Sh HISTORY
168The
169.Nm ktrace
170command appears in
171.Bx 4.4 .
172