Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.48 KB

ltrace.md

File metadata and controls

43 lines (28 loc) · 1.48 KB

The ltrace command is another diagnostic tool used in Unix-like operating systems, particularly Linux, to trace library calls made by a process. While strace traces system calls, ltrace focuses on library calls, providing insights into dynamic library usage by a program.

Here's a basic usage example:

ltrace <command>

Replace <command> with the command you want to trace. For example:

ltrace ls -l

This command will execute the ls -l command and print a detailed trace of library calls made by the ls program.

Some common options for the ltrace command include:

  • -c: This option counts the number of calls for each library function and reports a summary at the end.

    ltrace -c ls -l
  • -f: This option follows child processes as they are created, providing a trace of the entire process tree.

    ltrace -f ./my_program
  • -o <output-file>: This option redirects the output to a file instead of printing it to the console.

    ltrace -o output.txt ls -l
  • -p <pid>: This option attaches to an existing process specified by its process ID.

    ltrace -p 1234

Similar to strace, ltrace is useful for debugging and understanding program behavior. It can help identify which library functions are being called, the arguments passed to them, and the return values. This information is valuable for diagnosing issues, tracking down bugs, and gaining insights into the inner workings of a program.