In gdb x86_64 environment, like below example, when I tried to extract field value of $eflags to use as a breakpoint condition element, I got an error.
(gdb) cond 1 ($eflags & 0x200) != 0
(gdb) continue
Continuing.
Error in testing breakpoint condition:
Invalid cast.
[Switching to Thread 1.1]
Ofcourse, when extracting a specific field of $eflags, like p $eflags & 0x200
, I got also Invalid cast
error.
How to get a specific field from $eflags?
I do not know whether it is related or not, I debug a Rust program.
Environment
Thanks.
p $eflags & 0x200
This doesn't work because:
(gdb) ptype $eflags
type = flag i386_eflags {
bool CF @0;
bool @1;
bool PF @2;
bool AF @4;
bool ZF @6;
bool SF @7;
bool TF @8;
bool IF @9;
bool DF @10;
bool OF @11;
bool NT @14;
bool RF @16;
bool VM @17;
bool AC @18;
bool VIF @19;
bool VIP @20;
bool ID @21;
}
However, you can cast $eflags
to int
:
(gdb) p $eflags
$1 = [ IF ]
(gdb) p/x (int)$eflags
$2 = 0x202
(gdb) p/x (int)$eflags & 0x2
$3 = 0x2