]> git.saurik.com Git - apple/system_cmds.git/blame - ktrace.tproj/ktrace.1
system_cmds-336.1.2.tar.gz
[apple/system_cmds.git] / ktrace.tproj / ktrace.1
CommitLineData
1815bff5
A
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
b51d5b5f 33.\" $FreeBSD: src/usr.bin/ktrace/ktrace.1,v 1.8.2.5 2001/08/16 13:16:53 ru Exp $
1815bff5
A
34.\"
35.Dd June 6, 1993
36.Dt KTRACE 1
b51d5b5f 37.Os
1815bff5
A
38.Sh NAME
39.Nm ktrace
40.Nd enable kernel process tracing
41.Sh SYNOPSIS
b51d5b5f 42.Nm
1815bff5
A
43.Op Fl aCcdi
44.Op Fl f Ar trfile
b51d5b5f 45.Op Fl g Ar pgrp | Fl p Ar pid
1815bff5 46.Op Fl t Ar trstr
b51d5b5f 47.Nm
1815bff5
A
48.Op Fl adi
49.Op Fl f Ar trfile
50.Op Fl t Ar trstr
b51d5b5f 51.Ar command
1815bff5 52.Sh DESCRIPTION
b51d5b5f
A
53The
54.Nm
55command enables kernel trace logging for the specified processes.
1815bff5
A
56Kernel trace data is logged to the file
57.Pa ktrace.out .
58The kernel operations that are traced include system calls, namei
59translations, signal processing, and
60.Tn I/O .
61.Pp
62Once tracing is enabled on a process, trace data will be logged until
63either the process exits or the trace point is cleared.
64A traced process can generate enormous amounts of log data quickly;
65It is strongly suggested that users memorize how to disable tracing before
66attempting to trace a process.
67The following command is sufficient to disable tracing on all user owned
68processes, and, if executed by root, all processes:
69.Pp
b51d5b5f 70.Dl \&$ ktrace -C
1815bff5
A
71.Pp
72The trace file is not human readable; use
73.Xr kdump 1
74to decode it.
75.Pp
76The options are as follows:
77.Bl -tag -width indent
78.It Fl a
b51d5b5f 79Append to the trace file instead of recreating it.
1815bff5
A
80.It Fl C
81Disable tracing on all user owned processes, and, if executed by root, all
82processes in the system.
83.It Fl c
84Clear the trace points associated with the specified file or processes.
85.It Fl d
86Descendants; perform the operation for all current children of the
87designated processes.
b51d5b5f 88.It Fl f Ar file
1815bff5
A
89Log trace records to
90.Ar file
91instead of
92.Pa ktrace.out .
b51d5b5f 93.It Fl g Ar pgid
1815bff5
A
94Enable (disable) tracing on all processes in the process group (only one
95.Fl g
96flag is permitted).
97.It Fl i
98Inherit; pass the trace flags to all future children of the designated
99processes.
b51d5b5f 100.It Fl p Ar pid
1815bff5
A
101Enable (disable) tracing on the indicated process id (only one
102.Fl p
103flag is permitted).
b51d5b5f 104.It Fl t Ar trstr
1815bff5
A
105The string argument represents the kernel trace points, one per letter.
106The following table equates the letters with the tracepoints:
107.Pp
108.Bl -tag -width flag -compact
109.It Cm c
110trace system calls
111.It Cm n
112trace namei translations
113.It Cm i
114trace
115.Tn I/O
116.It Cm s
117trace signal processing
b51d5b5f
A
118.It Cm u
119userland traces
120.It Cm w
121context switches
1815bff5
A
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
b51d5b5f
A
164.Sh BUGS
165Only works if
166.Ar file
167is a regular file.
1815bff5
A
168.Sh HISTORY
169The
b51d5b5f
A
170.Nm
171command appeared in
1815bff5 172.Bx 4.4 .