1

I am looking for a program to observe the execution stack of a c/c++ program. Currently I am using gdb for this purpose.

The following command shows the content of the stack:

x/12xg $rsp

to execute instruction after instruction I am using

stepi

Is it possible to combine these to commands so that I would be able to stept through the assembly code and observing the stack? If you have another possible solution/program I am looking forward to hear that as well.

4
  • It may depend on what you want to do ("why?"). You could set breakpoints at function entries, you could use print statements to get your information, etc. Commented Oct 16, 2016 at 12:31
  • You can use display in gdb, or even automate it so that it steps through your whole program. Commented Oct 16, 2016 at 12:39
  • @Jester unfortunately display x/12xg $rsp doesn't work? Commented Oct 16, 2016 at 15:02
  • 1
    display/12xg $rsp should. Commented Oct 16, 2016 at 22:21

1 Answer 1

2

You can combine commands using define, like:

(gdb) define mystep
> stepi
> x/whatever $rsp
> end

Now mystep should step and then dump some memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.