[Debugging] Multiple commands in gdb separated by some sort of delimiter ';'?



Answers

If you are running gdb from command line you can pass multiple commands with the -ex parameter like:

$ gdb ./prog -ex 'b srcfile.c:90' -ex 'b somefunc' -ex 'r -p arg1 -q arg2'

This coupled with display and other commands makes running gdb less cumbersome.

Question

I am trying to execute two commands at once in gdb:

finish; next

I tried using the ';' to separate the commands but gdb did not let me do both at once.

Is it possible to do multiple commands in gdb similar to bash commands separated by ';' delimiter?




i ran across another way to do multiple commands in GDB using a Bash HERE document.

example:

cat << EOF | gdb
print "command_1"
print "..."
print "command_n"
EOF

this has limited value/usability IMO because GDB quits after executing the list of commands.






Links