- 帮助信息使用:
(gdb) help x Examine memory: x/FMT ADDRESS. ADDRESS is an expression for the memory address to examine. FMT is a repeat count followed by a format letter and a size letter. Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal), t(binary), f(float), a(address), i(instruction), c(char) and s(string). Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes). The specified number of objects of the specified size are printed according to the format. Defaults for format and size letters are those previously used. Default count is 1. Default address is following last thing printed with this command or "print". (gdb) x/10xb $input1
- 条件断点
break fun1 if loop==1
- 构造输入
(gdb) set $win1 = (winInfo *)malloc(sizeof(winInfo)) (gdb) set $win1->cnt = 1 (gdb) set $win1->sum = 2 (gdb) set $win1->sub = 3 (gdb) c fun3(win1) (gdb) p fun1($win1) $10 = 3 (gdb) set $win1->cnt = 100 (gdb) p fun1($win1) $11 = 99
- 查看指针,查看结构体
(gdb) p win $2 = (winInfo *) 0x8592008 (gdb) p *win $3 = {cnt = 13, sum = 12, sub = 11}
- 打印内存
(gdb) x/10xb $input1 0x8e0c018: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x8e0c020: 0x08 0x09 (gdb) x/10xh $input1 0x8e0c018: 0x0100 0x0302 0x0504 0x0706 0x0908 0x0b0a 0x0d0c 0x0f0e 0x8e0c028: 0x1110 0x1312 (gdb) x/10xw $input1 0x8e0c018: 0x03020100 0x07060504 0x0b0a0908 0x0f0e0d0c 0x8e0c028: 0x13121110 0x17161514 0x1b1a1918 0x1f1e1d1c 0x8e0c038: 0x23222120 0x27262524 (gdb) x/10xg $input1 0x8e0c018: 0x0706050403020100 0x0f0e0d0c0b0a0908 0x8e0c028: 0x1716151413121110 0x1f1e1d1c1b1a1918 0x8e0c038: 0x2726252423222120 0x2f2e2d2c2b2a2928 0x8e0c048: 0x3736353433323130 0x3f3e3d3c3b3a3938 0x8e0c058: 0x4746454443424140 0x4f4e4d4c4b4a4948 (gdb)
GDB使用记录
最新推荐文章于 2023-07-03 22:46:31 发布