2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93
45 .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid"
49 system call enables or disables tracing of one or more processes.
50 Users may only trace their own processes.
51 Only the super-user can trace setuid or setgid programs.
56 gives the pathname of the file to be used for tracing.
57 The file must exist and be a regular file writable by the calling process.
58 All trace records are always appended to the file,
59 so the file must be truncated to zero length to discard
61 If tracing points are being disabled (see KTROP_CLEAR below),
67 argument specifies the requested ktrace operation.
68 The defined operations are:
69 .Bl -column KTRFLAG_DESCENDXXX -offset indent
70 .It "KTROP_SET Enable trace points specified in"
72 .It "KTROP_CLEAR Disable trace points specified in"
74 .It "KTROP_CLEARFILE Stop all tracing."
75 .It "KTRFLAG_DESCEND The tracing change should apply to the"
76 specified process and all its current children.
81 argument specifies the trace points of interest.
82 The defined trace points are:
83 .Bl -column KTRFAC_PROCCTORXXX -offset indent
84 .It "KTRFAC_SYSCALL Trace system calls."
85 .It "KTRFAC_SYSRET Trace return values from system calls."
86 .It "KTRFAC_NAMEI Trace name lookup operations."
87 .It "KTRFAC_GENIO Trace all I/O (note that this option can"
88 generate much output).
89 .It "KTRFAC_PSIG Trace posted signals."
90 .It "KTRFAC_CSW Trace context switch points."
91 .It "KTRFAC_USER Trace application-specific events."
92 .It "KTRFAC_STRUCT Trace certain data structures."
93 .It "KTRFAC_SYSCTL Trace sysctls."
94 .It "KTRFAC_PROCCTOR Trace process construction."
95 .It "KTRFAC_PROCDTOR Trace process destruction."
96 .It "KTRFAC_CAPFAIL Trace capability failures."
97 .It "KTRFAC_INHERIT Inherit tracing to future children."
100 Each tracing event outputs a record composed of a generic header
101 followed by a trace point specific structure.
102 The generic header is:
105 int ktr_len; /* length of buf */
106 short ktr_type; /* trace record type */
107 pid_t ktr_pid; /* process id */
108 char ktr_comm[MAXCOMLEN+1]; /* command name */
109 struct timeval ktr_time; /* timestamp */
110 intptr_t ktr_tid; /* was ktr_buffer */
116 field specifies the length of the
118 data that follows this header.
123 fields specify the process and command generating the record.
126 field gives the time (with microsecond resolution)
127 that the record was generated.
130 field holds a threadid.
132 The generic header is followed by
137 The type specific records are defined in the
143 tunables influence the behaviour of
145 .Bl -tag -width indent
146 .It Va kern.ktrace.geniosize
147 bounds the amount of data a traced I/O request will log
149 .It Va kern.ktrace.request_pool
150 bounds the number of trace events being logged at a time.
153 Sysctl tunables that control process debuggability (as determined by
155 also affect the operation of
166 A component of the path prefix is not a directory.
167 .It Bq Er ENAMETOOLONG
168 A component of a pathname exceeded 255 characters,
169 or an entire path name exceeded 1023 characters.
171 The named tracefile does not exist.
173 Search permission is denied for a component of the path prefix.
175 Too many symbolic links were encountered in translating the pathname.
177 An I/O error occurred while reading from or writing to the file system.
179 The kernel was not compiled with
184 A thread may be unable to log one or more tracing events due to a
185 temporary shortage of resources.
186 This condition is remembered by the kernel, and the next tracing request
187 that succeeds will have the flag
201 system call first appeared in