Search code examples
assemblygdb

What's the meaning of the output of x/ in gdb (Linux)?


I'm debugging a C program with gdb.

(gdb) r prog_name
(gdb) break main
(gdb) x/wx $esp
(gdb) 0xbffff3d0:     0xbffff60d

I know the meaning of the first 3 commands.

What I don't understand is the meaning of last one (the output of gdb after 3rd command). Specifically, I don't understand: $esp is a register, hence I expect to find a SINGLE VALUE in the register, and as far as I know , registers don't have an address. So, supposing that 0xbffff60d is the value contained by register esp, what's ** 0xbffff3d0** ?

Thanks in advance


Solution

  • Straight from gdb:

    (gdb) help x
    Examine memory: x/FMT ADDRESS.
    ADDRESS is an expression for the memory address to examine.
    FMT is a repeat count followed by a format letter and a size letter.
    Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),
      t(binary), f(float), a(address), i(instruction), c(char) and s(string),
      T(OSType), A(floating point values in hex).
    Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
    The specified number of objects of the specified size are printed
    according to the format.
    

    So in your case, $esp contains 0xbffff3d0, and if you interpret that value as a pointer and dereference it, you'll get that *(uint32_t *)0xbffff3d0 is 0xbffff60d.