1.\" $OpenBSD: ktrace.1,v 1.19 2007/05/31 19:20:11 jmc 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. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)ktrace.1 8.1 (Berkeley) 6/6/93 31.\" 32.Dd $Mdocdate: May 31 2007 $ 33.Dt KTRACE 1 34.Os 35.Sh NAME 36.Nm ktrace 37.Nd enable kernel process tracing 38.Sh SYNOPSIS 39.Nm ktrace 40.Op Fl aCcdi 41.Op Fl f Ar trfile 42.Op Fl g Ar pgid 43.Op Fl p Ar pid 44.Op Fl t Ar trstr 45.Nm ktrace 46.Op Fl adi 47.Op Fl f Ar trfile 48.Op Fl t Ar trstr 49.Ar command 50.Sh DESCRIPTION 51.Nm ktrace 52enables kernel trace logging for the specified processes. 53By default, kernel trace data is logged to the file 54.Pa ktrace.out , 55unless overridden by the 56.Fl f 57option. 58The kernel operations that are traced include system calls, namei 59translations, signal processing, and I/O. 60.Pp 61Once tracing is enabled on a process, trace data will be logged until 62either the process exits or the trace point is cleared. 63A traced process can generate enormous amounts of log data quickly; 64it is strongly suggested that users memorize how to disable tracing before 65attempting to trace a process. 66The following command is sufficient to disable tracing on all user owned 67processes, and, if executed by root, all processes: 68.Pp 69.Dl $ ktrace -C 70.Pp 71The trace file is not human-readable; use 72.Xr kdump 1 73to decode it. 74.Pp 75The options are as follows: 76.Bl -tag -width "-t trstr" 77.It Fl a 78Append to the trace file instead of recreating it. 79.It Fl C 80Disable tracing on all user owned processes, and, if executed by root, all 81processes in the system. 82.It Fl c 83Clear the trace points associated with the specified file or processes. 84.It Fl d 85Descendants; perform the operation for all current children of the 86designated processes. 87.It Fl f Ar trfile 88Log trace records to 89.Ar trfile 90instead of 91.Pa ktrace.out . 92.It Fl g Ar pgid 93Enable (disable) tracing on all processes in the process group (only one 94.Fl g 95flag is permitted). 96.It Fl i 97Inherit; pass the trace flags to all future children of the designated 98processes. 99.It Fl p Ar pid 100Enable (disable) tracing on the indicated process ID (only one 101.Fl p 102flag is permitted). 103.It Fl t Ar trstr 104The string argument represents the kernel trace points, one per letter. 105The default flags are 106.Cm c , 107.Cm e , 108.Cm i , 109.Cm n , 110and 111.Cm s . 112The following table equates the letters with the tracepoints: 113.Pp 114.Bl -tag -width flag -offset indent -compact 115.It Cm c 116trace system calls 117.It Cm e 118trace emulation changes 119.It Cm i 120trace I/O 121.It Cm n 122trace namei translations 123.It Cm s 124trace signal processing 125.It Cm w 126trace context switch points 127.El 128.It Ar command 129Execute 130.Ar command 131with the specified trace flags. 132.El 133.Pp 134The 135.Fl p , 136.Fl g , 137and 138.Ar command 139options are mutually exclusive. 140.Sh FILES 141.Bl -tag -width ktrace.out -compact 142.It Pa ktrace.out 143default ktrace dump file 144.El 145.Sh EXAMPLES 146Trace all kernel operations of process ID 34: 147.Dl $ ktrace -p 34 148.Pp 149Trace all kernel operations of processes in process group 15 and 150pass the trace flags to all current and future children: 151.Dl $ ktrace -idg 15 152.Pp 153Disable all tracing of process 65: 154.Dl $ ktrace -cp 65 155.Pp 156Disable tracing signals on process 70 and all current children: 157.Dl $ ktrace -t s -cdp 70 158.Pp 159Enable tracing of I/O on process 67: 160.Dl $ ktrace -ti -p 67 161.Pp 162Run the command 163.Xr w 1 , 164tracing only system calls: 165.Dl $ ktrace -tc w 166.Pp 167Disable all tracing to the file "tracedata": 168.Dl $ ktrace -c -f tracedata 169.Pp 170Disable tracing of all processes owned by the user: 171.Dl $ ktrace -C 172.Sh SEE ALSO 173.Xr kdump 1 , 174.Xr ktrace 2 175.Sh HISTORY 176The 177.Nm ktrace 178command appeared in 179.Bx 4.4 . 180