KTRACE(1)
π KTRACE(1) π
okay bestie, welcome to the KTRACE(1) page from the General Commands Manual β this one is all about peeking at kernel process tracing, and yes itβs giving main-character debugging energy. π¦β¨
πΈ NAME πΈ
ktrace β enable kernel process tracing π
β¨ SYNOPSIS β¨
ktrace [-aCcdi] [-f trfile] [-g pgrp | -p pid] [-t trstr]
ktrace [-adi] [-f trfile] [-t trstr] command
π DESCRIPTION π
okay so ktrace enables kernel trace logging for the specified processes. Kernel trace data is logged to the file ktrace.out. The kernel operations that are traced include system calls (see intro(2)), file system path lookups (namei(9)), signal processing (sigaction(2)), and I/O. π₯
Once tracing is enabled on a process, trace data will be logged until either the process exits or the trace point is cleared. A traced process can generate enormous amounts of log data quickly; It is strongly suggested that users memorize how to disable tracing before attempting to trace a process. not me starting a trace and forgetting how to stop it π The following command is sufficient to disable tracing on all user-owned processes, and, if executed by root, all processes:
$ ktrace -C
The trace file is not human readable; use kdump(1) to decode it. π
The utility may be used only with a kernel that has been built with the KTRACE option in the kernel configuration file.
The options are:
-aβ append to the trace file instead of recreating it. π«Ά-Cβ disable tracing on all user-owned processes, and, if executed by root, all processes in the system. π-cβ clear the specified trace points associated with the given file or processes.-dβ descendants; perform the operation for all current children of the designated processes. See also the-ioption. π§-f trfileβ log trace records to trfile instead ofktrace.out.-g pgidβ enable (disable) tracing on all processes in the process group (only one-gflag is permitted). π-iβ inherit; pass the trace flags to all future children of the designated processes. See also the-doption. π-p pidβ enable (disable) tracing on the indicated process id (only one-pflag is permitted). π-t trstrβ specify the list of trace points to enable or disable, one per letter. If an explicit list is not specified, the default set of trace points is used. π
The following trace points are supported:
cβ trace system callsfβ trace page faultsiβ trace I/Onβ tracenamei(9)translationspβ trace capability check failuressβ trace signal processingtβ trace various structures and arrays of structuresuβ userland traces generated byutrace(2)wβ context switchesyβ tracesysctl(3)requestsaβ traceexecve(2)argumentseβ traceexecve(2)environment variablesxβ traceexterr(2)extended errors reports from kernel+β trace the default set of trace points -a,c,e,i,n,s,t,u,x,y
commandβ execute command with the specified trace flags. π«
The -p, -g, and command options are mutually exclusive. no mixing and matching, bestie, thatβs the rule π«Ά
π₯ CAPABILITY VIOLATION TRACING π₯
When the p trace point is specified, ktrace will record capsicum(4) capability mode violations made by the traced process. Violations will be logged regardless of whether the process has actually entered capability mode. π
For developers that are interested in Capsicumizing their programs, the c, n, p trace points can help quickly identify any system calls and path lookups that are triggering violations. π§β¨
π EXAMPLES π
Run "make", then trace it and any child processes:
$ ktrace -i make
Trace all kernel operations of process id 34:
$ ktrace -p 34
Trace all kernel operations of processes in process group 15 and pass the trace flags to all current and future children:
$ ktrace -idg 15
Disable all tracing of process 65:
$ ktrace -cp 65
Disable tracing signals on process 70 and all current children:
$ ktrace -t s -cdp 70
Enable tracing of I/O on process 67:
$ ktrace -ti -p 67
Disable all tracing to the file "tracedata":
$ ktrace -c -f tracedata
Disable tracing of all user-owned processes:
$ ktrace -C
π SEE ALSO π
β HISTORY β
The ktrace command appeared in 4.4BSD. iconic behavior, honestly πΈ
π BUGS π
Only works if trfile is a regular file. thatβs the whole tea, bestie π
thatβs the whole page, bestie π«Ά β sourced from Debian, dated November 17, 2024, and filed under KTRACE(1). periodt. π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms