Linux "ltrace" Command Line Options and Examples
A library call tracer

ltrace is a program that simply runs the specified command until it exits. It intercepts and records the dynamic library calls which are called by the executed process and the signals which are received by that process. It can also intercept and print the system calls executed by the program.


Usage:

ltrace [-e filter|-L] [-l|--library=library_pattern] [-x filter] [-S] [-b|--no-signals] [-i] [-w|--where=nr] [-r|-t|-tt|-ttt] [-T]
[-F filename] [-A maxelts] [-s strsize] [-C|--demangle] [-a|--align column] [-n|--indent nr] [-o|--output filename] [-D|--debug mask]
[-u username] [-f] [-p pid] [[--] command [arg ...]]






Command Line Options:

-a
Align return values in a specific column (default column is 5/8 of screen width).
ltrace -a ...
-A
Maximum number of array elements to print before suppressing the rest with an ellipsis ("..."). This also limits number ofrecursive structure expansions.
ltrace -A ...
-b
Disable printing of signals recieved by the traced process.
ltrace -b ...
-c
Count time and calls for each library call and report a summary on program exit.
ltrace -c ...
-C
Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore prefix used by thesystem, this makes C++ function names readable.
ltrace -C ...
-D
Show debugging output of ltrace itself. mask is a number with internal meaning that's not really well defined at all. maskof 77 shows all debug messages, which is what you usually need.
ltrace -D ...
-e
A qualifying expression which modifies which library calls to trace. The format of the filter expression is described in thesection FILTER EXPRESSIONS. If more than one -e option appears on the command line, the library calls that match any of themare traced. If no -e is given, @MAIN is assumed as a default.
ltrace -e ...
-F
Load an alternate config file. Normally, /etc/ltrace.conf and ~/.ltrace.conf will be read (the latter only if it exists). Usethis option to load the given file or files instead of those two default files. See ltrace.conf(5) for details on the syntaxof ltrace configuration files.
ltrace -F ...
-h
Show a summary of the options to ltrace and exit.
ltrace -h ...
-i
Print the instruction pointer at the time of the library call.
ltrace -i ...
-l
Display only calls to functions implemented by libraries that match library_pattern. Multiple library patters can be speci‐fied with several instances of this option. Syntax of library_pattern is described in section FILTER EXPRESSIONS.Note that while this option selects calls that might be directed to the selected libraries, there's no actual guarantee thatthe call won't be directed elsewhere due to e.g. LD_PRELOAD or simply dependency ordering. If you want to make sure that sym‐bols in given library are actually called, use -x @library_pattern instead.
ltrace -l ...
-L
When no -e option is given, don't assume the default action of @MAIN.
ltrace -L ...
-n
Indent trace output by nr spaces for each level of call nesting. Using this option makes the program flow visualization easyto follow. This indents uselessly also functions that never return, such as service functions for throwing exceptions in theC++ runtime.
ltrace -n ...
-o
Write the trace output to the file filename rather than to stderr.
ltrace -o ...
-s
Specify the maximum string size to print (the default is 32).
ltrace -s ...
-S
Display system calls as well as library calls
ltrace -S ...
-t
Prefix each line of the trace with the time of day.
ltrace -t ...
-tt
the time printed will include the microseconds.
ltrace -tt ...
-T
Show the time spent inside each call. This records the time difference between the beginning and the end of each call.
ltrace -T ...
-u
Run command with the userid, groupid and supplementary groups of username. This option is only useful when running as rootand enables the correct execution of setuid and/or setgid binaries.
ltrace -u ...
-w
Show backtrace of nr stack frames for each traced function. This option enabled only if libunwind support was enabled at com‐pile time.
ltrace -w ...
-x
A qualifying expression which modifies which symbol table entry points to trace. The format of the filter expression isdescribed in the section FILTER EXPRESSIONS. If more than one -x option appears on the command line, the symbols that matchany of them are traced. No entry points are traced if no -x is given.
ltrace -x ...
-V
Show the version number of ltrace and exit.FILTER EXPRESSIONSFilter expression is a chain of glob- or regexp-based rules that are used to pick symbols for tracing from libraries that the processuses. Most of it is intuitive, so as an example, the following would trace calls to malloc and free, except those done by libc:
ltrace -V ...