gdb with assembler: Print status of carry flag
37,736
Solution 1
You can use:
info registers eflags
to get the entire set of flags. You'll see a line like:
eflags 0x41 [ CF ZF ]
which means that the eflags
register is set to 0x41
, with the carry and zero flags set.
Solution 2
I check the EFLAGS register using
(gdb) p $eflags
$3 = [ PF ZF IF ]
where "p" is just short for the "print" command.
I also find it helpful to see the bits using "/t" ( also /x for hex, /d for decimal).
(gdb) p/t $eflags
$4 = 1001000110
You can then compare with the chart for the EFLAGS register.
![Hinton](https://i.stack.imgur.com/uD53K.png?s=256&g=1)
Author by
Hinton
Updated on April 06, 2020Comments
-
Hinton about 4 years
I've got an x86 assembler program which I'm debugging with gdb. Is there a way to print the status of the carry flag inside gdb with, like, "print $cf"?
-
Employed Russian over 13 yearsYou can also
'print $eflags'
, or'print/x $eflags'
-
Hinton over 13 yearsthanks a lot! could you help me find the "accept answer" checkbox on this page ^^ ? EDIT AH ok just the big check mark
-
Hinton over 13 years@Employed Russian: If you post this as an answer, I'll vote you up too