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 .\" 3. 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
29 .\" $FreeBSD: src/lib/libc/sys/ktrace.2,v 1.9.2.7 2001/12/14 18:34:01 ru Exp $
44 .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid"
48 function enables or disables tracing of one or more processes.
49 Users may only trace their own processes.
50 By default only the super-user can trace setuid or setgid programs.
51 This restriction can be removed by setting the sysctl
57 gives the pathname of the file to be used for tracing.
58 The file must exist and be a regular file writable by the calling process.
59 All trace records are always appended to the file,
60 so the file must be truncated to zero length to discard
62 If tracing points are being disabled (see
70 parameter specifies the requested ktrace operation.
71 The defined operations are:
73 .Bl -tag -width KTRFAC_SYSCALLXXXXXX -compact -offset indent
75 Enable trace points specified in
78 Disable trace points specified in
80 .It Dv KTROP_CLEARFILE
82 .It Dv KTRFLAG_DESCEND
83 The tracing change should apply to the
84 specified process and all its current children.
89 parameter specifies the trace points of interest.
90 The defined trace points are:
92 .Bl -tag -width KTRFAC_SYSCALLXXXXXX -compact -offset indent
96 Trace return values from system calls.
98 Trace name lookup operations.
100 Trace all I/O (note that this option can
101 generate much output).
103 Trace posted signals.
105 Trace context switch points.
108 .It Dv KTRFAC_INHERIT
109 Inherit tracing to future children.
112 Each tracing event outputs a record composed of a generic header
113 followed by a trace point specific structure.
114 The generic header is:
117 int ktr_len; /* length of buf */
118 short ktr_type; /* trace record type */
119 pid_t ktr_pid; /* process id */
120 char ktr_comm[MAXCOMLEN+1]; /* command name */
121 struct timeval ktr_time; /* timestamp */
128 field specifies the length of the
130 data that follows this header.
135 fields specify the process and command generating the record.
138 field gives the time (with microsecond resolution)
139 that the record was generated.
142 is an internal kernel pointer and is not useful.
144 The generic header is followed by
149 The type specific records are defined in the
160 A component of the path prefix is not a directory.
161 .It Bq Er ENAMETOOLONG
162 A component of a pathname exceeded 255 characters,
163 or an entire path name exceeded 1023 characters.
165 The named tracefile does not exist.
167 Search permission is denied for a component of the path prefix.
169 Too many symbolic links were encountered in translating the pathname.
171 An I/O error occurred while reading from or writing to the file system.
173 The kernel was not compiled with
185 function call first appeared in