blob: f05e850add1b9f4be01796a4eb308d0d2c20100a [file] [log] [blame]
Chris Lattner03efbe62003-01-19 18:07:38 +00001#!/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
13PROGRAM=$1
14shift
15
16rm -f core*
17ulimit -c hard
18$PROGRAM $*
19if ls | egrep "^core" > /dev/null
20then
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
25fi
26
27exit 0