In-depth analysis of Linux command debugging tool strace_PHP tutorial

WBOY
Release: 2016-07-21 15:09:26
Original
1039 people have browsed it

Reference
1 "Linux strace command (detailed explanation).txt" Sina e-book can be downloaded
2man strace
A basically universal and complete usage:
strace -o output.txt -T -tt -e trace=all -p 28979
The above meaning is to trace all system calls of the 28979 process (-e trace=all), and count the time spent on the system call, as well as the start time (and display it in a visual format of hours, minutes and seconds), and finally store the recording results in the output.txt file.
A few usages that must be remembered
1) strace -p pid can track a background process
2) strace -o filename outputs the tracking results to the file
3) strace -T records the time spent on each system call, you can see which system call takes longer
4) strace -t (or -tt) records the time when each system call occurs ( Format of hours, minutes and seconds)
5) strace -s 1024 When displaying system call parameters, the default length of the string display is 32. If the string parameter is very long, a lot of information cannot be displayed.
6) strace -e trace=nanosleep only records relevant system call information.
-e trace=network // Only record system calls related to the network API
-e trace=file // Only record system calls involving file names
-e trace=desc // Only record There are other system calls involving file handles including process, ipc, signal, etc.
A classic troubleshooting process of viewing all related open files of a process through strace, refer to "Linux strace command (detailed explanation).txt" Sina e-book can be downloaded
If the development program is not accompanied by a powerful tool, Then the development efficiency will be very low, and you may even have no way to start when encountering problems. Now start learning strace, a powerful debugging tool under Linux, and record it here.

strace
1) Similar Processexp.exe under Windows

can monitor system calls

2) Similar to the depand tool under Windows
It can check the dependent libraries of the program. Compared with ldd under Linux More powerful.
Reference: strace command usage

Click to download
Case:
strace helped me solve the problem of not knowing where the log file is printed.
Use strace to track the server
/usr/bin/strace -p pid -o out.file
Then execute the client, then end strace, check out.file and search for write and open system calls

http://www.bkjia.com/PHPjc/327285.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327285.htmlTechArticleReference 1 "Linux strace command (detailed explanation).txt" Sina e-book can be downloaded 2man strace is basically universal Full usage of: strace -o output.txt -T -tt -e trace=all -p 28979 above...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!