Question

I'm currently working with GDB and NASM for assembly programming.

Unfortunately I am unable to see the EFlags register mnemonics (ZF, AF, PF etc...) inside GDB.

I am being shown a decimal value instead: eflags 0x246 582

I'm sure I could convert the decimal to binary and count the flags myself, but this seems a lot of work for a feature that every one else seems to have?

Operating System: Mountain Lion 10.8.2

GDB Version:

GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Thu Nov 15 10:42:43 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".
Was it helpful?

Solution

Your version of gdb is very old. In case it does not have that functionality implemented, here's a gdb function I'm using to print the contents of eflags:

define eflags
    printf "     OF <%d>  DF <%d>  IF <%d>  TF <%d>",\
           (($eflags >> 0xB) & 1), (($eflags >> 0xA) & 1), \
           (($eflags >> 9) & 1), (($eflags >> 8) & 1)
    printf "  SF <%d>  ZF <%d>  AF <%d>  PF <%d>  CF <%d>\n",\
           (($eflags >> 7) & 1), (($eflags >> 6) & 1),\
           (($eflags >> 4) & 1), (($eflags >> 2) & 1), ($eflags & 1)
    printf "     ID <%d>  VIP <%d> VIF <%d> AC <%d>",\
           (($eflags >> 0x15) & 1), (($eflags >> 0x14) & 1), \
           (($eflags >> 0x13) & 1), (($eflags >> 0x12) & 1)
    printf "  VM <%d>  RF <%d>  NT <%d>  IOPL <%d>\n",\
           (($eflags >> 0x11) & 1), (($eflags >> 0x10) & 1),\
           (($eflags >> 0xE) & 1), (($eflags >> 0xC) & 3)
end
document eflags
Print EFLAGS register. (x86)
end

OTHER TIPS

To see the set flags:

info registers eflags
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top