xref: /original-bsd/usr.bin/ktrace/ktrace.1 (revision 6ab384a1)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)ktrace.1	1.3 (Berkeley) 07/24/90
7.\"
8.Dd
9.Dt KTRACE 1
10.Sh NAME
11.Nm ktrace
12.Nd enable kernel process tracing
13.Sh SYNOPSIS
14.Nm ktrace
15.Op Fl Cica
16.Op Fl p Ar pid
17.Op Fl g Ar pgrp
18.Op Fl f Ar trfile
19.Op Fl t Ar trstr
20.Nm ktrace
21.Op Fl ida
22.Op Fl f Ar trfile
23.Op command
24.Sh DESCRIPTION
25.Nm Ktrace
26enables kernel trace logging for the specified processes.
27Kernel trace data is logged to the file
28.Sq Pa ktrace.out
29in the
30current directory, or to the file named with the
31.Fl f
32flag.
33The current set of kernel operations that can be traced include:
34system calls, namei translations, signal processing, and i/o.
35By default, all operations are
36traced.  To restrict logging to specific operations, use the
37.Fl t
38flag as described below.  Once tracing is enabled on a process,
39trace data will be logged until either the process exits or the
40trace point is cleared with the
41.Fl c
42flag.  A traced process can generate enormous amounts of log
43data quickly; compounded with the action of the inherit flag,
44.Fl i  ,
45tracing can become unwieldly.
46It is strongly suggested that the user memorize
47how to globally disable all tracing before attempting
48to trace a process.  The following command is sufficient to
49disable tracing on all user owned processes
50(if root, all processes in the system):
51.Pp
52.Dl \&$ trace -C
53.Pp
54The
55trace file is binary format: use
56.Xr kdump 1
57to decode it.
58Following
59is a description of the options:
60.Tw Ds
61.Tp Fl C
62Disable tracing on all user owned processes (if root, all processes in the
63system).
64.Tc Fl f
65.Ws
66.Ar trfile
67.Cx
68Log trace records to
69.Ar trfile
70instead
71of
72.Dq Pa trace.out .
73.Tc Fl t
74.Ws
75.Ar trstr
76.Cx
77The string argument represents the kernel trace points, one
78per letter.  The following table equates the letters with the tracepoints:
79.Dw Ds
80.Dp Cm c
81trace system calls
82.Dp Cm n
83trace namei translations
84.Dp Cm i
85trace I/O
86.Dp Cm s
87trace processing of signals
88.Dp
89.Tc Fl p
90.Ws
91.Ar pid
92.Cx
93Enable (disable) tracing on the indicated process id (only one
94.Fl p
95flag
96allowed);
97.Tc Fl g
98.Ws
99.Ar pgid
100.Cx
101Enable (disable) tracing on all processes in the indicated
102process group.
103.Tp Fl a
104Append to the tracefile instead of truncating it.
105.Tp Fl c
106Clear
107the indicated trace points.
108.Tp Fl i
109Pass the trace flag to all future children of the
110designated processes.
111.Tp Fl I
112Pass the trace flag to all current and future children of the
113designated processes.
114.Tp Ar command
115Run
116.Ar command
117with the specified trace flags.
118.Tp
119.Pp
120The
121.Fl p ,
122.Fl g ,
123and command options are mutually exclusive.
124.Sh EXAMPLES
125.Ds I
126# trace all kernel operations of process id 34
127.Dl $ ktrace -p34
128# trace all kernel operations of processes in process group 15 and
129# pass the trace flags to all current and future children
130.Dl $ ktrace -Ig15
131# disable all tracing of process 65
132.Dl $ ktrace -cp65
133# disable tracing signals on process 70 and all current children
134.Dl $ ktrace -ts -cip70
135# enable tracing of i/o on process 67
136.Dl $ ktrace -ti -p67
137# run the command "w", tracing only system calls
138.Dl $ ktrace -tc w
139# disable all tracing to the file "tracedata"
140.Dl $ ktrace -c -f tracedata
141# disable tracing of all processes owned by the user
142.Dl $ ktrace -C
143.De
144.Sh SEE ALSO
145.Xr kdump 1
146\- display kernel trace data.
147.Sh HISTORY
1484.4 BSD.
149