# Include <iostream> int teststring () {char szbuff [1024]; memset (szbuff, 0, sizeof (szbuff); snprintf (szbuff, sizeof (szbuff ), "% s", "abcdefg01 \ 023 \ 0456 \ R78 \ partition"); int * Parr = new int [20]; for (INT I = 0; I <20; I ++) {Parr [I] = I; Parr [I] = I + 1; Parr [I] = I + 2;} printf ("% d \ n ", parr [1]); printf ("% d \ n", Parr [2]); Return 0 ;}int main () {teststring (); Return 0 ;}
2 -- Process Control commands
Exit loop command: "U" or "until row number"
Breakpoint 1, teststring () at togdb. CPP: 1212 for (INT I = 0; I <20; I ++) (GDB) N14 Parr [I] = I; (GDB) u15 Parr [I] = I + 1; (GDB) 16 Parr [I] = I + 2; (GDB) 12 for (INT I = 0; I <20; I ++) (GDB) 20 return 0; (GDB)
Run the "U" command in the loop body. After executing the statements in the loop body, jump to the for statement and press the "enter" key to stop entering the loop body, skip the statement after the for loop is executed.
You can also use "until 20" to directly jump to the statement outside the for loop to start execution.
3 -- view memory commands and Methods
Use the EXAMINE command (X) to view the value in the memory address. Command Format:
X/NFU <ADDR>
| parameter n |
indicates the number of memory units to be displayed |
| parameter F |
indicates the display mode. The value can be as follows: X displays variables in hexadecimal format (HEX ); A display variables in hexadecimal format (Address); D Display variables in decimal format (decimal ); U displays unsigned integer (unsigned decimal) in decimal format; O displays variables in octal format (octal ); T display variables in binary format (Binary); I command address format (Instruction); C display variables in character format, C (char); F display variables in floating point format (float) |
| parameter U |
indicates the length of an element unit. Values: B indicates a single byte (byte); h indicates a double byte, (halfword); W indicates four bytes, (Word); G indicates octal, (giant, 8 bytes) |
for example, run the following command to display the first 100 bytes in the szbuff cache:
X/100cb szbuff indicates that 100 elements are read from szbuff, each of which is 1 byte and displayed in characters;
X/100xb szbuff indicates that 100 elements are read from szbuff, each of which is 1 byte and displayed in hexadecimal format;
X/100xh szbuff indicates that 100 elements are read from szbuff. Each element contains 2 bytes and is displayed in hexadecimal format, actually reads 200 bytes.