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.

Share:
37,736
Hinton
Author by

Hinton

Updated on April 06, 2020

Comments

  • Hinton
    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
    Employed Russian over 13 years
    You can also 'print $eflags', or 'print/x $eflags'
  • Hinton
    Hinton over 13 years
    thanks a lot! could you help me find the "accept answer" checkbox on this page ^^ ? EDIT AH ok just the big check mark
  • Hinton
    Hinton over 13 years
    @Employed Russian: If you post this as an answer, I'll vote you up too