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