1.\" $NetBSD: ktrace.1,v 1.15 2001/10/26 23:38:07 jdolecek 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 39.Sh NAME 40.Nm ktrace , ktruss 41.Nd enable kernel process tracing 42.Sh SYNOPSIS 43.Nm 44.Op Fl aCcdis 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 adis 51.Op Fl f Ar trfile 52.Op Fl t Ar trstr 53command 54.Nm ktruss 55.Op Fl aCcdilRT 56.Op Fl e Ar emulation 57.Op Fl f Ar infile 58.Op Fl g Ar pgrp 59.Op Fl m Ar maxdata 60.Op Fl o Ar outfile 61.Op Fl p Ar pid 62.Op Fl t Ar trstr 63.Nm ktruss 64.Op Fl adiRT 65.Op Fl e Ar emulation 66.Op Fl m Ar maxdata 67.Op Fl o Ar outfile 68.Op Fl t Ar trstr 69command 70.Sh DESCRIPTION 71.Nm 72enables kernel trace logging for the specified processes. 73Kernel trace data is logged to the file 74.Pa ktrace.out . 75The kernel operations that are traced include system calls, namei 76translations, signal processing, and 77.Tn I/O . 78.Pp 79Once tracing is enabled on a process, trace data will be logged until 80either the process exits or the trace point is cleared. 81A traced process can generate enormous amounts of log data quickly; 82It is strongly suggested that users memorize how to disable tracing before 83attempting to trace a process. 84The following command is sufficient to disable tracing on all user owned 85processes, and, if executed by root, all processes: 86.Pp 87.Dl \&$ ktrace -C 88.Pp 89The trace file is not human readable; use 90.Xr kdump 1 91to decode it. 92.Pp 93The options are as follows: 94.Bl -tag -width indent 95.It Fl a 96Append to the trace file instead of truncating it. 97.It Fl C 98Disable tracing on all user owned processes, and, if executed by root, all 99processes in the system. 100.It Fl c 101Clear the trace points associated with the specified file or processes. 102.It Fl d 103Descendants; perform the operation for all current children of the 104designated processes. 105.It Fl f Ar file 106Log trace records to 107.Ar file 108instead of 109.Pa ktrace.out . 110.It Fl g Ar pgid 111Enable (disable) tracing on all processes in the process group (only one 112.Fl g 113flag is permitted). 114.It Fl i 115Inherit; pass the trace flags to all future children of the designated 116processes. 117.It Fl p Ar pid 118Enable (disable) tracing on the indicated process id (only one 119.Fl p 120flag is permitted). 121.It Fl s 122Write to the trace file with synchronized I/O. 123.It Fl t Ar trstr 124The string argument represents the kernel trace points, one per letter. 125The following table equates the letters with the tracepoints: 126.Pp 127.Bl -tag -width flag -compact 128.It Cm c 129trace system calls 130.It Cm e 131trace emulation changes 132.It Cm n 133trace namei translations 134.It Cm i 135trace 136.Tn I/O 137.It Cm s 138trace signal processing 139.It Cm u 140trace user data 141.It Cm w 142trace context switches 143.It Cm + 144trace the default set of trace points (c, e, n, i, s, u) 145.El 146.It Fl e Ar emulation 147If an emulation of a process is unknown, 148interpret system call maps assuming the named emulation instead of 149default "netbsd". 150.It Ar command 151Execute 152.Ar command 153with the specified trace flags. 154.El 155.Pp 156The 157.Fl p , 158.Fl g , 159and 160.Ar command 161options are mutually exclusive. 162.Sh EXAMPLES 163# trace all kernel operations of process id 34 164.Dl $ ktrace -p 34 165.Pp 166.Bd -literal 167# trace all kernel operations of processes in process group 15 and 168# pass the trace flags to all current and future children 169.Ed 170.Dl $ ktrace -idg 15 171.Pp 172# disable all tracing of process 65 173.Dl $ ktrace -cp 65 174.Pp 175# disable tracing signals on process 70 and all current children 176.Dl $ ktrace -t s -cdp 70 177.Pp 178# enable tracing of 179.Tn I/O 180on process 67 181.Dl $ ktrace -ti -p 67 182.Pp 183# run the command "w", tracing only system calls 184.Dl $ ktrace -tc w 185.Pp 186# disable all tracing to the file "tracedata" 187.Dl $ ktrace -c -f tracedata 188.Pp 189# disable tracing of all processes owned by the user 190.Dl $ ktrace -C 191.Sh SEE ALSO 192.Xr kdump 1 193.Sh HISTORY 194The 195.Nm 196command appears in 197.Bx 4.4 . 198