New helper script


git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@5373 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/RunSafely.sh b/RunSafely.sh
new file mode 100755
index 0000000..f05e850
--- /dev/null
+++ b/RunSafely.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Program:  RunSafely.sh
+#
+# Synopsis: This script simply runs another program.  If the program works
+#           correctly, this script has no effect, otherwise it will do things
+#           like print a stack trace of a core dump.  It always returns
+#           "successful" so that tests will continue to be run.
+#
+# Syntax:  ./RunSafely.sh <program> <arguments>
+#
+
+PROGRAM=$1
+shift
+
+rm -f core*
+ulimit -c hard
+$PROGRAM $*
+if ls | egrep "^core" > /dev/null
+then
+    corefile=`ls core* | head -1`
+    echo "where" > StackTrace.$$
+    gdb -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null
+    rm -f StackTrace.$$ $corefile
+fi
+
+exit 0
\ No newline at end of file