View stack Information
Bt
Info stack
View Source Program
List
Foucs (FS) command, which can highlight the execution position of the current statement, and also follow the change in stepping
View Memory
P [email protected] View xxxptr pointer content start continuous n bytes of memory
You can use the Examine command (abbreviated as x) to view the values in the memory address. The syntax for the x command is as follows:
X/<n/f/u> <addr>
n indicates the length of the memory, meaning that the contents of several addresses are displayed backwards from the current address.
f indicates the format of the display, if it is a string, use S, if it is a number, you can use I.
U represents the number of bytes requested from the current address, and the default is 4 bytes. (b single-byte, H-DWORD, w four bytes, g eight bytes)
<addr> represents a memory address.
Watch Window
In VisualStudio, you can view the value of a variable dynamically through the Watch window. In GdB, a similar command display is provided, and its syntax is:
Display <expr>
Display/<fmt> <expr>
Display/<fmt> <addr>
Expr is an expression, FMT represents the format shown, and addr represents a memory address. When you set up one or more expressions with display, GDB automatically displays the values of the expressions you set as long as your program is stopped (step-by-trace).
Several related commands are as follows:
- Undisplay <dnums...> not show dispaly
- Delete display [dnums] removes auto-displays, removes all auto-displays without the Dnums parameter, and also supports range deletion, such as: Delete Display 1,3-5
- Disable Display <dnums...> disable display
- Enable Display <dnums...> Restore display
- Info Display View display information
Some of GDB's tricks