The x
command will be the easiest way to display values in memory. Try, for instance:
(gdb) x/32b $ebp
If this doesn't work (especially if you get an error that "value can't be converted to integer"), you're probably debugging a 64-bit executable. x86-64 registers have different names; use $rbp
instead.
The characters after the slash in the x
command control how many values are displayed, and what format is used. x/s
will attempt to read a string from that address, for instance. If you don't use anything, gdb will use whatever you last used.
While it isn't strictly necessary to answer your question, I've fixed up some of the other commands you were trying to run:
p *((char *) $ebp) <- treat $ebp as a character pointer and display what it points to
p *((char *) $ebp + 4) <- with an offset
p ((char *) $ebp)[4] <- same thing as above, except using array syntax
The $
character is only needed when referring to registers, or to gdb variables. You don't need it for anything else.