linux command debugging tool strace in depth analysis

  • 2020-06-03 06:04:26
  • OfStack

linux strace command (a detailed explanation).txt Sina ebook can be downloaded
2man strace
1 complete usage that is basically universal:
strace -o output.txt -T -tt -e trace=all -p 28979
The above meaning is to track all system calls of the 28979 process (-e trace=all), count the time spent on the system call, and the start time (shown in a visual minute and second format), and finally save the recorded results in the output.txt file.
A few usages you must remember
strace-pid Can track a background process
strace-filename outputs the tracking results to the file
3) ES25en-ES26en records the time spent on each system call to see which system call takes the longest
4) ES28en-ES29en (or -ES30en) Records the time each system call occurs (in minute and second format)
5) When es32EN-s 1024 displays system call parameters, the default is 32 for the length of string. If the string parameters are too long, a lot of information cannot be displayed.
6) ES35en-ES36en trace=nanosleep Only records the relevant system call information.
-ES40en trace=network // Only system calls related to network api are logged
-ES45en trace=file // Records only system calls involving file names
-ES49en trace=desc // Records only system calls involving file handles
Others include process, ipc, signal and so on.
1 classic, through strace view 1 process all relevant open file screening process, reference linux strace command (details).txt Sina ebook can be downloaded
If the development program is not accompanied by a powerful tool, then the development efficiency will be very low, and even have no way to start the problem. Now start to learn strace, a powerful debugging tool under linux, and record here.
1) Similar to ES68en. exe under windows
You can monitor system calls
2) Similar to depand tool under windows
You can check the dependencies of the program library. ldd linux under more powerful.
Reference :strace command usage
Click on the download
Case study:
strace helped me solve the problem of where the log file was printed.
Track server with strace
/usr/bin/strace -p pid -o out.file
Then execute the client side and end strace to see the system call for out.file to search write,open

Related articles: