【问题标题】:Read from memory location using gdb? [duplicate]使用gdb从内存位置读取? [复制]
【发布时间】:2012-11-08 05:04:09
【问题描述】:

可能重复:
Using gdb to check register’s values

我知道要从下面的内存位置读取:

 mov %esi, (%eax)

在 GDB 中我可以使用

 (gdb) display *(int *)$eax

如果想从内存位置 0x8(%eax) 读取,我可以在 GDB 中使用哪个命令?我尝试使用上面显示命令的一些变体,但没有成功。

【问题讨论】:

    标签: assembly gdb


    【解决方案1】:

    如果您想在任何新步骤之后查看表达式,可以使用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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-24
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-22
      • 2018-04-26
      • 2015-05-10
      相关资源
      最近更新 更多