首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GDB读取寄存器指向的内存

使用GDB读取寄存器指向的内存
EN

Stack Overflow用户
提问于 2013-03-30 22:43:29
回答 2查看 6.2K关注 0票数 4

如果我知道内存位置,有没有办法查看GDB中的内存内容?

也就是说,我正在调试我为操作系统课程编写的x86汇编程序。现在,我正在尝试用C和gas (GNU assembler)为x86上的Linux编写一个用户级线程库。我分配了自己的堆栈,并使esp寄存器指向该内存位置。现在,我想要读取内存,以查看我分配的堆栈中有什么。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-30 22:46:54

我会尝试下面这样的命令(在gdb下)

代码语言:javascript
复制
 p (int*)$esp
 x /20x $esp
 p ((int*)$esp)[3]
票数 7
EN

Stack Overflow用户

发布于 2013-03-30 22:46:25

有关更多详细信息,请使用x addr查看https://visualgdb.com/gdbreference/commands/x

代码语言:javascript
复制
x command
Displays the memory contents at a given address using the specified format.

Syntax
x [Address expression]
x /[Format] [Address expression]
x /[Length][Format] [Address expression]
x
Parameters
Address expression
Specifies the memory address which contents will be displayed. This can be the address itself or any C/C++ expression evaluating to address. The expression can include registers (e.g. $eip) and pseudoregisters (e.g. $pc). If the address expression is not specified, the command will continue displaying memory contents from the address where the previous instance of this command has finished.
Format
If specified, allows overriding the output format used by the command. Valid format specifiers are:
o - octal
x - hexadecimal
d - decimal
u - unsigned decimal
t - binary
f - floating point
a - address
c - char
s - string
i - instruction
The following size modifiers are supported:

b - byte
h - halfword (16-bit value)
w - word (32-bit value)
g - giant word (64-bit value)
Length
Specifies the number of elements that will be displayed by this command.
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15719750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档