2 .\" Copyright (c) 2012 Petr Machata, Red Hat Inc.
3 .\" Copyright (c) 1997-2005 Juan Cespedes <cespedes@debian.org>
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.
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.
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
20 .TH LTRACE "1" "October 2012" "" "User Commands"
22 ltrace \- A library call tracer
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 ...]]"
30 is a program that simply runs the specified
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.
37 Its use is very similar to
42 .I \-a, \-\-align column
43 Align return values in a specific
45 (default column is 5/8 of screen width).
48 Maximum number of array elements to print before suppressing the rest
49 with an ellipsis ("..."). This also limits number of recursive
52 .I \-b, \-\-no-signals
53 Disable printing of signals recieved by the traced process.
56 Count time and calls for each library call and report a summary on program exit.
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.
63 .I \-D, \-\-debug level
64 Show debugging output of
68 must be a sum of some of the following numbers:
72 DEBUG_GENERAL. Shows helpful progress information
75 DEBUG_EVENT. Shows every event received by a traced program
78 DEBUG_PROCESS. Shows every action
80 carries upon a traced process
83 DEBUG_FUNCTION. Shows every entry to internal functions
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.
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.
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.
106 Show a summary of the options to ltrace and exit.
109 Print the instruction pointer at the time of the library call.
111 .I \-l, \-\-library library_pattern
112 Display only calls to functions implemented by libraries that match
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.
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.
125 When no -e option is given, don't assume the default action of
128 .I \-n, \-\-indent nr
129 Indent trace output by
131 number of spaces for each new nested call. Using this option makes
132 the program flow visualization easy to follow.
134 .I \-o, \-\-output filename
135 Write the trace output to the file
137 rather than to stderr.
140 Attach to the process with the process ID
145 Print a relative timestamp with each line of the trace.
146 This records the time difference between the beginning of
150 Specify the maximum string size to print (the default is 32).
153 Display system calls as well as library calls
156 Prefix each line of the trace with the time of day.
159 If given twice, the time printed will include the microseconds.
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
167 Show the time spent inside each call. This records the time difference
168 between the beginning and the end of each call.
171 Run command with the userid, groupid and supplementary groups of
173 This option is only useful when running as root and enables the
174 correct execution of setuid and/or setgid binaries.
177 Show backtrace of NR stack frames for each traced function. This option enabled
178 only if libunwind support was enabled at compile time.
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.
188 Show the version number of ltrace and exit.
190 .SH FILTER EXPRESSIONS
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:
197 -e malloc+free-@libc.so*
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:
203 {[+-][\fIsymbol_pattern\fR][@\fIlibrary_pattern\fR]}
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
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.)
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).
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
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
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.
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.
248 It has most of the bugs stated in
251 It only works on Linux and in a small subset of architectures.
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
257 program if you are under the Debian GNU/Linux distribution.
262 System configuration file
265 Personal config file, overrides
269 Juan Cespedes <cespedes@debian.org>
271 Petr Machata <pmachata@redhat.com>