GDB Operation Basic Command

Source: Internet
Author: User

GDB Operation Basic Command 1 open file and exit operation

Shell input GDB filename: Open a single file

GDB filename-q: Open a single file and block out GdB's own instructions

GDB input Quit (q), exit debugging

2 GDB Command
Command Abbreviation Explain
File filename Open File under GdB
List L

Displays the code, which displays 10 rows by default. Enter ENTER to display the next 10 lines

The list can include additional parameters, such as:

List 5,10 shows the code from line 5th to line 10th;

The list func shows the code around the Func function, and the display range is related to the list parameter;

List test.c:5,10 Displays the code for the source file test.c lines 5th through 10th,

Typically used to debug a program with multiple source files.

Shell Clear Empty the shell, clear the screen
Break Linenumber/funname B

Break 6: Make a breakpoint on line 6th, or break a point on a function

Conditional breakpoint:

Break 6 if n = = 0, triggers a breakpoint when the variable n==0

Info I

Info Breakpoints (i B): Show All Breakpoints

Info Source View Current Program

Info Stack View stack information

Info args View current parameter values

Info reg outputs The current value of all registers

The use of the info frame output stack frame

Info b n where n is the specified breakpoint number, displays the state information of the specified breakpoint, and displays information for all breakpoints when no parameter n is added

Disable Breaknumber Disable 1: Make breakpoint 1 unable to be triggered
Clear Breaknumber Clear 1: Delete N-line breakpoints
Delete Breaknumber Delete N Breakpoint, delete all breakpoints by default
Run R Execute the program
Next N The next statement does not enter the function
Continue C Continue execution
Step S Stepping will enter the function body
Print variable name or expression Print the variable or the value of the expression
Whatis variable name or expression Displays the data type of the variable or expression
Set variable variable = value Assign a value to the corresponding variable
Watch variable Sets the watch variable, which triggers when the value of the variable changes
Finish Jump out of the current function

GDB Operation Basic Command

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.