Assembly 使用gdb从内存位置读取?
可能重复:Assembly 使用gdb从内存位置读取?,assembly,gdb,Assembly,Gdb,可能重复: 我知道从下面的内存位置读取: mov %esi, (%eax) 在GDB中时,我可以使用 (gdb) display *(int *)$eax 如果要从内存位置0x8(%eax)读取,我可以在GDB中使用哪个命令?我尝试使用上面的display命令的一些变体,但没有成功。如果要在任何新步骤后查看表达式,可以使用display。如果您想观看此表达式,这将非常有用。如果您只是想显示一个表达式的状态,只需使用print 例如: print $eax print *(int *)$
我知道从下面的内存位置读取:
mov %esi, (%eax)
在GDB中时,我可以使用
(gdb) display *(int *)$eax
如果要从内存位置0x8(%eax)读取,我可以在GDB中使用哪个命令?我尝试使用上面的display命令的一些变体,但没有成功。如果要在任何新步骤后查看表达式,可以使用
display
。如果您想观看此表达式,这将非常有用。如果您只是想显示一个表达式的状态,只需使用print
例如:
print $eax
print *(int *)$esp
例如,如果您想查看存储在0x8(%eax)
位置的int
,可以使用
print *(int *)($eax+8)
有时,似乎需要省略寄存器前面的$以使gdb正常工作
下面是32位x86可执行文件上调试会话的简单转储:
d:\temp\C++11>gdb test.exe
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from d:\temp\C++11\test.exe...(no debugging symbols found)...don
e.
(gdb) start
Temporary breakpoint 1 at 0x4013c1
Starting program: d:\temp\C++11\test.exe
[New Thread 340.0x1bc0]
Temporary breakpoint 1, 0x004013c1 in main ()
(gdb) print $eax
$1 = 1
(gdb) info register $eax
eax 0x1 1
(gdb) info register
eax 0x1 1
ecx 0x28ff30 2686768
edx 0x8e3c8 582600
ebx 0x7efde000 2130567168
esp 0x28ff08 0x28ff08
ebp 0x28ff18 0x28ff18
esi 0x0 0
edi 0x0 0
eip 0x4013c1 0x4013c1 <main+17>
eflags 0x202 [ IF ]
cs 0x23 35
ss 0x2b 43
ds 0x2b 43
es 0x2b 43
fs 0x53 83
gs 0x2b 43
(gdb) print *(int *)$esp
$2 = 2686768
(gdb) print *(int *)($esp+8)
$3 = 0
(gdb)
d:\temp\C++11>gdb test.exe
GNU gdb(gdb)7.5
版权所有(C)2012免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。键入“显示复制”
和“显示保修”了解详细信息。
此GDB配置为“i686-pc-mingw32”。
有关错误报告说明,请参阅:
...
正在从d:\temp\C++11\test.exe读取符号…(未找到调试符号)
E
(gdb)启动
0x4013c1处的临时断点1
启动程序:d:\temp\C++11\test.exe
[新螺纹340.0x1bc0]
主()
(gdb)打印$eax
$1 = 1
(gdb)信息寄存器$eax
eax 0x1 1
(gdb)信息登记册
eax 0x1 1
ecx 0x28ff30 2686768
edx 0x8e3c8 582600
ebx 0x7efde000 2130567168
esp 0x28ff08 0x28ff08
ebp 0x28ff18 0x28ff18
esi 0x0 0
电子数据交换0x0
eip 0x4013c1 0x4013c1
eflags 0x202[如果]
cs 0x23 35
ss 0x2b 43
ds 0x2b 43
es 0x2b 43
fs 0x53 83
gs 0x2b 43
(gdb)打印*(int*)$esp
$2 = 2686768
(gdb)打印*(整数*)($esp+8)
$3 = 0
(gdb)