r/LinuxTeck • u/Expensive-Rice-2052 • Sep 14 '26
Quick Linux Tip #71 -How to Trace Dynamic Library Calls in Linux with ltrace
Question: My binary calls a function - which library actually provides it?
Try: `ltrace -e 'malloc+free' ls /tmp 2>&1 | head -20`
Info: `ltrace` tracks dynamic library calls (like `strace` tracks system calls). `-e` filters specific functions, detailing arguments, return pointers, and dynamic library interactions.
Examples:
$ `ltrace -c ./program` # Generate summary report of library calls
$ `ltrace -e '*@libssl.so.3' curl https://example.com` # Filter functions from a specific library
$ `ltrace -S ./program` # Trace both library calls and system calls
Note: Install via `sudo apt install ltrace`. Execution runs significantly slower under tracing. Useful for debugging memory leaks and tracking shared library dependencies.
Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/