Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb with assembler: Print status of carry flag

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"?

like image 310
Hinton Avatar asked Mar 06 '11 12:03

Hinton


2 Answers

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.

like image 72
paxdiablo Avatar answered Oct 18 '22 07:10

paxdiablo


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.

like image 32
Jamie O'Sullivan Avatar answered Oct 18 '22 05:10

Jamie O'Sullivan