ltrace is an immensely useful tool to know what a program is doing. It displays the library calls made by a program that you execute. Just like strace, it will display the function called, list its input arguments and also display the return value from the function. Note that only calls made to dynamically linked libraries are reported. Not those to libraries that have been statically linked into the executable.
- Installing ltrace is easy:
$ sudo apt install ltrace
- Provide a program as argument when you invoke it:
$ ltrace ./foobar $ ltrace touch
Note that it writes its output to stderr.
- To redirect output of ltrace to a file:
$ ltrace -o foobar.log ./foobar
- To filter and display only calls to a certain library function:
$ ltrace -e foobar_function_name ./foobar $ ltrace -e malloc ./foobar
Note that you need to specify the exact name of the function. You can also use some method name and library name globs and regular expressions. For more info, please see the manual.
Tried with: ltrace 0.7.3