printinggdboffsetdisplayoperand

How does gdb use register as address and display offset content?


In gdb:

p $ebp #will print content pointed by ebp

p 4$ebp # gdb says this is illegal operand.

I wish to show 4 bytes after the address pointed by ebp, and display an int. How to specify this command in gdb?


Solution

  • p $ebp #will print content pointed by ebp

    No, it will print the value of $EBP.

    I wish to show 4 bytes after the address pointed by ebp, and display an int.

    (gdb) x/x $EBP+4
    (gdb) x/d $EBP+4
    (gdb) p *(int*)($EBP+4)