Search code examples
debuggingubuntuassemblygdbvmware-workstation

Ubuntu gdb can't access memory at address when tryint to view memory at $esp


enter image description here

Hi,

I am running ubuntu on VMWARE and when i try to access the memory at $esp,I get the error as shown in the screenshot below.I've tried googling for answers but most of them were too complicated.

Is there any configuration I need to do for this to work?

I've tried running gdb on my actual windows machine and it does not have this issue.

Thanks.


Solution

  • You want $rsp, not $esp.

    By using $esp, you got the sign-extended 32-bit-truncated value of $rsp, which points to neverland.

    Note: GDB provides $sp pseudo-register that is automatically mapped to correct stack pointer register for a given platform.

    (gdb) p $rsp
    $1 = (void *) 0x7fffffffe178
    (gdb) p $sp
    $2 = (void *) 0x7fffffffe178
    (gdb) p $esp
    $3 = -7816
    (gdb) p/x $esp
    $4 = 0xffffe178