blob: 16cb03b026bc347e940a8b7babb3a13796ba3a11 [file] [log] [blame]
Petr Machata4e1c0662012-04-24 00:50:07 +02001.\" Copyright (c) 2012 Petr Machata, Red Hat Inc.
Ian Wienand9a2ad352006-02-20 22:44:45 +01002.\" Copyright (c) 1997-2005 Juan Cespedes <cespedes@debian.org>
Juan Cespedes07461b61997-08-22 15:29:10 +02003.\" This file is covered by the GNU GPL
Juan Cespedesfea4a122009-05-28 16:53:43 +02004.TH ltrace 1
Ian Wienand9a2ad352006-02-20 22:44:45 +01005.SH NAME
Juan Cespedes07461b61997-08-22 15:29:10 +02006ltrace \- A library call tracer
7
Ian Wienand9a2ad352006-02-20 22:44:45 +01008.SH SYNOPSIS
Juan Cespedes07461b61997-08-22 15:29:10 +02009.B ltrace
Petr Machata51e74ac2012-09-27 23:43:25 +020010.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 ...]]"
Juan Cespedes07461b61997-08-22 15:29:10 +020011
Ian Wienand9a2ad352006-02-20 22:44:45 +010012.SH DESCRIPTION
Juan Cespedes07461b61997-08-22 15:29:10 +020013.B ltrace
14is a program that simply runs the specified
15.I command
16until it exits. It intercepts and records the dynamic library calls
17which are called by the executed process and the signals which are
18received by that process.
Juan Cespedesac3db291998-04-25 14:31:58 +020019It can also intercept and print the system calls executed by the program.
Ian Wienand9a2ad352006-02-20 22:44:45 +010020.PP
Juan Cespedes07461b61997-08-22 15:29:10 +020021Its use is very similar to
Juan Cespedes81690ef1998-03-13 19:31:29 +010022.BR strace(1) .
Juan Cespedes07461b61997-08-22 15:29:10 +020023
Ian Wienand9a2ad352006-02-20 22:44:45 +010024.SH OPTIONS
25.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010026.I \-a, \-\-align column
Joe Damatofa2aefc2010-10-30 19:56:50 -070027Align return values in a specific
28.IR column
29(default column is 5/8 of screen width).
Ian Wienand9a2ad352006-02-20 22:44:45 +010030.TP
Steve Fink1150bc42006-08-07 06:04:43 +020031.I \-A maxelts
32Maximum number of array elements to print before suppressing the rest with an ellipsis ("...")
33.TP
Joe Damato59e3fb12009-11-06 19:45:10 -080034.I \-b, \-\-no-signals
35Disable printing of signals recieved by the traced process.
36.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010037.I \-c
38Count time and calls for each library call and report a summary on program exit.
Ian Wienand9a2ad352006-02-20 22:44:45 +010039.TP
Juan Cespedesac3db291998-04-25 14:31:58 +020040.I \-C, \-\-demangle
Ian Wienand9a2ad352006-02-20 22:44:45 +010041Decode (demangle) low-level symbol names into user-level names.
Justin Pryzbyfda2c6f2006-07-18 00:05:26 +020042Besides removing any initial underscore prefix used by the system,
Juan Cespedesac3db291998-04-25 14:31:58 +020043this makes C++ function names readable.
Ian Wienand9a2ad352006-02-20 22:44:45 +010044.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020045.I \-D, \-\-debug level
Juan Cespedescd8976d2009-05-14 13:47:58 +020046Show debugging output of
47.B ltrace
48itself.
49.I level
50must be a sum of some of the following numbers:
51.RS
52.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020053.B 01
54DEBUG_GENERAL. Shows helpful progress information
55.TP
56.B 010
Juan Cespedescd8976d2009-05-14 13:47:58 +020057DEBUG_EVENT. Shows every event received by a traced program
58.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020059.B 020
Juan Cespedes85f7d762009-05-14 13:53:59 +020060DEBUG_PROCESS. Shows every action
61.B ltrace
Juan Cespedesc5c744a2009-07-23 18:22:58 +020062carries upon a traced process
63.TP
64.B 040
65DEBUG_FUNCTION. Shows every entry to internal functions
Juan Cespedescd8976d2009-05-14 13:47:58 +020066.RE
Ian Wienand9a2ad352006-02-20 22:44:45 +010067.TP
Petr Machata4e1c0662012-04-24 00:50:07 +020068.I \-e filter
69A qualifying expression which modifies which library calls to trace.
70The format of the filter expression is described in the section
71\fBFILTER EXPRESSIONS\fR. If more than one \-e option appears on the
72command line, the library calls that match any of them are traced. If
73no \-e is given, \fB@MAIN\fR is assumed as a default.
Ian Wienand9a2ad352006-02-20 22:44:45 +010074.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010075.I \-f
76Trace child processes as they are created by
Juan Cespedesc4e53a92009-05-06 20:36:42 +020077currently traced processes as a result of the fork(2)
Juan Cespedesd65efa32003-02-03 00:22:30 +010078or clone(2) system calls.
Juan Cespedesc4e53a92009-05-06 20:36:42 +020079The new process is attached immediately.
Ian Wienand9a2ad352006-02-20 22:44:45 +010080.TP
Joe Damatofa2aefc2010-10-30 19:56:50 -070081.I \-g
82Do not place breakpoints on PLT entries. This option reduces
83the output of ltrace. This is commonly used to avoid tracing
84libc functions.
85.TP
Steve Fink58c73a72006-07-17 23:18:35 +020086.I \-F
87Load an alternate config file. Normally, /etc/ltrace.conf and
88~/.ltrace.conf will be read (the latter only if it exists).
89Use this option to load the given file or files instead of
90those two default files.
91.TP
Juan Cespedesac3db291998-04-25 14:31:58 +020092.I \-h, \-\-help
93Show a summary of the options to ltrace and exit.
Ian Wienand9a2ad352006-02-20 22:44:45 +010094.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010095.I \-i
96Print the instruction pointer at the time of the library call.
Ian Wienand9a2ad352006-02-20 22:44:45 +010097.TP
Petr Machata51e74ac2012-09-27 23:43:25 +020098.I \-l, \-\-library library_pattern
99Display only the symbols implemented by libraries that match
100.I library_pattern.
101Multiple library patters can be specified with several instances of
102this option. Syntax of library_pattern is described in section
103\fBFILTER EXPRESSIONS\fR.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100104.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100105.I \-L
Petr Machata51e74ac2012-09-27 23:43:25 +0200106When no -e option is given, don't assume the default action of
107\fB@MAIN\fR.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100108.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100109.I \-n, \-\-indent nr
110Indent trace output by
111.I nr
112number of spaces for each new nested call. Using this option makes
113the program flow visualization easy to follow.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100114.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100115.I \-o, \-\-output filename
116Write the trace output to the file
117.I filename
118rather than to stderr.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100119.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100120.I \-p pid
121Attach to the process with the process ID
122.I pid
123and begin tracing.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100124.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100125.I \-r
126Print a relative timestamp with each line of the trace.
127This records the time difference between the beginning of
128successive lines.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100129.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100130.I \-s strsize
131Specify the maximum string size to print (the default is 32).
Ian Wienand9a2ad352006-02-20 22:44:45 +0100132.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100133.I \-S
134Display system calls as well as library calls
Ian Wienand9a2ad352006-02-20 22:44:45 +0100135.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100136.I \-t
137Prefix each line of the trace with the time of day.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100138.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100139.I \-tt
140If given twice, the time printed will include the microseconds.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100141.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100142.I \-ttt
143If given thrice, the time printed will include the microseconds and
144the leading portion will be printed as the number of seconds since the
145epoch.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100146.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100147.I \-T
148Show the time spent inside each call. This records the time difference
149between the beginning and the end of each call.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100150.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100151.I \-u username
152Run command with the userid, groupid and supplementary groups of
Ian Wienand9a2ad352006-02-20 22:44:45 +0100153.IR username .
Juan Cespedesd65efa32003-02-03 00:22:30 +0100154This option is only useful when running as root and enables the
155correct execution of setuid and/or setgid binaries.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100156.TP
Joe Damato535e7382010-11-08 15:47:43 -0800157.I \-w, --where NR
158Show backtrace of NR stack frames for each traced function. This option enabled
159only if libunwind support was enabled at compile time.
160.TP
Petr Machata4e1c0662012-04-24 00:50:07 +0200161.I \-x filter
162A qualifying expression which modifies which symbol table entry points
163to trace. The format of the filter expression is described in the
164section \fBFILTER EXPRESSIONS\fR. If more than one \-x option appears
165on the command line, the symbols that match any of them are traced.
166No entry points are traced if no \-x is given.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100167.TP
Juan Cespedesac3db291998-04-25 14:31:58 +0200168.I \-V, \-\-version
169Show the version number of ltrace and exit.
Juan Cespedes07461b61997-08-22 15:29:10 +0200170
Petr Machata4e1c0662012-04-24 00:50:07 +0200171.SH FILTER EXPRESSIONS
172
173Filter expression is a chain of glob- or regexp-based rules that are
174used to pick symbols for tracing from libraries that the process uses.
175Most of it is intuitive, so as an example, the following would trace
176calls to malloc and free, except those done by libc:
177
178-e malloc+free-@libc.so*
179
180This reads: trace malloc and free, but don't trace anything that comes
181from libc. Semi-formally, the syntax of the above example looks
182approximately like this:
183
Petr Machata964a6802012-06-29 14:27:08 +0200184{[+-][\fIsymbol_pattern\fR][@\fIlibrary_pattern\fR]}
Petr Machata4e1c0662012-04-24 00:50:07 +0200185
Petr Machata964a6802012-06-29 14:27:08 +0200186\fISymbol_pattern\fR is used to match symbol names,
187\fIlibrary_pattern\fR to match library SONAMEs. Both are implicitly
188globs, but can be regular expressions as well (see below). The glob
189syntax supports meta-characters \fB*\fR and \fB?\fR and character
190classes, similarly to what basic bash globs support. \fB^\fR and
191\fB$\fR are recognized to mean, respectively, start and end of given
192name.
Petr Machata4e1c0662012-04-24 00:50:07 +0200193
Petr Machata964a6802012-06-29 14:27:08 +0200194Both \fIsymbol_pattern\fR and \fIlibrary_pattern\fR have to match the
195whole name. If you want to match only part of the name, surround it
Petr Machata4e1c0662012-04-24 00:50:07 +0200196with one or two *'s as appropriate. The exception is if the pattern
197is not mentioned at all, in which case it's as if the corresponding
198pattern were \fB*\fR. (So \fBmalloc\fR is really \fBmalloc@*\fR and
199\fB@libc.*\fR is really \fB*@libc.*\fR.)
200
201In libraries that don't have an explicit SONAME, basename is taken for
202SONAME. That holds for main binary as well: \fB/bin/echo\fR has an
203implicit SONAME of \fBecho\fR. In addition to that, special library
204pattern \fBMAIN\fR always matches symbols in the main binary and never
205a library with actual SONAME \fBMAIN\fR (use e.g. \fB^MAIN\fR or
206\fB[M]AIN\fR for that).
207
208If the symbol or library pattern is surrounded in slashes (/like
209this/), then it is considered a regular expression instead. As a
210shorthand, instead of writing \fB/x/@/y/\fR, you can write
211\fB/x@y/\fR.
212
213If the library pattern starts with a slash, it is not a SONAME
214expression, but a path expression, and is matched against the library
215path name.
216
217The first rule may lack a sign, in which case \fB+\fR is assumed. If,
218on the other hand, the first rule has a \fB-\fR sign, it is as if
219there was another rule \fB@*\fR in front of it.
220
221The above rules are used to construct the set of traced symbols. Each
222candidate symbol is passed through the chain of above rules.
Petr Machata964a6802012-06-29 14:27:08 +0200223Initially, the symbol is \fIunmarked\fR. If it matches a \fB+\fR
224rule, it becomes \fImarked\fR, if it matches a \fB-\fR rule, it
225becomes \fIunmarked\fR again. If, after applying all rules, the
226symbol is \fImarked\fR, it will be traced.
Petr Machata4e1c0662012-04-24 00:50:07 +0200227
Ian Wienand9a2ad352006-02-20 22:44:45 +0100228.SH BUGS
Juan Cespedesac3db291998-04-25 14:31:58 +0200229It has most of the bugs stated in
230.BR strace(1) .
Ian Wienand9a2ad352006-02-20 22:44:45 +0100231.LP
232Manual page and documentation are not very up-to-date.
233.LP
234Option -f sometimes fails to trace some children.
235.LP
Juan Cespedes5c3fe062004-06-14 18:08:37 +0200236It only works on Linux and in a small subset of architectures.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100237.LP
Ian Wienand9a2ad352006-02-20 22:44:45 +0100238.PP
Steve Fink7ab8df12006-08-07 04:06:16 +0200239If you would like to report a bug, send a message to the mailing list
240(ltrace-devel@lists.alioth.debian.org), or use the
Ian Wienandbf312a12006-02-20 23:28:35 +0100241.BR reportbug(1)
Juan Cespedesac3db291998-04-25 14:31:58 +0200242program if you are under the Debian GNU/Linux distribution.
Juan Cespedes07461b61997-08-22 15:29:10 +0200243
Ian Wienand9a2ad352006-02-20 22:44:45 +0100244.SH FILES
245.TP
Juan Cespedes5e01f651998-03-08 22:31:44 +0100246.I /etc/ltrace.conf
247System configuration file
Ian Wienand9a2ad352006-02-20 22:44:45 +0100248.TP
Juan Cespedes5e01f651998-03-08 22:31:44 +0100249.I ~/.ltrace.conf
250Personal config file, overrides
251.I /etc/ltrace.conf
252
Ian Wienand9a2ad352006-02-20 22:44:45 +0100253.SH AUTHOR
Juan Cespedes64e793b1997-09-11 23:22:36 +0200254Juan Cespedes <cespedes@debian.org>
Petr Machata4e1c0662012-04-24 00:50:07 +0200255.br
256Petr Machata <pmachata@redhat.com>
Juan Cespedes07461b61997-08-22 15:29:10 +0200257
258.SH "SEE ALSO"
259.BR strace(1) ,
260.BR ptrace(2)
261