如何从 x86-64 中的 gdb 访问 r8-r15 的低字节寄存器? [英] How do you access low-byte registers for r8-r15 from gdb in x86-64?
问题描述
在 gdb 中,我似乎无法访问任何伪寄存器:r8b
、r9b
、r10b
、r11b
、r12b
、r13b
、r14b
和 r15b
(但是,r15d
和 r15w
似乎可以工作,sil
也一样).
In gdb, I can't seem to access any of the pseudo-registers: r8b
, r9b
, r10b
, r11b
, r12b
, r13b
, r14b
, nor r15b
(however, r15d
and r15w
seem to work, and same for sil
).
看一个例子:
section .text
global main
main:
xor esi, esi
mov sil, 0x1f
xor r13d, r13d
mov r13b, sil
ret
使用 gdb
运行:
(gdb) p $sil
$1 = -15
(gdb) p $r13
$2 = 241
(gdb) p $r13b
$3 = void
(gdb) p /x $r13b
$4 = 0x0
我在 gdb 中找不到任何内容手册,它们不是用 info all-registers
命令打印的.我正在使用 GDB 10.
I couldn't find anything in the gdb manual, and they aren't printed with the info all-registers
command. I'm using GDB 10.
推荐答案
您可以使用 l
后缀来引用这些寄存器的低字节:
You can reference to the low byte of those registers using the l
suffix:
r8l
、r9l
、r10l
、r11l
、r12l
、r13l
, r14l
, r15l
.
(gdb) p $r13l
$1 = -15
(gdb) p /x $r13l
$2 = 0xf1
除了在 gdb 代码库:
/* Register names for byte pseudo-registers. */
static const char * const amd64_byte_names[] =
{
"al", "bl", "cl", "dl", "sil", "dil", "bpl", "spl",
"r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l",
"ah", "bh", "ch", "dh"
};
此外,gdb 代码库中有 是一个错误如果为 print
命令指定格式,则为 0 而不是 void,就像在上一个示例中发生的那样.如果您要打印的值未定义,则 gdb 的未来版本应显示 void
.
Furthermore, there was a bug in the gdb codebase that would print 0 instead of void if a format is specified to the print
command, as it happens in the last example. Future versions of gdb should display void
if the value that you are printing is not defined.
这篇关于如何从 x86-64 中的 gdb 访问 r8-r15 的低字节寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!