1*44955Scael.\" Copyright (c) 1990 The Regents of the University of California. 2*44955Scael.\" All rights reserved. 3*44955Scael.\" 4*44955Scael.\" %sccs.include.redist.man% 5*44955Scael.\" 6*44955Scael.\" @(#)ktrace.1 1.3 (Berkeley) 07/24/90 7*44955Scael.\" 8*44955Scael.Dd 9*44955Scael.Dt KTRACE 1 10*44955Scael.Sh NAME 11*44955Scael.Nm ktrace 12*44955Scael.Nd enable kernel process tracing 13*44955Scael.Sh SYNOPSIS 14*44955Scael.Nm ktrace 15*44955Scael.Op Fl Cica 16*44955Scael.Op Fl p Ar pid 17*44955Scael.Op Fl g Ar pgrp 18*44955Scael.Op Fl f Ar trfile 19*44955Scael.Op Fl t Ar trstr 20*44955Scael.Nm ktrace 21*44955Scael.Op Fl ida 22*44955Scael.Op Fl f Ar trfile 23*44955Scael.Op command 24*44955Scael.Sh DESCRIPTION 25*44955Scael.Nm Ktrace 26*44955Scaelenables kernel trace logging for the specified processes. 27*44955ScaelKernel trace data is logged to the file 28*44955Scael.Sq Pa ktrace.out 29*44955Scaelin the 3037231Smarccurrent directory, or to the file named with the 31*44955Scael.Fl f 3237231Smarcflag. 33*44955ScaelThe current set of kernel operations that can be traced include: 34*44955Scaelsystem calls, namei translations, signal processing, and i/o. 35*44955ScaelBy default, all operations are 36*44955Scaeltraced. To restrict logging to specific operations, use the 37*44955Scael.Fl t 3837231Smarcflag as described below. Once tracing is enabled on a process, 3937231Smarctrace data will be logged until either the process exits or the 4037231Smarctrace point is cleared with the 41*44955Scael.Fl c 42*44955Scaelflag. A traced process can generate enormous amounts of log 43*44955Scaeldata quickly; compounded with the action of the inherit flag, 44*44955Scael.Fl i , 45*44955Scaeltracing can become unwieldly. 4644583SmarcIt is strongly suggested that the user memorize 4737231Smarchow to globally disable all tracing before attempting 4837231Smarcto trace a process. The following command is sufficient to 49*44955Scaeldisable tracing on all user owned processes 50*44955Scael(if root, all processes in the system): 51*44955Scael.Pp 52*44955Scael.Dl \&$ trace -C 53*44955Scael.Pp 54*44955ScaelThe 55*44955Scaeltrace file is binary format: use 56*44955Scael.Xr kdump 1 57*44955Scaelto decode it. 58*44955ScaelFollowing 59*44955Scaelis a description of the options: 60*44955Scael.Tw Ds 61*44955Scael.Tp Fl C 6237231SmarcDisable tracing on all user owned processes (if root, all processes in the 6337231Smarcsystem). 64*44955Scael.Tc Fl f 65*44955Scael.Ws 66*44955Scael.Ar trfile 67*44955Scael.Cx 68*44955ScaelLog trace records to 69*44955Scael.Ar trfile 70*44955Scaelinstead 71*44955Scaelof 72*44955Scael.Dq Pa trace.out . 73*44955Scael.Tc Fl t 74*44955Scael.Ws 75*44955Scael.Ar trstr 76*44955Scael.Cx 7737231SmarcThe string argument represents the kernel trace points, one 7837231Smarcper letter. The following table equates the letters with the tracepoints: 79*44955Scael.Dw Ds 80*44955Scael.Dp Cm c 81*44955Scaeltrace system calls 82*44955Scael.Dp Cm n 83*44955Scaeltrace namei translations 84*44955Scael.Dp Cm i 85*44955Scaeltrace I/O 86*44955Scael.Dp Cm s 87*44955Scaeltrace processing of signals 88*44955Scael.Dp 89*44955Scael.Tc Fl p 90*44955Scael.Ws 91*44955Scael.Ar pid 92*44955Scael.Cx 93*44955ScaelEnable (disable) tracing on the indicated process id (only one 94*44955Scael.Fl p 95*44955Scaelflag 96*44955Scaelallowed); 97*44955Scael.Tc Fl g 98*44955Scael.Ws 99*44955Scael.Ar pgid 100*44955Scael.Cx 10137231SmarcEnable (disable) tracing on all processes in the indicated 10237231Smarcprocess group. 103*44955Scael.Tp Fl a 10437231SmarcAppend to the tracefile instead of truncating it. 105*44955Scael.Tp Fl c 106*44955ScaelClear 107*44955Scaelthe indicated trace points. 108*44955Scael.Tp Fl i 10944583SmarcPass the trace flag to all future children of the 11044583Smarcdesignated processes. 111*44955Scael.Tp Fl I 11244583SmarcPass the trace flag to all current and future children of the 11344583Smarcdesignated processes. 114*44955Scael.Tp Ar command 115*44955ScaelRun 116*44955Scael.Ar command 117*44955Scaelwith the specified trace flags. 118*44955Scael.Tp 119*44955Scael.Pp 120*44955ScaelThe 121*44955Scael.Fl p , 122*44955Scael.Fl g , 123*44955Scaeland command options are mutually exclusive. 124*44955Scael.Sh EXAMPLES 125*44955Scael.Ds I 12644583Smarc# trace all kernel operations of process id 34 127*44955Scael.Dl $ ktrace -p34 12844583Smarc# trace all kernel operations of processes in process group 15 and 12937231Smarc# pass the trace flags to all current and future children 130*44955Scael.Dl $ ktrace -Ig15 13144583Smarc# disable all tracing of process 65 132*44955Scael.Dl $ ktrace -cp65 13344583Smarc# disable tracing signals on process 70 and all current children 134*44955Scael.Dl $ ktrace -ts -cip70 13544583Smarc# enable tracing of i/o on process 67 136*44955Scael.Dl $ ktrace -ti -p67 13744583Smarc# run the command "w", tracing only system calls 138*44955Scael.Dl $ ktrace -tc w 13937231Smarc# disable all tracing to the file "tracedata" 140*44955Scael.Dl $ ktrace -c -f tracedata 14144583Smarc# disable tracing of all processes owned by the user 142*44955Scael.Dl $ ktrace -C 143*44955Scael.De 144*44955Scael.Sh SEE ALSO 145*44955Scael.Xr kdump 1 14637231Smarc\- display kernel trace data. 147*44955Scael.Sh HISTORY 148*44955Scael4.4 BSD. 149