Command |
Describe |
Help |
Lists GDB help information. |
Help Topic |
Lists the GDB commands in the related topic. |
Help command |
Lists command description information. |
Apropos Search-word |
Search for related topics. |
Info args I-args |
Lists the command-line arguments that run the program. |
Info Breakpoints |
Lists breakpoints. |
Info break |
Lists the breakpoint number. |
Info Break Breakpoint-number |
Lists information for the specified breakpoint. |
Info watchpoints |
Lists the observer points. |
Info Registers |
Lists the registers used. |
Info threads |
Lists the current thread. |
Info set |
Lists the options you can set. |
Break and Watch |
|
Break funtion Break Line-number |
Sets a breakpoint at the specified function, or at the line number. |
Break +Offset Break-Offset |
Sets a breakpoint at the front or several lines in the current place of stay. |
Break File:func |
Sets a breakpoint at the func in the specified file file. |
Break File:nth |
Sets a breakpoint in the nth line in the specified file file. |
Break *Address |
Sets a breakpoint at the specified address. Generally used when there is no source code. |
Break line-number ifcondition |
If the condition is met, set the breakpoint at the specified location. |
Break Line threadthread-number |
Interrupts in the specified thread. Use info threads to display the thread number. |
Tbreak |
Sets a temporary breakpoint. Breakpoints are deleted after a break. |
Watch Condition |
Sets the observer point when the condition is met. |
Clear Clear func Clear Nth |
Clears the breakpoint at the function func . Clears the breakpoint at line Nth . |
Delete D |
Delete all breakpoints or observer points. |
Delete Breakpoint-number Delete range |
Deletes the specified breakpoint, the Observer point. |
Disable breakpoint-number-or-range Enable Breakpoint-number-or-range |
Do not delete the breakpoint, just set it to invalid, or valid. Example: Show Breakpoint: Info break Invalid setting: Disable 2-9 |
Enable onceBreakpoint-number |
Sets the specified breakpoint to be valid, which is not valid when the breakpoint is reached. |
Enable del Breakpoint-number |
Sets the specified breakpoint to be valid and removes it when the breakpoint is reached. |
Finish |
Continue execution to the end of the function. |
Line execution |
|
Step S Step number-of-steps-to-perform |
The execution of the next line of code goes inside the function. |
Next N Next number |
Executes the next line of code. But it doesn't go inside the function. |
Until Until line-number Until line-number ifcondition |
Continue running until you reach the specified line number, or function, address, and so on. |
Return return expression |
POPs the selected stack frame. If the parameter is specified later, the value of the expression is returned. |
Stepi Si Nexti Ni |
Executes the next assembly/CPU directive. |
Info signals Info handle Handle signal-nameoption |
When the signal is received, the following actions are performed: Nostop (do not stop program), Stop (Stop program execution), print (display signal), noprint (not shown), Pass/noignore (allows the program to process the signal), nopass/ Ignore (do not allow the program to accept the signal) |
where |
Displays the current line number and the function in which it is located. |
Program Stack |
|
BackTrace Bt BT inner-function-nesting-depth BT-outer-function-nesting-depth |
Displays the current stack's trace, the current function. |
BackTrace full |
Prints the values of all local variables. |
Frame Number F number |
Selects the specified stack frame. |
Up number Down number |
Moves the specified number of stack frames up or down. |
Info Frame Addr |
Describes the selected stack frame. |
Info args Info All-reg Info locals Info catch |
Displays the parameters of the selected stack frame, local variables, exception handling functions. All-reg also lists floating-point registers. |
Source Code |
|
List L List Line-number List function List- List start#,end# List filename:function |
List the corresponding source code. |
Set Listsize Count Show Listsize |
Sets the number of lines when the list command prints the source code. |
Directory Directory-name Dir directory-name Show directories |
Adds the specified directory before the source code path. |
Directory |
When no parameters are followed, clear the source code directory. |
Examine Variables |
|
Print variable P Variable P file::variable P 'file'::variable |
Prints the value of the specified variable. |
P *Array-var@length |
Prints the first length entry in the Arrary-var . |
p/x var |
The integer variable varis printed in hexadecimal. |
P/d var |
The variable var is printed as a signed integer. |
P/u var |
The variable var is printed as an unsigned integer. |
p/o var |
The variable var is printed as an octal number. |
p/t var x/b Address x/b &Variable |
Prints the value of the var variable in integer binary form. |
P/C Variable |
When characters are printed. |
p/f Variable |
Print variable varin floating-point format. |
P/A Variable |
Prints the address in hexadecimal form. |
x/w Address X/4B &Variable |
Prints the specified address in a four-byte set of ways. |
Call expression |
Similar to print, but void is not printed. |
Disassem Addr |
The instructions in the specified address are disassembled. |
Controlling GDB |
|
Set gdb-option value |
Sets the options for GDB. |
Set Print array on Set Print array off Show Print Array |
Prints an array in readable form. The default is off. |
Set Print array-indexes on Set Print array-indexes off Show Print Array-indexes |
Prints the subscript of an array element. The default is off. |
Set Print pretty on Set print pretty off Show Print Pretty |
Formats the output of the C-struct body. |
Set Print Union on Set Print union off Show Print Union |
Print a union in C. The default is on. |
Set Print Demangle on Set Print Demangle off Show Print Demangle |
Controls the printing of names in C + +. The default is on. |
Working Files |
|
Info files Info share |
Lists the current files, shared libraries. |
File file |
Take file as a debugging program. If no parameters are specified, discard. |
Core file |
Take file as a core file. If no parameter is specified, it is discarded. |
exec file |
Consider file as the executing procedure. If no parameter is specified, it is discarded. |
Symbol file |
Reads the symbol table from file . If no parameter is specified, it is discarded. |
Load file |
Dynamically chain into the file and read its symbol table. |
Path directory |
Add directory directories to the path of the search executable and symbol files. |
Start and Stop |
|
Run R Run command-line-arguments Run < infile > outfile |
Execute the program from the beginning, and also allow redirection. |
Continue C |
Resumes execution until the next breakpoint or observer point. |
Continue Number |
Continues execution, but ignores the current breakpoint number times. Useful when breakpoints are in a loop. |
Kill |
Stop program execution. |
Quit Q |
Exit the GDB debugger. |