Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to use ltrace

📅 2018-Apr-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ltrace, strace ⬩ 📚 Archive

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.

$ sudo apt install ltrace
$ ltrace ./foobar
$ ltrace touch

Note that it writes its output to stderr.

$ ltrace -o foobar.log ./foobar
$ 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

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧