Search code examples
cassemblygdbcpu-registerscmp

computing the actual address from assembly in cmp


I am using gdb in order to debug my code, still a beginner
I wanted to know how to get the actual address
For example, given the following assembly code:
cmp %eax, 0x4(%rbp,%rbx,4)

I want to know what is being compared with %eax, in other words i want to know what is in: 0x4(%rbp,%rbx,4)


Solution

  • If you don't know at&t syntax, switch gdb to intel syntax using set disassembly-flavor intel. Then you will see this expression is really rbp+rbx*4+4. Then read gdb help and you will find the x (examine memory) command and that you can access registers using $ prefix. Putting all this together, you should type x $rbp+$rbx*4+4 to see the contents.