Imported Upstream version 0.7.2
[platform/upstream/ltrace.git] / ltrace.1
1 .\" -*-nroff-*-
2 .\" Copyright (c) 2012 Petr Machata, Red Hat Inc.
3 .\" Copyright (c) 1997-2005 Juan Cespedes <cespedes@debian.org>
4 .\"
5 .\" This program is free software; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of the
8 .\" License, or (at your option) any later version.
9 .\"
10 .\" This program is distributed in the hope that it will be useful, but
11 .\" WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 .\" General Public License for more details.
14 .\"
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program; if not, write to the Free Software
17 .\" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 .\" 02110-1301 USA
19 .\"
20 .TH LTRACE "1" "October 2012" "" "User Commands"
21 .SH NAME
22 ltrace \- A library call tracer
23
24 .SH SYNOPSIS
25 .B ltrace
26 .I "[-bCfghiLrStttV] [-a column] [-A maxelts] [-D level] [-e expr] [-l library_pattern] [-n nr] [-o filename] [-p pid] ... [-s strsize] [-u username] [-w count] [-x extern] ... [--align=column] [--debug=level] [--demangle] [--help] [--indent=nr] [--library=library_pattern] [--no-signals] [--output=filename] [--version] [--where=NR] [command [arg ...]]"
27
28 .SH DESCRIPTION
29 .B ltrace
30 is a program that simply runs the specified
31 .I command
32 until it exits.  It intercepts and records the dynamic library calls
33 which are called by the executed process and the signals which are
34 received by that process.
35 It can also intercept and print the system calls executed by the program.
36 .PP
37 Its use is very similar to
38 .BR strace(1) .
39
40 .SH OPTIONS
41 .TP
42 .I \-a, \-\-align column
43 Align return values in a specific
44 .IR column
45 (default column is 5/8 of screen width).
46 .TP
47 .I \-A maxelts
48 Maximum number of array elements to print before suppressing the rest
49 with an ellipsis ("...").  This also limits number of recursive
50 structure expansions.
51 .TP
52 .I \-b, \-\-no-signals
53 Disable printing of signals recieved by the traced process.
54 .TP
55 .I \-c
56 Count time and calls for each library call and report a summary on program exit.
57 .TP
58 .I \-C, \-\-demangle
59 Decode (demangle) low-level symbol names into user-level names.
60 Besides removing any initial underscore prefix used by the system,
61 this makes C++ function names readable.
62 .TP
63 .I \-D, \-\-debug level
64 Show debugging output of
65 .B ltrace
66 itself.
67 .I level
68 must be a sum of some of the following numbers:
69 .RS
70 .TP
71 .B 01
72 DEBUG_GENERAL.  Shows helpful progress information
73 .TP
74 .B 010
75 DEBUG_EVENT.  Shows every event received by a traced program
76 .TP
77 .B 020
78 DEBUG_PROCESS.  Shows every action
79 .B ltrace
80 carries upon a traced process
81 .TP
82 .B 040
83 DEBUG_FUNCTION.  Shows every entry to internal functions
84 .RE
85 .TP
86 .I \-e filter
87 A qualifying expression which modifies which library calls to trace.
88 The format of the filter expression is described in the section
89 \fBFILTER EXPRESSIONS\fR.  If more than one \-e option appears on the
90 command line, the library calls that match any of them are traced.  If
91 no \-e is given, \fB@MAIN\fR is assumed as a default.
92 .TP
93 .I \-f
94 Trace child processes as they are created by
95 currently traced processes as a result of the fork(2)
96 or clone(2) system calls.
97 The new process is attached immediately.
98 .TP
99 .I \-F
100 Load an alternate config file. Normally, /etc/ltrace.conf and
101 ~/.ltrace.conf will be read (the latter only if it exists).
102 Use this option to load the given file or files instead of
103 those two default files.
104 .TP
105 .I \-h, \-\-help
106 Show a summary of the options to ltrace and exit.
107 .TP
108 .I \-i
109 Print the instruction pointer at the time of the library call.
110 .TP
111 .I \-l, \-\-library library_pattern
112 Display only calls to functions implemented by libraries that match
113 .I library_pattern.
114 Multiple library patters can be specified with several instances of
115 this option.  Syntax of library_pattern is described in section
116 \fBFILTER EXPRESSIONS\fR.
117
118 Note that while this option selects calls that might be directed to
119 the selected libraries, there's no actual guarantee that the call
120 won't be directed elsewhere due to e.g. LD_PRELOAD or simply
121 dependency ordering.  If you want to make sure that symbols in given
122 library are actually called, use \fB-x @\fIlibrary_pattern\fR instead.
123 .TP
124 .I \-L
125 When no -e option is given, don't assume the default action of
126 \fB@MAIN\fR.
127 .TP
128 .I \-n, \-\-indent nr
129 Indent trace output by
130 .I nr
131 number of spaces for each new nested call. Using this option makes
132 the program flow visualization easy to follow.
133 .TP
134 .I \-o, \-\-output filename
135 Write the trace output to the file
136 .I filename
137 rather than to stderr.
138 .TP
139 .I \-p pid
140 Attach to the process with the process ID
141 .I pid
142 and begin tracing.
143 .TP
144 .I \-r
145 Print a relative timestamp with each line of the trace.
146 This records the time difference between the beginning of
147 successive lines.
148 .TP
149 .I \-s strsize
150 Specify the maximum string size to print (the default is 32).
151 .TP
152 .I \-S
153 Display system calls as well as library calls
154 .TP
155 .I \-t
156 Prefix each line of the trace with the time of day.
157 .TP
158 .I \-tt
159 If given twice, the time printed will include the microseconds.
160 .TP
161 .I \-ttt
162 If given thrice, the time printed will include the microseconds and
163 the leading portion will be printed as the number of seconds since the
164 epoch.
165 .TP
166 .I \-T
167 Show  the  time  spent inside each call. This records the time difference
168 between the beginning and the end of each call.
169 .TP
170 .I \-u username
171 Run command with the userid, groupid and supplementary groups of
172 .IR username .
173 This option is only useful when running as root and enables the
174 correct execution of setuid and/or setgid binaries.
175 .TP
176 .I \-w, --where NR
177 Show backtrace of NR stack frames for each traced function. This option enabled
178 only if libunwind support was enabled at compile time.
179 .TP
180 .I \-x filter
181 A qualifying expression which modifies which symbol table entry points
182 to trace.  The format of the filter expression is described in the
183 section \fBFILTER EXPRESSIONS\fR.  If more than one \-x option appears
184 on the command line, the symbols that match any of them are traced.
185 No entry points are traced if no \-x is given.
186 .TP
187 .I \-V, \-\-version
188 Show the version number of ltrace and exit.
189
190 .SH FILTER EXPRESSIONS
191
192 Filter expression is a chain of glob- or regexp-based rules that are
193 used to pick symbols for tracing from libraries that the process uses.
194 Most of it is intuitive, so as an example, the following would trace
195 calls to malloc and free, except those done by libc:
196
197 -e malloc+free-@libc.so*
198
199 This reads: trace malloc and free, but don't trace anything that comes
200 from libc.  Semi-formally, the syntax of the above example looks
201 approximately like this:
202
203 {[+-][\fIsymbol_pattern\fR][@\fIlibrary_pattern\fR]}
204
205 \fISymbol_pattern\fR is used to match symbol names,
206 \fIlibrary_pattern\fR to match library SONAMEs.  Both are implicitly
207 globs, but can be regular expressions as well (see below).  The glob
208 syntax supports meta-characters \fB*\fR and \fB?\fR and character
209 classes, similarly to what basic bash globs support.  \fB^\fR and
210 \fB$\fR are recognized to mean, respectively, start and end of given
211 name.
212
213 Both \fIsymbol_pattern\fR and \fIlibrary_pattern\fR have to match the
214 whole name.  If you want to match only part of the name, surround it
215 with one or two *'s as appropriate.  The exception is if the pattern
216 is not mentioned at all, in which case it's as if the corresponding
217 pattern were \fB*\fR.  (So \fBmalloc\fR is really \fBmalloc@*\fR and
218 \fB@libc.*\fR is really \fB*@libc.*\fR.)
219
220 In libraries that don't have an explicit SONAME, basename is taken for
221 SONAME.  That holds for main binary as well: \fB/bin/echo\fR has an
222 implicit SONAME of \fBecho\fR.  In addition to that, special library
223 pattern \fBMAIN\fR always matches symbols in the main binary and never
224 a library with actual SONAME \fBMAIN\fR (use e.g. \fB^MAIN\fR or
225 \fB[M]AIN\fR for that).
226
227 If the symbol or library pattern is surrounded in slashes (/like
228 this/), then it is considered a regular expression instead.  As a
229 shorthand, instead of writing \fB/x/@/y/\fR, you can write
230 \fB/x@y/\fR.
231
232 If the library pattern starts with a slash, it is not a SONAME
233 expression, but a path expression, and is matched against the library
234 path name.
235
236 The first rule may lack a sign, in which case \fB+\fR is assumed.  If,
237 on the other hand, the first rule has a \fB-\fR sign, it is as if
238 there was another rule \fB@*\fR in front of it.
239
240 The above rules are used to construct the set of traced symbols.  Each
241 candidate symbol is passed through the chain of above rules.
242 Initially, the symbol is \fIunmarked\fR.  If it matches a \fB+\fR
243 rule, it becomes \fImarked\fR, if it matches a \fB-\fR rule, it
244 becomes \fIunmarked\fR again.  If, after applying all rules, the
245 symbol is \fImarked\fR, it will be traced.
246
247 .SH BUGS
248 It has most of the bugs stated in
249 .BR strace(1) .
250 .LP
251 It only works on Linux and in a small subset of architectures.
252 .LP
253 .PP
254 If you would like to report a bug, send a message to the mailing list
255 (ltrace-devel@lists.alioth.debian.org), or use the
256 .BR reportbug(1)
257 program if you are under the Debian GNU/Linux distribution.
258
259 .SH FILES
260 .TP
261 .I /etc/ltrace.conf
262 System configuration file
263 .TP
264 .I ~/.ltrace.conf
265 Personal config file, overrides
266 .I /etc/ltrace.conf
267
268 .SH AUTHOR
269 Juan Cespedes <cespedes@debian.org>
270 .br
271 Petr Machata <pmachata@redhat.com>
272
273 .SH "SEE ALSO"
274 .BR ltrace.conf(5),
275 .BR strace(1) ,
276 .BR ptrace(2)