A very useful
tool for figuring out what a program is doing. Works on Linux
, and other Unices. It can often be helpful for debugging
It works by tracing every shared library function call. This includes the C library, so you'll see things like fopen(), strcmp(), etc.
An example use is when you're trying to figure out where a program's configuration file is. Just ltrace the process and look for fopen() calls. You'll often see it trying to open several configuration files and failing. Those are usually alternate places to put them. Commonly you'll see it checking for something in /etc and then in your home directory. That means you can override the default settings with a private configuration file.
It requires a description of the parameters of each function call in order to be useful. /etc/ltrace.conf contains those for most of the calls in libc, as well as documentation on how to describe parameters. You can add your own definitions there or in a private configuration file -- use ltrace to trace itself to figure out where!
See also strace, an even more valuable tool.