4

メモリの場所がわかっている場合、GDB からメモリの内容を確認する方法はありますか?

つまり、オペレーティング システム コース用に書いた x86 アセンブリ プログラムをデバッグしています。現在、C とガス (GNU アセンブラー) を使用して x86 上の Linux 用のユーザー レベルのスレッド ライブラリを作成しようとしています。独自のスタックを割り当て、esp レジスターがそのメモリー位置を指すようにしました。ここで、メモリを読み取って、割り当てたスタックに何があるかを確認します。

4

2 に答える 2

7

次のコマンドのようなものを試します(下gdb

 p (int*)$esp
 x /20x $esp
 p ((int*)$esp)[3]
于 2013-03-30T14:46:53.837 に答える
5

x addr詳細については、https://visualgdb.com/gdbreference/commands/xをご覧ください。

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.
于 2013-03-30T14:46:25.433 に答える