Chris Lattner | 03efbe6 | 2003-01-19 18:07:38 +0000 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Program: RunSafely.sh |
| 4 | # |
| 5 | # Synopsis: This script simply runs another program. If the program works |
| 6 | # correctly, this script has no effect, otherwise it will do things |
| 7 | # like print a stack trace of a core dump. It always returns |
| 8 | # "successful" so that tests will continue to be run. |
| 9 | # |
| 10 | # Syntax: ./RunSafely.sh <program> <arguments> |
| 11 | # |
| 12 | |
| 13 | PROGRAM=$1 |
| 14 | shift |
| 15 | |
| 16 | rm -f core* |
| 17 | ulimit -c hard |
| 18 | $PROGRAM $* |
| 19 | if ls | egrep "^core" > /dev/null |
| 20 | then |
| 21 | corefile=`ls core* | head -1` |
| 22 | echo "where" > StackTrace.$$ |
| 23 | gdb -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null |
| 24 | rm -f StackTrace.$$ $corefile |
| 25 | fi |
| 26 | |
| 27 | exit 0 |