0

I want to print 1 words from the top of stack in the form of hexadecimal. To do so, I typed the following:

(gdb) x/1xw $esp

but GDB keeps popping up:

0xffffffffffffe030: Cannot access memory at address 0xffffffffffffe030

The program I'm trying to debug has already pushed a value onto stack so just in case if you're wondering that I might be trying to access kernel variables at the very beginning of program, it's not so. Any idea?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
7_R3X
  • 3,904
  • 4
  • 25
  • 43

1 Answers1

3

0xffffffffffffe030 is a 64-bit constant, so you are running in x64-bit mode. But $esp is a 32-bit register (which GDB sign-extends to 64 bits in this context). The 64-bit stack pointer is called $rsp. Try this instead:

(gdb) x/1xw $rsp
Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • Thanks a lot. It worked. Just one little thing I'd like to know. What does 'r' in rax, rsp or any other 64 bit register stands for? 32 bit registers are preceded with an 'e' which stands for 'extended'. – 7_R3X Jul 28 '17 at 06:51
  • 1
    @7_R3X: [What do the E and R prefixes stand for in the names of Intel 32-bit and 64-bit registers?](https://stackoverflow.com/questions/43933379/what-do-the-e-and-r-prefixes-stand-for-in-the-names-of-intel-32-bit-and-64-bit-r) – ecm Mar 12 '20 at 13:34
  • @ecm: Thanks a lot! – 7_R3X Mar 12 '20 at 17:59