Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.49 KB

strace.md

File metadata and controls

43 lines (28 loc) · 1.49 KB

The strace command is a powerful diagnostic tool in Unix-like operating systems that is used to trace system calls and signals between a process and the kernel. It allows you to monitor the interactions of a program with the operating system, providing insights into its behavior, system calls, and resource usage.

Here's a basic usage example:

strace <command>

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

strace ls -l

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

Some common options for the strace command include:

  • -c: This option counts the number of calls, time, and errors for each system call and reports a summary at the end.

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

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

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

    strace -p 1234

strace can be a valuable tool for debugging, performance analysis, and understanding how a program interacts with the underlying system. It provides detailed information about system calls, signals, and errors, aiding in the identification of issues or bottlenecks in the program's execution.