2

Is it possible to run multiple commands in gdb such as the following:

# step instruction and then print what I want to see again
>>> si && x/bt $rsi

If so, how can it be done?

9
  • 1
    How about a user-defined command, would that work for you? Commented Oct 3, 2020 at 23:52
  • 2
    I don't think it's possible to have multiple commands in one line. I guess the Automatic Display is also not what you want. The Ctrl-o binding may or may not help you a bit thou. Commented Oct 4, 2020 at 0:04
  • 2
    In your case, if you did si and x/bt $rsi before, and they are now in your command history, you can go back in the history to si and press ctrl-o. This executes the command, just like [enter], but then automatically goes to the x/bt $rsi command. Commented Oct 4, 2020 at 0:15
  • 1
    Possible duplicate of stackoverflow.com/q/1262639/72178. Commented Oct 4, 2020 at 8:45
  • 2
    User-defined commands as mentioned by @ssbssa are the way to go, but for something quick and dirty keyboard macros are also a good option. Commented Oct 6, 2020 at 19:54

1 Answer 1

2

If your gdb includes python, follow this post to add a user command in your .gdbinit file: https://stackoverflow.com/a/51804606/11873710

Usage example:

(gdb) cmds echo hi ; echo bye
hi
bye
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.