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