Run a program transparently, but print a stack trace if it fails gdb -batch -ex "run" -ex "bt" ${my_program} 2>&1 | grep -v ^"No stack."$ For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn't have to mess around with core files. The one downside is that it does smoosh your program's stderr
{{#tags}}- {{label}}
{{/tags}}