gdb stops in a command file if there is an error. How to continue despite the error?

gdb's command language doesn't have a way to ignore an error when processing a command.

This is easily done, though, if your gdb was built with the Python extension. Search for the "ignore-errors" script. With that, you can:

(gdb) ignore-errors print *foo

... and any errors from print will be shown but not abort the rest of your script.


You can also do this:

gdb a.out < analyze.v2.gdb 

This will execute the commands in analyze.v2.gdb line by line, even if an error occurs.