A common command summary _php instance based on Linux debugging Tools Strace and GDB

Source: Internet
Author: User
Tags add time
Strace and GDB are two common debugging tools in a Linux environment, and here is a summary of the common parameters used by individuals in the use of these two tools for later viewing.
strace Debugging Tools
The Strace tool is used to track system calls and received signals when a process executes, including parameters, return values, and execution times. In Linux, the user program to access the system device, must be switched from user state to the kernel state, which is initiated and completed through system calls.
strace Common parameters:
-C Statistics The execution time of each system call, the number of calls, the number of errors, and the report when the program exits
-p PID tracks a specified process, which can be tracked multiple processes simultaneously with multiple-p
-o filename strace default output to stdout,-o the output can be written to the specified file
-F system call to track child processes generated by fork
-ff are often used with the-o option, and system calls from different processes (subprocess) are output to individual filename.pid files
-F attempts to trace vfork system calls, note: Vfork is not tracked when used with-f
-E expr Output filter expression that filters out strace results that you do not want to output
-e Trace=set Specifies system calls in trace set
-e trace=network track all system calls related to the network
-e strace=signal tracks all system calls related to system signals
-e TRACE=IPC tracks all system calls related to process communication
-e signal=set Specifies the signal in the trace set
-e read=set output data read from a specified file, such as-e read=3,5
-e write=set output to data written to a specified file, such as-e write=1
-R Prints the relative time of each system call
-T add time information to each line in the output
-tt the time information before each line in the output, the time is accurate to the microsecond level
-TTT the time information before each line in the output, the output is relative time
-s Specifies the length of the output string for each line (default is 32)
strace Use examples:
Strace-t whoami #跟踪whoami可执行程序, print execution time before output results per line
Strace-p 17151-p 17152-p 17153 #同时跟踪进程17151, 17152, 17153
Strace-f-e trace=read,write-p 17151-o log #跟踪进程17151及子进程中read和write系统调用, output to log file
gdb Debugging Tools
GDB is a powerful UNIX program debugging tool released by the GNU Open source organization. GCC compile-time with the-g parameter, you can enable the executable program plus GDB debugging information.
(1) Info
Shorthand: I, listing information for GDB subcommand, such as info break,info variables,info stack, etc.
(2) List [file:]function
Short: l, view the context of the current line, default to 10 lines, or set up a function to list the source code.
(3) Edit [file:]function
Shorthand: E, edit the current line, or edit the source of a function.
(4) Break [file:]function
Short: B, set breakpoints, can be set in a row or a function.
(5) Run [arglist]
Short: R, run the program to the breakpoint stop, after the Run command can add the parameters required by the debugger.
(6) Next
Short: N, single statement execution.
(7) Continue
Short: C, continue running the program to the next breakpoint.
(8) Print
Short: p, print the value of the variable.
(9) bt
View the function stack information.
(Ten) Enter
Enter key, repeat the last debug command.
(one) help [name]
Displays help information for the specified GDB command.
(quit)
Abbreviation: q, Exit gdb.

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.