如果我的汇编代码......
0x08048cc4 <+0>: push %ebp
0x08048cc5 <+1>: mov %esp,%ebp
0x08048cc7 <+3>: push %esi
0x08048cc8 <+4>: push %ebx
0x08048cc9 <+5>: sub $0x20,%esp
0x08048ccc <+8>: lea -0x10(%ebp),%eax // input 3
0x08048ccf <+11>: mov %eax,0xc(%esp)
0x08048cd3 <+15>: lea -0xc(%ebp),%eax // input 2
0x08048cd6 <+18>: mov %eax,0x8(%esp)
0x08048cda <+22>: movl $0x804a1aa,0x4(%esp)
0x08048ce2 <+30>: mov 0x8(%ebp),%eax // input 1
0x08048ce5 <+33>: mov %eax,(%esp)
0x08048ce8 <+36>: call 0x804870c <__isoc99_sscanf@plt>
如果我将断点设置为&lt; + 36&gt;,是否可以打印输入1,2,3的值? ?
我知道我可以保持在&lt; + 8&gt;并做一些(gdb)我每次都得到%eax。但是在&lt; + 36&gt;的一个断点处有更好的方法吗?
我的输入是14,15(输入2,输入3) 输入1是格式(“%d,%d”)
我曾尝试做类似的事情,但还不太明白我在读什么......
(gdb) x /20wx $esp
0xbffff070: 0x0804b820 0x0804a1aa 0xbffff08c 0xbffff088
0xbffff080: 0x00000001 0x7a000002 0x00000073 0x0000000e
0xbffff090: 0xbffff168 0xbffff164 0xbffff0c8 0x08048a4d
0xbffff0a0: 0x0804b820 0x08049f2c 0x00000000 0xb7e5164d
0xbffff0b0: 0xb7fc93c4 0xb7fff000 0xb7fc9000 0x00000000
(gdb) x /20wx $ebp
0xbffff098: 0xbffff0c8 0x08048a4d 0x0804b820 0x08049f2c
0xbffff0a8: 0x00000000 0xb7e5164d 0xb7fc93c4 0xb7fff000
0xbffff0b8: 0xb7fc9000 0x00000000 0x08049e60 0x00000000
0xbffff0c8: 0x00000000 0xb7e37a83 0x00000002 0xbffff164
0xbffff0d8: 0xbffff170 0xb7feccea 0x00000002 0xbffff164
(gdb) x /20wd $ebp
0xbffff098: -1073745720 134515277 134527008 134520620
0xbffff0a8: 0 -1209723315 -1208183868 -1207963648
0xbffff0b8: -1208184832 0 134520416 0
0xbffff0c8: 0 -1209828733 2 -1073745564
0xbffff0d8: -1073745552 -1208038166 2 -1073745564
答案 0 :(得分:1)
尚未调用+36 sscanf
,因此您只能看到您调用input2/3
的两个输出变量的随机内存垃圾。
Input1
不是格式,而是要解析的字符串。
该调用的内容如下:sscanf(input1, "%d %d", &input2, &input3)
您当然可以使用x/s $eax
input1
和x/d
input2/3
来检查变量:
(gdb) x/s $eax
0xffffdba6: "14 115"
(gdb) ni
(gdb) x/d $ebp-0xc
0xffffd97c: 14
(gdb) x/d $ebp-0x10
0xffffd978: 115
(注意我在input1
之前打印了sscanf
,但之后打印了其他人。{)
有关格式说明符,请参阅gdb帮助。