]>
Commit | Line | Data |
---|---|---|
9bccf70c A |
1 | .\" Copyright (c) 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
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. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
32 | .\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93 | |
33 | .\" $FreeBSD: src/lib/libc/sys/ktrace.2,v 1.9.2.7 2001/12/14 18:34:01 ru Exp $ | |
34 | .\" | |
35 | .Dd June 4, 1993 | |
36 | .Dt KTRACE 2 | |
37 | .Os | |
38 | .Sh NAME | |
39 | .Nm ktrace | |
40 | .Nd process tracing | |
41 | .Sh LIBRARY | |
42 | .Lb libc | |
43 | .Sh SYNOPSIS | |
44 | .In sys/param.h | |
45 | .In sys/time.h | |
46 | .In sys/uio.h | |
47 | .In sys/ktrace.h | |
48 | .Ft int | |
49 | .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid" | |
50 | .Sh DESCRIPTION | |
51 | The | |
52 | .Fn ktrace | |
53 | function enables or disables tracing of one or more processes. | |
54 | Users may only trace their own processes. | |
55 | Only the super-user can trace setuid or setgid programs. | |
56 | .Pp | |
57 | The | |
58 | .Fa tracefile | |
59 | gives the pathname of the file to be used for tracing. | |
60 | The file must exist and be a regular file writable by the calling process. | |
61 | All trace records are always appended to the file, | |
62 | so the file must be truncated to zero length to discard | |
63 | previous trace data. | |
64 | If tracing points are being disabled (see KTROP_CLEAR below), | |
65 | .Fa tracefile | |
66 | may be NULL. | |
67 | .Pp | |
68 | The | |
69 | .Fa ops | |
70 | parameter specifies the requested ktrace operation. | |
71 | The defined operations are: | |
72 | .Bl -column KTRFLAG_DESCENDXXX -offset indent | |
73 | .It "KTROP_SET Enable trace points specified in" | |
74 | .Fa trpoints . | |
75 | .It "KTROP_CLEAR Disable trace points specified in | |
76 | .Fa trpoints . | |
77 | .It "KTROP_CLEARFILE Stop all tracing." | |
78 | .It "KTRFLAG_DESCEND The tracing change should apply to the" | |
79 | specified process and all its current children. | |
80 | .El | |
81 | .Pp | |
82 | The | |
83 | .Fa trpoints | |
84 | parameter specifies the trace points of interest. | |
85 | The defined trace points are: | |
86 | .Bl -column KTRFAC_SYSCALLXXX -offset indent | |
87 | .It "KTRFAC_SYSCALL Trace system calls." | |
88 | .It "KTRFAC_SYSRET Trace return values from system calls." | |
89 | .It "KTRFAC_NAMEI Trace name lookup operations." | |
90 | .It "KTRFAC_GENIO Trace all I/O (note that this option can" | |
91 | generate much output). | |
92 | .It "KTRFAC_PSIG Trace posted signals." | |
93 | .It "KTRFAC_CSW Trace context switch points." | |
94 | .It "KTRFAC_INHERIT Inherit tracing to future children." | |
95 | .El | |
96 | .Pp | |
97 | Each tracing event outputs a record composed of a generic header | |
98 | followed by a trace point specific structure. | |
99 | The generic header is: | |
100 | .Bd -literal | |
101 | struct ktr_header { | |
102 | int ktr_len; /* length of buf */ | |
103 | short ktr_type; /* trace record type */ | |
104 | pid_t ktr_pid; /* process id */ | |
105 | char ktr_comm[MAXCOMLEN+1]; /* command name */ | |
106 | struct timeval ktr_time; /* timestamp */ | |
107 | caddr_t ktr_buf; | |
108 | }; | |
109 | .Ed | |
110 | .Pp | |
111 | The | |
112 | .Va ktr_len | |
113 | field specifies the length of the | |
114 | .Va ktr_type | |
115 | data that follows this header. | |
116 | The | |
117 | .Va ktr_pid | |
118 | and | |
119 | .Va ktr_comm | |
120 | fields specify the process and command generating the record. | |
121 | The | |
122 | .Va ktr_time | |
123 | field gives the time (with microsecond resolution) | |
124 | that the record was generated. | |
125 | The | |
126 | .Va ktr_buf | |
127 | is an internal kernel pointer and is not useful. | |
128 | .Pp | |
129 | The generic header is followed by | |
130 | .Va ktr_len | |
131 | bytes of a | |
132 | .Va ktr_type | |
133 | record. | |
134 | The type specific records are defined in the | |
135 | .Aq Pa sys/ktrace.h | |
136 | include file. | |
137 | .Sh RETURN VALUES | |
138 | .Rv -std ktrace | |
139 | .Sh ERRORS | |
140 | .Fn Ktrace | |
141 | will fail if: | |
142 | .Bl -tag -width Er | |
143 | .It Bq Er ENOTDIR | |
144 | A component of the path prefix is not a directory. | |
145 | .It Bq Er ENAMETOOLONG | |
146 | A component of a pathname exceeded 255 characters, | |
147 | or an entire path name exceeded 1023 characters. | |
148 | .It Bq Er ENOENT | |
149 | The named tracefile does not exist. | |
150 | .It Bq Er EACCES | |
151 | Search permission is denied for a component of the path prefix. | |
152 | .It Bq Er ELOOP | |
153 | Too many symbolic links were encountered in translating the pathname. | |
154 | .It Bq Er EIO | |
155 | An I/O error occurred while reading from or writing to the file system. | |
156 | .It Bq Er ENOSYS | |
157 | The kernel was not compiled with | |
158 | .Nm | |
159 | support. | |
160 | .El | |
161 | .Sh SEE ALSO | |
162 | .Xr kdump 1 , | |
163 | .Xr ktrace 1 | |
164 | .Sh HISTORY | |
165 | A | |
166 | .Fn ktrace | |
167 | function call first appeared in | |
168 | .Bx 4.4 . |