[C/C ++] GDB Reading Notes (resend)

Source: Internet
Author: User
Tags print print

Press:

Understanding the basic commands can give developers a better understanding of the debugger than fully packaged by IDE, so I will post an article.

 

Breakpoint commands:
Awatch is used to set an observation point for an expression. When the expression value changes, or when the expression value
When the program is deprecated, it stops running.
Format: Specifies the expression of the observation point for awatch.
Break is used to set breakpoints.
Format: The line number of the breakpoint to be set for the break.
Clear the breakpoint.
Format: The line number of the breakpoint to be clear
Commands is set to execute specific commands after a breakpoint occurs.
Format: commands breakpoint number.
Condition sets a breakpoint on the specified row only when certain conditions are met.
Format: Conditional breakpoint number condition expression
Delete indicates the breakpoint or automatically displayed expression.
Format: Number or expression of the delete breakpoint
Disable temporarily invalidates the breakpoint.
Format: Disable breakpoint number
Enable resumes temporarily invalid breakpoints.
Format: Enable breakpoint number
Ignore ignores breakpoints set by users within a certain range.
Format: Ignore n cont
Set a temporary breakpoint for tbreak. Function once.
Format: tbreak: Set the line number of a temporary breakpoint
Watch sets an observation point for an expression. When the expression value changes, the program stops running.
Format: Expression of the observation point to be set for watch
Data commands:
Display is used to display the values of some expressions.
Format: Expression of the value to be displayed in display
Info display displays information about all worthwhile expressions.
Format: info display
Delete display deletes a worthwhile expression to be displayed.
Format: delete display: Delete the number of the displayed expression
Disable display temporarily shields expressions that do not need to be displayed.
Format: disalbe display: Number of the expression that is blocked
Enable display enables the expression with the displayed value blocked to resume display.
Format: Number of the expression to be displayed for enable display
Undisplay ends the display of an expression value.
Format: undisplay expressions that do not need to display the value
Whatis displays the data type of an expression.
Format: whatis expression of the query type
Print print expression value. It can also be used to print the content of a region starting from a variable in the memory.
Format: expression to be printed for print
Ptype is used to define the type.
Format: ptype Parameter
Set is used to assign values to variables.
Format: Set variable = expression
File commands:
Add-shared-symbol-files is used to load the symbol table from the shared target file of the dynamic connection ing.
Add-symbol-file is used to load the symbol table from a file that has been dynamically loaded.
Format: Add-symbol-file ADDR
CD is used to change the current working directory.
Core-file makes a file a core dump, which can check the memory and registers.
Directory is used to add a directory to the source file search path.
Format: directory to be added
The file command is used to mount the program to be debugged.
Format: name of the file to be loaded
List is used to list object content.
The list command can use the following non-empty parameters:
Linenum: linenum row of the current file;
File: linenum: Specifies the linenum row of the file;
Function: the function of the current file;
File: function: Specifies the function of a file;
* Address: list the files containing this address.
Format: start line number of the List
Forward is used to search for the first program row that matches a string from the current row in the list.
Format: string to be matched by forward
Load is used to dynamically load files into the program being debugged, record its symbol table, and prepare the connection.
Format: name of the file to be loaded by load
PATH is used to add a directory to the search path of the target file.
Format: directory name to be added to the search path
Reverse-search searches for the first program row that matches a string from the current row in the list.
The usage of the search and forward commands is exactly the same.
Command for running the program:
Cont enables the program to run after the word signal occurs or stops at the breakpoint.
Handle is used to set the processing function for the signal.
Format: handle Signal Processing
Jump is used to specify the instruction or address for the program to start debugging.
Format: Jump line number or command address
Kill is used to end debugging of the current program.
Format: Kill
Next is used to continue running the program. It is called beyond the subroutine.
Format: Next N or null
Nexti is used to execute an instruction in one step.
Step is used to execute a statement. Instead of calling a subroutine, it traces the subprogram.
Stepi is used to execute an instruction. It does not go beyond the calling of the subprogram, But traces to the subprogram.
Stack commands:
Backtrace is used to print the stack trim (stack frame) pointer. Its format and functions are identical to those of commands.
.
Format: Number of stack history pointers to be printed by backtrace
Frame is used to print the stack metadata.
Format: Number of the stack marker to be printed by the frame
Select-frame is used to specify the number of stack shards to be selected.
I learned/reviewed the command summary written during GDB... I hope to help you.
Written by choatrue

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.