[llvm-commits] CVS: llvm/test/Programs/RunSafely_trace_execs.sh
Anand Shukla
ashukla at cs.uiuc.edu
Fri Jul 18 11:00:02 PDT 2003
Changes in directory llvm/test/Programs:
RunSafely_trace_execs.sh added (r1.1)
---
Log message:
Program to execute tracing framework executables
---
Diffs of the changes:
Index: llvm/test/Programs/RunSafely_trace_execs.sh
diff -c /dev/null llvm/test/Programs/RunSafely_trace_execs.sh:1.1
*** /dev/null Fri Jul 18 10:59:47 2003
--- llvm/test/Programs/RunSafely_trace_execs.sh Fri Jul 18 10:59:37 2003
***************
*** 0 ****
--- 1,70 ----
+ #!/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.
+ #
+ # This script funnels stdout and stderr from the program into the
+ # first argument specified, and outputs a <outputfile>.time file which
+ # contains a timing of the program.
+ #
+ # Syntax: ./RunSafely.sh <ulimit> <stdinfile> <stdoutfile> <program> <args...>
+ #
+ ULIMIT=$1
+ shift
+ INFILE=$1
+ shift
+ OUTFILE=$1
+ shift
+ PROGRAM=$1
+ shift
+
+ ulimit -t $ULIMIT
+ rm -f core core.*
+
+ #cputrack -c Cycle_cnt,Instr_cnt -o $OUTFILE.time $PROGRAM $* > $OUTFILE < $INFILE
+
+ #
+ # If we are on a sun4u machine (UltraSparc), then the code we're generating
+ # is 64 bit code. In that case, use gdb-64 instead of gdb.
+ #
+ myarch=`uname -m`
+ if [ "$myarch" = "sun4u" ]
+ then
+ GDB="gdb-64"
+ else
+ GDB=gdb
+ fi
+
+ #
+ # Run the command, timing its execution.
+ # The standard output and standard error of $PROGRAM should go in $OUTFILE,
+ # and the standard error of time should go in $OUTFILE.time.
+ #
+ # Ah, the joys of shell programming!
+ # To get the time program and the specified program different output filenames,
+ # we tell time to launch a shell which in turn executes $PROGRAM with the
+ # necessary I/O redirection.
+ #
+ (time sh -c "$PROGRAM $* > $OUTFILE 2>&1 < $INFILE") > $OUTFILE.time 2>&1
+
+ ulimit -c unlimited
+
+ if test $? -eq 0
+ then
+ touch $OUTFILE.exitok
+ fi
+
+ 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
+
+ pkill -n $PROGRAM
+ exit 0
More information about the llvm-commits
mailing list