Skip to content

Instantly share code, notes, and snippets.

@sumerc
Last active December 2, 2020 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumerc/8d6bbc40cc67dae1bf4f6193a71cfc3b to your computer and use it in GitHub Desktop.
Save sumerc/8d6bbc40cc67dae1bf4f6193a71cfc3b to your computer and use it in GitHub Desktop.
Run GDB repeatedly and get a backtrace when error happens
#!/bin/bash
set -eu
i=1
while [ $i -le 10 ]
do
gdb_output=$(gdb -batch -ex "run" -ex "bt" --args python regression.py 2>&1)
if [[ ${gdb_output} != *'No stack'* ]]; then
echo -e "${gdb_output}"
break
fi
echo "Running $i"
i=$(( $i + 1 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment