19b50d902SRodney W. Grimes.\" Copyright (c) 1990, 1993 29b50d902SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 39b50d902SRodney W. Grimes.\" 49b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 59b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions 69b50d902SRodney W. Grimes.\" are met: 79b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 89b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 99b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 109b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 119b50d902SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 139b50d902SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 149b50d902SRodney W. Grimes.\" without specific prior written permission. 159b50d902SRodney W. Grimes.\" 169b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 179b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 189b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 199b50d902SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 209b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 219b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 229b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 239b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 249b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 259b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 269b50d902SRodney W. Grimes.\" SUCH DAMAGE. 279b50d902SRodney W. Grimes.\" 289b50d902SRodney W. Grimes.\" @(#)ktrace.1 8.1 (Berkeley) 6/6/93 29c3aac50fSPeter Wemm.\" $FreeBSD$ 309b50d902SRodney W. Grimes.\" 31c5ed2864SEdward Tomasz Napierala.Dd July 24, 2017 329b50d902SRodney W. Grimes.Dt KTRACE 1 3362500372SRuslan Ermilov.Os 349b50d902SRodney W. Grimes.Sh NAME 359b50d902SRodney W. Grimes.Nm ktrace 369b50d902SRodney W. Grimes.Nd enable kernel process tracing 379b50d902SRodney W. Grimes.Sh SYNOPSIS 388fe908efSRuslan Ermilov.Nm 399b50d902SRodney W. Grimes.Op Fl aCcdi 409b50d902SRodney W. Grimes.Op Fl f Ar trfile 4124b9685cSMike Heffner.Op Fl g Ar pgrp | Fl p Ar pid 42da647ae9SRuslan Ermilov.Op Fl t Ar trstr 438fe908efSRuslan Ermilov.Nm 449b50d902SRodney W. Grimes.Op Fl adi 459b50d902SRodney W. Grimes.Op Fl f Ar trfile 46da647ae9SRuslan Ermilov.Op Fl t Ar trstr 4733f69855SRuslan Ermilov.Ar command 489b50d902SRodney W. Grimes.Sh DESCRIPTION 4993e0d62dSJohn-Mark GurneyThe 5093e0d62dSJohn-Mark Gurney.Nm 51e8937ba0SPhilippe Charnierutility enables kernel trace logging for the specified processes. 529b50d902SRodney W. GrimesKernel trace data is logged to the file 539b50d902SRodney W. Grimes.Pa ktrace.out . 549b50d902SRodney W. GrimesThe kernel operations that are traced include system calls, namei 559b50d902SRodney W. Grimestranslations, signal processing, and 569b50d902SRodney W. Grimes.Tn I/O . 579b50d902SRodney W. Grimes.Pp 589b50d902SRodney W. GrimesOnce tracing is enabled on a process, trace data will be logged until 599b50d902SRodney W. Grimeseither the process exits or the trace point is cleared. 609b50d902SRodney W. GrimesA traced process can generate enormous amounts of log data quickly; 619b50d902SRodney W. GrimesIt is strongly suggested that users memorize how to disable tracing before 629b50d902SRodney W. Grimesattempting to trace a process. 63df449c35STom RhodesThe following command is sufficient to disable tracing on all user-owned 649b50d902SRodney W. Grimesprocesses, and, if executed by root, all processes: 659b50d902SRodney W. Grimes.Pp 6616964daeSPeter Wemm.Dl \&$ ktrace -C 679b50d902SRodney W. Grimes.Pp 689b50d902SRodney W. GrimesThe trace file is not human readable; use 699b50d902SRodney W. Grimes.Xr kdump 1 709b50d902SRodney W. Grimesto decode it. 719b50d902SRodney W. Grimes.Pp 72df449c35STom RhodesThe utility may be used only with a kernel that has been built with the 73df449c35STom Rhodes.Dq KTRACE 74df449c35STom Rhodesoption in the kernel configuration file. 75df449c35STom Rhodes.Pp 76df449c35STom RhodesThe options are: 779b50d902SRodney W. Grimes.Bl -tag -width indent 789b50d902SRodney W. Grimes.It Fl a 799bedbe6cSJoerg WunschAppend to the trace file instead of recreating it. 809b50d902SRodney W. Grimes.It Fl C 81df449c35STom RhodesDisable tracing on all user-owned processes, and, if executed by root, all 829b50d902SRodney W. Grimesprocesses in the system. 839b50d902SRodney W. Grimes.It Fl c 840b976534SJohn BaldwinClear the specified trace points associated with the given file or processes. 859b50d902SRodney W. Grimes.It Fl d 869b50d902SRodney W. GrimesDescendants; perform the operation for all current children of the 879b50d902SRodney W. Grimesdesignated processes. 88*6e5f5f90SEdward Tomasz NapieralaSee also the 89*6e5f5f90SEdward Tomasz Napierala.Fl i 90*6e5f5f90SEdward Tomasz Napieralaoption. 91943c2638SGiorgos Keramidas.It Fl f Ar trfile 929b50d902SRodney W. GrimesLog trace records to 93943c2638SGiorgos Keramidas.Ar trfile 949b50d902SRodney W. Grimesinstead of 959b50d902SRodney W. Grimes.Pa ktrace.out . 969b50d902SRodney W. Grimes.It Fl g Ar pgid 979b50d902SRodney W. GrimesEnable (disable) tracing on all processes in the process group (only one 989b50d902SRodney W. Grimes.Fl g 999b50d902SRodney W. Grimesflag is permitted). 1009b50d902SRodney W. Grimes.It Fl i 1019b50d902SRodney W. GrimesInherit; pass the trace flags to all future children of the designated 1029b50d902SRodney W. Grimesprocesses. 103*6e5f5f90SEdward Tomasz NapieralaSee also the 104*6e5f5f90SEdward Tomasz Napierala.Fl d 105*6e5f5f90SEdward Tomasz Napieralaoption. 1069b50d902SRodney W. Grimes.It Fl p Ar pid 1079b50d902SRodney W. GrimesEnable (disable) tracing on the indicated process id (only one 1089b50d902SRodney W. Grimes.Fl p 1099b50d902SRodney W. Grimesflag is permitted). 110da647ae9SRuslan Ermilov.It Fl t Ar trstr 1110b976534SJohn BaldwinSpecify the list of trace points to enable or disable, one per letter. 1120b976534SJohn BaldwinIf an explicit list is not specified, the default set of trace points is used. 1130b976534SJohn Baldwin.Pp 1140b976534SJohn BaldwinThe following trace points are supported: 1159b50d902SRodney W. Grimes.Pp 1169b50d902SRodney W. Grimes.Bl -tag -width flag -compact 1179b50d902SRodney W. Grimes.It Cm c 1189b50d902SRodney W. Grimestrace system calls 11935818d2eSJohn Baldwin.It Cm f 12035818d2eSJohn Baldwintrace page faults 1219b50d902SRodney W. Grimes.It Cm i 1229b50d902SRodney W. Grimestrace 1239b50d902SRodney W. Grimes.Tn I/O 124d4523bd9SJohn Baldwin.It Cm n 125d4523bd9SJohn Baldwintrace namei translations 126c601ad8eSDag-Erling Smørgrav.It Cm p 127c601ad8eSDag-Erling Smørgravtrace capability check failures 1289b50d902SRodney W. Grimes.It Cm s 1299b50d902SRodney W. Grimestrace signal processing 13060e15db9SDag-Erling Smørgrav.It Cm t 13160e15db9SDag-Erling Smørgravtrace various structures 13209ac2438SPoul-Henning Kamp.It Cm u 13309ac2438SPoul-Henning Kampuserland traces 13409ac2438SPoul-Henning Kamp.It Cm w 13509ac2438SPoul-Henning Kampcontext switches 136a56be37eSJohn Baldwin.It Cm y 137a56be37eSJohn Baldwintrace 138a56be37eSJohn Baldwin.Xr sysctl 3 139a56be37eSJohn Baldwinrequests 140fef3edecSPeter Pentchev.It Cm + 141fef3edecSPeter Pentchevtrace the default set of trace points - 1425c506fb0SJohn Baldwin.Cm c , i , n , p , s , t , u , y 1439b50d902SRodney W. Grimes.El 1449b50d902SRodney W. Grimes.It Ar command 1459b50d902SRodney W. GrimesExecute 1469b50d902SRodney W. Grimes.Ar command 1479b50d902SRodney W. Grimeswith the specified trace flags. 1489b50d902SRodney W. Grimes.El 1499b50d902SRodney W. Grimes.Pp 1509b50d902SRodney W. GrimesThe 1519b50d902SRodney W. Grimes.Fl p , 1529b50d902SRodney W. Grimes.Fl g , 1539b50d902SRodney W. Grimesand 1549b50d902SRodney W. Grimes.Ar command 1559b50d902SRodney W. Grimesoptions are mutually exclusive. 1569b50d902SRodney W. Grimes.Sh EXAMPLES 157*6e5f5f90SEdward Tomasz NapieralaRun "make", then trace it and any child processes: 158*6e5f5f90SEdward Tomasz Napierala.Dl $ ktrace -i make 159*6e5f5f90SEdward Tomasz Napierala.Pp 160c5ed2864SEdward Tomasz NapieralaTrace all kernel operations of process id 34: 1619b50d902SRodney W. Grimes.Dl $ ktrace -p 34 1629b50d902SRodney W. Grimes.Pp 163c5ed2864SEdward Tomasz NapieralaTrace all kernel operations of processes in process group 15 and 164c5ed2864SEdward Tomasz Napieralapass the trace flags to all current and future children: 1659b50d902SRodney W. Grimes.Dl $ ktrace -idg 15 1669b50d902SRodney W. Grimes.Pp 167c5ed2864SEdward Tomasz NapieralaDisable all tracing of process 65: 1689b50d902SRodney W. Grimes.Dl $ ktrace -cp 65 1699b50d902SRodney W. Grimes.Pp 170c5ed2864SEdward Tomasz NapieralaDisable tracing signals on process 70 and all current children: 1719b50d902SRodney W. Grimes.Dl $ ktrace -t s -cdp 70 1729b50d902SRodney W. Grimes.Pp 173c5ed2864SEdward Tomasz NapieralaEnable tracing of 1749b50d902SRodney W. Grimes.Tn I/O 175c5ed2864SEdward Tomasz Napieralaon process 67: 1769b50d902SRodney W. Grimes.Dl $ ktrace -ti -p 67 1779b50d902SRodney W. Grimes.Pp 178c5ed2864SEdward Tomasz NapieralaDisable all tracing to the file "tracedata": 1799b50d902SRodney W. Grimes.Dl $ ktrace -c -f tracedata 1809b50d902SRodney W. Grimes.Pp 181c5ed2864SEdward Tomasz NapieralaDisable tracing of all user-owned processes: 1829b50d902SRodney W. Grimes.Dl $ ktrace -C 1839b50d902SRodney W. Grimes.Sh SEE ALSO 184*6e5f5f90SEdward Tomasz Napierala.Xr dtrace 1 , 185f4864c27SBrooks Davis.Xr kdump 1 , 186*6e5f5f90SEdward Tomasz Napierala.Xr truss 1 , 187f4864c27SBrooks Davis.Xr ktrace 2 1889b50d902SRodney W. Grimes.Sh HISTORY 1899b50d902SRodney W. GrimesThe 19093e0d62dSJohn-Mark Gurney.Nm 19193e0d62dSJohn-Mark Gurneycommand appeared in 1929b50d902SRodney W. Grimes.Bx 4.4 . 1936c7216dfSRuslan Ermilov.Sh BUGS 1946c7216dfSRuslan ErmilovOnly works if 1956c7216dfSRuslan Ermilov.Ar trfile 1966c7216dfSRuslan Ermilovis a regular file. 197