xref: /dragonfly/usr.bin/ktrace/ktrace.1 (revision 0ca59c34)
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. 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: src/usr.bin/ktrace/ktrace.1,v 1.8.2.8 2002/06/21 15:27:30 charnier Exp $
30.\" $DragonFly: src/usr.bin/ktrace/ktrace.1,v 1.5 2008/10/16 08:15:18 swildner Exp $
31.\"
32.Dd June 6, 1993
33.Dt KTRACE 1
34.Os
35.Sh NAME
36.Nm ktrace
37.Nd enable kernel process tracing
38.Sh SYNOPSIS
39.Nm
40.Op Fl aCcdi
41.Op Fl f Ar trfile
42.Op Fl g Ar pgrp | Fl p Ar pid
43.Op Fl t Ar trstr
44.Nm
45.Op Fl adi
46.Op Fl f Ar trfile
47.Op Fl t Ar trstr
48.Ar command
49.Sh DESCRIPTION
50The
51.Nm
52utility enables kernel trace logging for the specified processes.
53Kernel trace data is logged to the file
54.Pa ktrace.out .
55The kernel operations that are traced include system calls, namei
56translations, signal processing, and
57.Tn I/O .
58.Pp
59Once tracing is enabled on a process, trace data will be logged until
60either the process exits or the trace point is cleared.
61A traced process can generate enormous amounts of log data quickly;
62It is strongly suggested that users memorize how to disable tracing before
63attempting to trace a process.
64The following command is sufficient to disable tracing on all user owned
65processes, and, if executed by root, all processes:
66.Pp
67.Dl \&$ ktrace -C
68.Pp
69The trace file is not human readable; use
70.Xr kdump 1
71to decode it.
72.Pp
73The options are as follows:
74.Bl -tag -width indent
75.It Fl a
76Append to the trace file instead of recreating it.
77.It Fl C
78Disable tracing on all user owned processes, and, if executed by root, all
79processes in the system.
80.It Fl c
81Clear the trace points associated with the specified file or processes.
82.It Fl d
83Descendants; perform the operation for all current children of the
84designated processes.
85.It Fl f Ar trfile
86Log trace records to
87.Ar trfile
88instead of
89.Pa ktrace.out .
90.It Fl g Ar pgid
91Enable (disable) tracing on all processes in the process group (only one
92.Fl g
93flag is permitted).
94.It Fl i
95Inherit; pass the trace flags to all future children of the designated
96processes.
97.It Fl p Ar pid
98Enable (disable) tracing on the indicated process id (only one
99.Fl p
100flag is permitted).
101.It Fl t Ar trstr
102The string argument represents the kernel trace points, one per letter.
103The following table equates the letters with the tracepoints:
104.Pp
105.Bl -tag -width flag -compact
106.It Cm c
107trace system calls
108.It Cm n
109trace namei translations
110.It Cm i
111trace
112.Tn I/O
113.It Cm s
114trace signal processing
115.It Cm u
116userland traces
117.It Cm w
118context switches
119.It Cm +
120trace the default set of trace points -
121.Cm c , n , i , s , u
122.El
123.It Ar command
124Execute
125.Ar command
126with the specified trace flags.
127.El
128.Pp
129The
130.Fl p ,
131.Fl g ,
132and
133.Ar command
134options are mutually exclusive.
135.Sh EXAMPLES
136# trace all kernel operations of process id 34
137.Dl $ ktrace -p 34
138.Pp
139# trace all kernel operations of processes in process group 15 and
140# pass the trace flags to all current and future children
141.Dl $ ktrace -idg 15
142.Pp
143# disable all tracing of process 65
144.Dl $ ktrace -cp 65
145.Pp
146# disable tracing signals on process 70 and all current children
147.Dl $ ktrace -t s -cdp 70
148.Pp
149# enable tracing of
150.Tn I/O
151on process 67
152.Dl $ ktrace -ti -p 67
153.Pp
154# run the command "w", tracing only system calls
155.Dl $ ktrace -tc w
156.Pp
157# disable all tracing to the file "tracedata"
158.Dl $ ktrace -c -f tracedata
159.Pp
160# disable tracing of all processes owned by the user
161.Dl $ ktrace -C
162.Sh SEE ALSO
163.Xr kdump 1
164.Sh HISTORY
165The
166.Nm
167command appeared in
168.Bx 4.4 .
169.Sh BUGS
170Only works if
171.Ar trfile
172is a regular file.
173