Linux GDB Common Commands summary

Source: Internet
Author: User

View GDB's version number (1) rpm-q gdb will show if GDB is installed and the version number (2) GDB--version can also

Breakpoint b Main; b 20; Set breakpoints
Breakpoint If Break function name, number if XXXX Breakpoints set in the case of XXX do not take effect (XXX For example: variable = 3)
Cd cd/home/yongchao/ Change the current working directory
Clear The cursor is on the line of the break point that is about to be executed, and then hit clear Delete a breakpoint at the stop
Info b Info b To view all breakpoints
Continue Continue Continue execution from Breakpoint
Enable Enable Breakpoint number Make a breakpoint effective
Disable Disable Breakpoint number Make a breakpoint invalid
Delete Delete Breakpoint Number Delete a breakpoint
Delete Delete Delete all Breakpoints
Display Display variables, expressions Displays the value of the variable or expression when the program stops (always displayed until the display is canceled)
Info display Info display Displays the variable number of the display
Undisplay Undisplay number Cancel a number always appears
Step S Jump into function
Until Until Execute directly to the function at the end or jump out of a loop
Finish Finish If you have entered a function and want to exit the function to return to its calling function
Shell Shell Linux Commands Enables you to execute UNIX shell commands without leaving GDB.
Print Print variables Print variables
Print Print variable = 2 Assigning a value to a variable 2
Print Print Find_entry (1,0) Calls to functions in a program
Print Print array[0]@5 (cannot be [email protected]) View the 5 elements of an array
Pager Call Find_entry (1,10) Calling and executing functions
Pwd Pwd Show Current working directory
PType Ptyoe variable Display the structure of a class, struct
Whatis Whatis variable/function type Show declaration of variable/function type
Watch Watch variable Observe the value of the variable and stop when there is a change

The steps are as follows when using watch:

1. Use break to set a power outage at the point where the variable is to be observed;

2. Use Run to execute until the breakpoint;

3. Use watch to set the observer point;

4. Use continue to see if there are any changes to the observed points set.

Watch COUNTER>15 The program terminates when Counter>15.
Delete watch number Delete watch number Delete Watch points
Make Make You can regenerate the executable file without exiting GDB
X X/3 memory Address The number of memory units that need to be displayed, that is, the contents of several memory units are displayed backwards from the current address, and the size of a memory unit is defined by the following U
x/f memory Address f indicates the format of the display:

x Displays the variable in hexadecimal format.

D Displays the variable in decimal format.

u displays unsigned integers in decimal format.

o Displays the variable in octal format.

T displays the variable in binary format.

A displays the variable in hexadecimal format.

I instruction address format

C Displays the variable in character format.

F Displays the variable in floating-point number format.

x/u memory Address

U represents the length of an address unit

b represents a single byte,

H represents double-byte,

W represents four bytes,

g = Eight bytes

X/3DW memory Address Print 3 x Four bytes, install 10 binary format
where where Use the where command to see where the program went wrong

GDB A.out Core

where

View the cause of the crash

Linux GDB Common Commands summary

Related Article

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.