Using GDB to Verify Machine Stack

Is there a way to get GDB to print the last "n" values ​​stacked on the stack. For example, currently, if I want to check the contents of a stack, I am doing the following (assuming x86 architecture):

(gdb) # get last value pushed on stack (gdb) p *(int *)($esp) (gdb) # get 2nd to last value pushed on stack (gdb) p *(int *)($esp + 4) 

Is there a better way to view a stack of machines? Maybe printed beautifully?

+11
gdb
Oct 25 '10 at
source share
1 answer

Learn 16 words at the top of the stack:

 x/16wx $esp 

"w" - for typing words

+21
Oct. 27 '10 at 4:29
source share



All Articles