blob: b5ec82688947e1a79a6dddd1dad5254d3faa0502 [file] [log] [blame]
Petr Machata11f23ba2012-10-25 03:39:59 +02001.\" -*-nroff-*-
Petr Machata4e1c0662012-04-24 00:50:07 +02002.\" Copyright (c) 2012 Petr Machata, Red Hat Inc.
Ian Wienand9a2ad352006-02-20 22:44:45 +01003.\" Copyright (c) 1997-2005 Juan Cespedes <cespedes@debian.org>
Petr Machata11f23ba2012-10-25 03:39:59 +02004.\"
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"
Ian Wienand9a2ad352006-02-20 22:44:45 +010021.SH NAME
Juan Cespedes07461b61997-08-22 15:29:10 +020022ltrace \- A library call tracer
23
Ian Wienand9a2ad352006-02-20 22:44:45 +010024.SH SYNOPSIS
Juan Cespedes07461b61997-08-22 15:29:10 +020025.B ltrace
Petr Machata51e74ac2012-09-27 23:43:25 +020026.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 +020027
Ian Wienand9a2ad352006-02-20 22:44:45 +010028.SH DESCRIPTION
Juan Cespedes07461b61997-08-22 15:29:10 +020029.B ltrace
30is a program that simply runs the specified
31.I command
32until it exits. It intercepts and records the dynamic library calls
33which are called by the executed process and the signals which are
34received by that process.
Juan Cespedesac3db291998-04-25 14:31:58 +020035It can also intercept and print the system calls executed by the program.
Ian Wienand9a2ad352006-02-20 22:44:45 +010036.PP
Juan Cespedes07461b61997-08-22 15:29:10 +020037Its use is very similar to
Juan Cespedes81690ef1998-03-13 19:31:29 +010038.BR strace(1) .
Juan Cespedes07461b61997-08-22 15:29:10 +020039
Ian Wienand9a2ad352006-02-20 22:44:45 +010040.SH OPTIONS
41.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010042.I \-a, \-\-align column
Joe Damatofa2aefc2010-10-30 19:56:50 -070043Align return values in a specific
44.IR column
45(default column is 5/8 of screen width).
Ian Wienand9a2ad352006-02-20 22:44:45 +010046.TP
Steve Fink1150bc42006-08-07 06:04:43 +020047.I \-A maxelts
48Maximum number of array elements to print before suppressing the rest with an ellipsis ("...")
49.TP
Joe Damato59e3fb12009-11-06 19:45:10 -080050.I \-b, \-\-no-signals
51Disable printing of signals recieved by the traced process.
52.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010053.I \-c
54Count time and calls for each library call and report a summary on program exit.
Ian Wienand9a2ad352006-02-20 22:44:45 +010055.TP
Juan Cespedesac3db291998-04-25 14:31:58 +020056.I \-C, \-\-demangle
Ian Wienand9a2ad352006-02-20 22:44:45 +010057Decode (demangle) low-level symbol names into user-level names.
Justin Pryzbyfda2c6f2006-07-18 00:05:26 +020058Besides removing any initial underscore prefix used by the system,
Juan Cespedesac3db291998-04-25 14:31:58 +020059this makes C++ function names readable.
Ian Wienand9a2ad352006-02-20 22:44:45 +010060.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020061.I \-D, \-\-debug level
Juan Cespedescd8976d2009-05-14 13:47:58 +020062Show debugging output of
63.B ltrace
64itself.
65.I level
66must be a sum of some of the following numbers:
67.RS
68.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020069.B 01
70DEBUG_GENERAL. Shows helpful progress information
71.TP
72.B 010
Juan Cespedescd8976d2009-05-14 13:47:58 +020073DEBUG_EVENT. Shows every event received by a traced program
74.TP
Juan Cespedesc5c744a2009-07-23 18:22:58 +020075.B 020
Juan Cespedes85f7d762009-05-14 13:53:59 +020076DEBUG_PROCESS. Shows every action
77.B ltrace
Juan Cespedesc5c744a2009-07-23 18:22:58 +020078carries upon a traced process
79.TP
80.B 040
81DEBUG_FUNCTION. Shows every entry to internal functions
Juan Cespedescd8976d2009-05-14 13:47:58 +020082.RE
Ian Wienand9a2ad352006-02-20 22:44:45 +010083.TP
Petr Machata4e1c0662012-04-24 00:50:07 +020084.I \-e filter
85A qualifying expression which modifies which library calls to trace.
86The format of the filter expression is described in the section
87\fBFILTER EXPRESSIONS\fR. If more than one \-e option appears on the
88command line, the library calls that match any of them are traced. If
89no \-e is given, \fB@MAIN\fR is assumed as a default.
Ian Wienand9a2ad352006-02-20 22:44:45 +010090.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +010091.I \-f
92Trace child processes as they are created by
Juan Cespedesc4e53a92009-05-06 20:36:42 +020093currently traced processes as a result of the fork(2)
Juan Cespedesd65efa32003-02-03 00:22:30 +010094or clone(2) system calls.
Juan Cespedesc4e53a92009-05-06 20:36:42 +020095The new process is attached immediately.
Ian Wienand9a2ad352006-02-20 22:44:45 +010096.TP
Steve Fink58c73a72006-07-17 23:18:35 +020097.I \-F
98Load an alternate config file. Normally, /etc/ltrace.conf and
99~/.ltrace.conf will be read (the latter only if it exists).
100Use this option to load the given file or files instead of
101those two default files.
102.TP
Juan Cespedesac3db291998-04-25 14:31:58 +0200103.I \-h, \-\-help
104Show a summary of the options to ltrace and exit.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100105.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100106.I \-i
107Print the instruction pointer at the time of the library call.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100108.TP
Petr Machata51e74ac2012-09-27 23:43:25 +0200109.I \-l, \-\-library library_pattern
Petr Machata9265da42012-11-02 02:56:08 +0100110Display only calls to functions implemented by libraries that match
Petr Machata51e74ac2012-09-27 23:43:25 +0200111.I library_pattern.
112Multiple library patters can be specified with several instances of
113this option. Syntax of library_pattern is described in section
114\fBFILTER EXPRESSIONS\fR.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100115.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100116.I \-L
Petr Machata51e74ac2012-09-27 23:43:25 +0200117When no -e option is given, don't assume the default action of
118\fB@MAIN\fR.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100119.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100120.I \-n, \-\-indent nr
121Indent trace output by
122.I nr
123number of spaces for each new nested call. Using this option makes
124the program flow visualization easy to follow.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100125.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100126.I \-o, \-\-output filename
127Write the trace output to the file
128.I filename
129rather than to stderr.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100130.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100131.I \-p pid
132Attach to the process with the process ID
133.I pid
134and begin tracing.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100135.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100136.I \-r
137Print a relative timestamp with each line of the trace.
138This records the time difference between the beginning of
139successive lines.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100140.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100141.I \-s strsize
142Specify the maximum string size to print (the default is 32).
Ian Wienand9a2ad352006-02-20 22:44:45 +0100143.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100144.I \-S
145Display system calls as well as library calls
Ian Wienand9a2ad352006-02-20 22:44:45 +0100146.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100147.I \-t
148Prefix each line of the trace with the time of day.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100149.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100150.I \-tt
151If given twice, the time printed will include the microseconds.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100152.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100153.I \-ttt
154If given thrice, the time printed will include the microseconds and
155the leading portion will be printed as the number of seconds since the
156epoch.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100157.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100158.I \-T
159Show the time spent inside each call. This records the time difference
160between the beginning and the end of each call.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100161.TP
Juan Cespedesd65efa32003-02-03 00:22:30 +0100162.I \-u username
163Run command with the userid, groupid and supplementary groups of
Ian Wienand9a2ad352006-02-20 22:44:45 +0100164.IR username .
Juan Cespedesd65efa32003-02-03 00:22:30 +0100165This option is only useful when running as root and enables the
166correct execution of setuid and/or setgid binaries.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100167.TP
Joe Damato535e7382010-11-08 15:47:43 -0800168.I \-w, --where NR
169Show backtrace of NR stack frames for each traced function. This option enabled
170only if libunwind support was enabled at compile time.
171.TP
Petr Machata4e1c0662012-04-24 00:50:07 +0200172.I \-x filter
173A qualifying expression which modifies which symbol table entry points
174to trace. The format of the filter expression is described in the
175section \fBFILTER EXPRESSIONS\fR. If more than one \-x option appears
176on the command line, the symbols that match any of them are traced.
177No entry points are traced if no \-x is given.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100178.TP
Juan Cespedesac3db291998-04-25 14:31:58 +0200179.I \-V, \-\-version
180Show the version number of ltrace and exit.
Juan Cespedes07461b61997-08-22 15:29:10 +0200181
Petr Machata4e1c0662012-04-24 00:50:07 +0200182.SH FILTER EXPRESSIONS
183
184Filter expression is a chain of glob- or regexp-based rules that are
185used to pick symbols for tracing from libraries that the process uses.
186Most of it is intuitive, so as an example, the following would trace
187calls to malloc and free, except those done by libc:
188
189-e malloc+free-@libc.so*
190
191This reads: trace malloc and free, but don't trace anything that comes
192from libc. Semi-formally, the syntax of the above example looks
193approximately like this:
194
Petr Machata964a6802012-06-29 14:27:08 +0200195{[+-][\fIsymbol_pattern\fR][@\fIlibrary_pattern\fR]}
Petr Machata4e1c0662012-04-24 00:50:07 +0200196
Petr Machata964a6802012-06-29 14:27:08 +0200197\fISymbol_pattern\fR is used to match symbol names,
198\fIlibrary_pattern\fR to match library SONAMEs. Both are implicitly
199globs, but can be regular expressions as well (see below). The glob
200syntax supports meta-characters \fB*\fR and \fB?\fR and character
201classes, similarly to what basic bash globs support. \fB^\fR and
202\fB$\fR are recognized to mean, respectively, start and end of given
203name.
Petr Machata4e1c0662012-04-24 00:50:07 +0200204
Petr Machata964a6802012-06-29 14:27:08 +0200205Both \fIsymbol_pattern\fR and \fIlibrary_pattern\fR have to match the
206whole name. If you want to match only part of the name, surround it
Petr Machata4e1c0662012-04-24 00:50:07 +0200207with one or two *'s as appropriate. The exception is if the pattern
208is not mentioned at all, in which case it's as if the corresponding
209pattern were \fB*\fR. (So \fBmalloc\fR is really \fBmalloc@*\fR and
210\fB@libc.*\fR is really \fB*@libc.*\fR.)
211
212In libraries that don't have an explicit SONAME, basename is taken for
213SONAME. That holds for main binary as well: \fB/bin/echo\fR has an
214implicit SONAME of \fBecho\fR. In addition to that, special library
215pattern \fBMAIN\fR always matches symbols in the main binary and never
216a library with actual SONAME \fBMAIN\fR (use e.g. \fB^MAIN\fR or
217\fB[M]AIN\fR for that).
218
219If the symbol or library pattern is surrounded in slashes (/like
220this/), then it is considered a regular expression instead. As a
221shorthand, instead of writing \fB/x/@/y/\fR, you can write
222\fB/x@y/\fR.
223
224If the library pattern starts with a slash, it is not a SONAME
225expression, but a path expression, and is matched against the library
226path name.
227
228The first rule may lack a sign, in which case \fB+\fR is assumed. If,
229on the other hand, the first rule has a \fB-\fR sign, it is as if
230there was another rule \fB@*\fR in front of it.
231
232The above rules are used to construct the set of traced symbols. Each
233candidate symbol is passed through the chain of above rules.
Petr Machata964a6802012-06-29 14:27:08 +0200234Initially, the symbol is \fIunmarked\fR. If it matches a \fB+\fR
235rule, it becomes \fImarked\fR, if it matches a \fB-\fR rule, it
236becomes \fIunmarked\fR again. If, after applying all rules, the
237symbol is \fImarked\fR, it will be traced.
Petr Machata4e1c0662012-04-24 00:50:07 +0200238
Ian Wienand9a2ad352006-02-20 22:44:45 +0100239.SH BUGS
Juan Cespedesac3db291998-04-25 14:31:58 +0200240It has most of the bugs stated in
241.BR strace(1) .
Ian Wienand9a2ad352006-02-20 22:44:45 +0100242.LP
243Manual page and documentation are not very up-to-date.
244.LP
245Option -f sometimes fails to trace some children.
246.LP
Juan Cespedes5c3fe062004-06-14 18:08:37 +0200247It only works on Linux and in a small subset of architectures.
Ian Wienand9a2ad352006-02-20 22:44:45 +0100248.LP
Ian Wienand9a2ad352006-02-20 22:44:45 +0100249.PP
Steve Fink7ab8df12006-08-07 04:06:16 +0200250If you would like to report a bug, send a message to the mailing list
251(ltrace-devel@lists.alioth.debian.org), or use the
Ian Wienandbf312a12006-02-20 23:28:35 +0100252.BR reportbug(1)
Juan Cespedesac3db291998-04-25 14:31:58 +0200253program if you are under the Debian GNU/Linux distribution.
Juan Cespedes07461b61997-08-22 15:29:10 +0200254
Ian Wienand9a2ad352006-02-20 22:44:45 +0100255.SH FILES
256.TP
Juan Cespedes5e01f651998-03-08 22:31:44 +0100257.I /etc/ltrace.conf
258System configuration file
Ian Wienand9a2ad352006-02-20 22:44:45 +0100259.TP
Juan Cespedes5e01f651998-03-08 22:31:44 +0100260.I ~/.ltrace.conf
261Personal config file, overrides
262.I /etc/ltrace.conf
263
Ian Wienand9a2ad352006-02-20 22:44:45 +0100264.SH AUTHOR
Juan Cespedes64e793b1997-09-11 23:22:36 +0200265Juan Cespedes <cespedes@debian.org>
Petr Machata4e1c0662012-04-24 00:50:07 +0200266.br
267Petr Machata <pmachata@redhat.com>
Juan Cespedes07461b61997-08-22 15:29:10 +0200268
269.SH "SEE ALSO"
Petr Machata11f23ba2012-10-25 03:39:59 +0200270.BR ltrace.conf(5),
Juan Cespedes07461b61997-08-22 15:29:10 +0200271.BR strace(1) ,
272.BR ptrace(2)
273