In-depth analysis of strace, a debugging tool for linux Commands

Source: Internet
Author: User
This article provides a detailed analysis of the use of the debugging tool strace. For more information, see Reference
1. you can download the stracecommand of linux.txt from Sina.
2man strace
A general and complete usage:
Strace-o output.txt-T-tt-e trace = all-p 28979
The preceding description is used to track all system calls of the 28979 process (in the-e Workflow file.
Several usage that must be remembered
1) the strace-p pid can track a background process.
2) strace-o filename outputs the trace result to the file
3) strace-T records the time spent on each system call. you can see which system call takes a long time.
4) strace-t (or-tt) records the time when each system call occurred (in the format of hour, minute, and second)
5) when strace-s 1024 displays system call parameters, the default length of the string is 32. if the string parameters are long, a lot of information cannot be displayed.
6) strace-e trace = nanosleep only records relevant system call information.
-E trace = network // only records system calls related to network APIs
-E trace = file // only records system calls involving file names
-E trace = desc // only records system calls involving file handles
Others include process, ipc, and signal.
A classic user can download the stracecommand of linuxlinux( detailed description: .txt, Sina eBook) by following the steps of strace related to file opening.
If the development program does not have a powerful tool, the development efficiency will be very low, and you may not have any problems to start with. now, learn about the powerful debugging tool strace in linux and record it here.
Strace
This parameter is applicable to processexp.exe in Windows.
Monitor System calls
2) similar to the depand tool in windows
Check the dependent libraries of the program. it is more powerful than ldd in linux.
Reference: strace command usage
Click to download
Case:
Strace helps me solve the problem where I don't know where the log file is printed.
Use strace to track the server
/Usr/bin/strace-p pid-o out. file
Then execute the client, end strace, view out. file, and search for the write and open system calls.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.