Question

so I know that my current block is between epb and esp is there a way to print my stack the following way: lets says that len=ebp-esp I would like a command on gdb that would look like this x/lenx $esp

so I'm priting what's on the stack for the current function being executed? can I do this using display like: display/lenx $esp ?

Was it helpful?

Solution

is it possible to have a variable that will change each time

Seems display doesn't allow this. So you can define your own command and simply call it when you need to see a function stack:

define display_stack
  eval "x /%dbx $esp", $ebp-$esp
end

And then while debugging your program:

(gdb) display_stack

If you need to see your function stack on each step you can 1) define another command nn and use it when you debug your functions 2) use hook for the pseudo-command, ‘stop’ :

define nn
  n
  display_stack
end

define hook-stop
  echo "hook-stop, display_stack:\n"
  display_stack
end

Useful links:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top