Search code examples
assemblygdbcmp

How to get values used by cmp in assembly language with gdb?


I have a program comparing two values and I would like to print them for debug :

   0x00000000004005cd <+73>:    mov    DWORD PTR [rbp-0x4],eax
   0x00000000004005d0 <+76>:    mov    eax,DWORD PTR [rbp-0x4]
=> 0x00000000004005d3 <+79>:    cmp    eax,0x1e240
   0x00000000004005d8 <+84>:    jne    0x4005e6 <main+98>

So i placed a breakpoint on main+79 and I would like to print the values being compared by the cmp call.

How can I achieve that with gdb?

Thanks for your help.


Solution

  • CMP is not a call - it's a single instruction. To see the current value of EAX, use the following command:

    info registers eax
    

    The other comparand is the hex value 0x1e240. It's not an address, it's an integer constant.