Summary _php tutorial for common commands Strace and GDB based on Linux debugging Tools

Source: Internet
Author: User
Tags add time
Strace and GDB are two common debugging tools in the Linux environment, and this is a summary of the parameters commonly used by individuals in the process of using them 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 time. In Linux, the user program to access the system device, must be switched from the user state to the kernel state, which is initiated and completed by the system call.
strace Common parameters:
-C Statistics The time of execution of each system call, number of calls, number of errors, report when program exits
-p PID tracks the specified process and can use multiple-p to track multiple processes simultaneously
-o filename strace default output to stdout,-o the output can be written to the specified file
-F tracing system calls of child processes produced by fork
-FF is often used with the-o option, and system calls from different processes (sub-processes) are output to each filename.pid file
-F attempts to trace vfork child process system calls, note: Vfork is not tracked when used with-f
-E expr Output filter expression to filter out strace results that you do not want to output
-e Trace=set specifying system calls in trace set
-e trace=network trace 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 the specified file, such as-e read=3,5
-e write=set output writes data to the specified file, such as-e write=1
-R Prints the relative time of each system call
-T plus time information in front of each line in the output
-tt with time information before each line in the output, the time is accurate to the microsecond level
-TTT add time information to each line in the output as relative time
-s Specifies the length of each line of output string (default is 32)
examples of strace use:
Strace-t whoami #跟踪whoami可执行程序, print execution time before output 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 compiles with the-G parameter, which allows the executable program to add GDB debugging information.
(1) Info
Shorthand: I, lists information for GDB subcommands, such as info break,info variables,info stack, and so on.
(2) List [file:]function
Shorthand: l, view the context of the current line, default to 10 rows, or set the source code to be listed at a function.
(3) Edit [file:]function
Shorthand: E, edit the current line, or edit the source code of a function.
(4) Break [file:]function
Shorthand: B, set breakpoints, can be set on a line or a function.
(5) Run [arglist]
Abbreviation: R, run the program to the breakpoint stop, after the Run command can be added to the parameters required by the debugger.
(6) Next
Shorthand: N, single statement execution.
(7) Continue
Shorthand: C, continue to run the program to the next breakpoint.
(8) Print
Shorthand: p, prints the value of the variable.
(9) bt
View function stack information.
(Ten) Enter
Enter to repeat the last debug command.
(one) help [name]
Displays the help information for the specified GDB command.
(a) Quit
Shorthand: Q, Exit gdb.

http://www.bkjia.com/PHPjc/327282.html www.bkjia.com true http://www.bkjia.com/PHPjc/327282.html techarticle Strace and GDB are two common debugging tools in the Linux environment, and this is a summary of the parameters commonly used by individuals in the process of using them for later viewing. Strace Debugging Tools ...

  • 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.