重複の可能性:
gdb を使用してレジスタの値をチェックする
以下のメモリの場所から読み取ることを知っています:
mov %esi, (%eax)
GDBでいつ使用できるか
(gdb) display *(int *)$eax
メモリ位置 0x8(%eax) から読み取りたい場合、GDB でどのコマンドを使用できますか? 上記の表示コマンドのいくつかの変形を使用しようとしましたが、成功しませんでした。
重複の可能性:
gdb を使用してレジスタの値をチェックする
以下のメモリの場所から読み取ることを知っています:
mov %esi, (%eax)
GDBでいつ使用できるか
(gdb) display *(int *)$eax
メモリ位置 0x8(%eax) から読み取りたい場合、GDB でどのコマンドを使用できますか? 上記の表示コマンドのいくつかの変形を使用しようとしましたが、成功しませんでした。
display
新しいステップの後に式を見たい場合に使用できます。これは、この式を見たい場合に便利です。単に式の状態を表示したい場合は、 を使用してprint
ください。
例えば:
print $eax
print *(int *)$esp
int
たとえば、保存されている場所を調べたい場合は、0x8(%eax)
使用できます
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)