summaryrefslogtreecommitdiff
path: root/usr.bin/ktrace/ltrace.1
blob: a3e2dfe97e054601bbf01ecf83593163d932065d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
.\"	$OpenBSD: ltrace.1,v 1.7 2015/09/07 15:38:45 guenther Exp $
.\"
.\" Copyright (c) 2013 Miodrag Vallat.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Copyright (c) 1990, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	from: @(#)ktrace.1	8.1 (Berkeley) 6/6/93
.\"
.Dd $Mdocdate: September 7 2015 $
.Dt LTRACE 1
.Os
.Sh NAME
.Nm ltrace
.Nd shared library function call tracer
.Sh SYNOPSIS
.Nm ltrace
.Op Fl ai
.Op Fl f Ar trfile
.Op Fl t Ar trstr
.Op Fl u Ar trspec
.Ar command
.Sh DESCRIPTION
.Nm ltrace
enables shared library function calls issued by the specified processes
to be traced using the
.Xr utrace 2
user tracing facility.
By default, call trace data is logged to the file
.Pa ktrace.out ,
unless overridden by the
.Fl f
option.
Each function call is traced as a pair of
.Dv KTRFAC_USER
entries;
the first entry contains the shared library containing the symbol being
called, and the second entry contains the symbol name.
.Pp
Once tracing is enabled on a process, trace data will be logged until
either the process exits or the trace point is cleared with
.Xr ktrace 1 .
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.
The following command is sufficient to disable tracing on all user owned
processes and, if executed by root, all processes:
.Pp
.Dl $ ktrace -C
.Pp
The trace file is not human-readable; use
.Xr kdump 1
to decode it.
.Pp
The options are as follows:
.Bl -tag -width 9n
.It Fl a
Append to the trace file instead of recreating it.
.It Fl f Ar trfile
Log trace records to
.Ar trfile
instead of
.Pa ktrace.out .
.It Fl i
Inherit; pass the trace flags to all future children of the designated
processes.
.It Fl t Ar trstr
The string argument represents the kernel trace points, one per letter.
The default flags are
.Cm c ,
.Cm e ,
.Cm i ,
.Cm n ,
.Cm s ,
.Cm t ,
and
.Cm u .
The following table equates the letters with the tracepoints:
.Pp
.Bl -tag -width flag -offset indent -compact
.It Cm c
trace system calls
.It Cm e
trace emulation changes
.It Cm i
trace I/O
.It Cm n
trace namei translations
.It Cm s
trace signal processing
.It Cm t
trace various structures
.It Cm u
trace user data coming from
.Xr utrace 2
.It Cm +
trace the default points
.It Fl u Ar trspec
Restrict the trace to a list of shared objects and/or function names, as
specified by the
.Ar trspec
argument.
The trace specification is a comma-separated list of library names,
followed by a colon
.Pq :\& ,
and a comma-separated list of function names.
Each list can be empty.
Each list member may end with a star
.Pq *
to only match the beginning of a name.
An exclamation mark at the beginning of a list turns it into a rejection list,
causing all unmatched names to be traced.
Library names are compared without their version number and
.Sq .so
suffix.
.It Ar command
Execute
.Ar command
with the specified trace flags.
.El
.Sh FILES
.Bl -tag -width ktrace.outXXX -compact
.It Pa ktrace.out
Default
.Nm
dump file.
.El
.Sh EXAMPLES
Trace all shared library function calls from
.Xr wc 1
reading the message of the day:
.Dl $ ltrace wc -lh /etc/motd
.Pp
Trace only the shared library function calls in
.Pa libutil.so :
.Dl $ ltrace -u libutil wc -lh /etc/motd
.Pp
Trace all the shared library function calls but those in
.Pa libc.so :
.Dl $ ltrace -u \(dq!libc\(dq wc -lh /etc/motd
.Pp
Trace all the shared library function calls with names starting
.Qq fmt :
.Dl $ ltrace -u \(dq:fmt*\(dq wc -lh /etc/motd
.Pp
Trace all shared library function calls, as well as all system calls:
.Dl $ ltrace -t cu wc -lh /etc/motd
.Sh SEE ALSO
.Xr kdump 1 ,
.Xr ktrace 1 ,
.Xr ktrace 2 ,
.Xr utrace 2
.Sh HISTORY
The
.Nm ltrace
command appeared in
.Ox 5.4 .