#! /bin/sh # $Id$ GDB=$PWD/gdb.`uname -i` DIR=$PWD TEST=tst-core.`uname -i` STORAGE=$PWD/demo.d LIB=libobjid.so.`uname -i` function check { if ! $* then echo >&2 "Failed: $*" exit 1 fi } check test -f ./demo check test ! -e $STORAGE if test -f $LIB then rm -f ./libobjid.so cp -p $LIB ./libobjid.so cp -p $LIB.debug ./libobjid.so.debug fi if ! test -f $GDB then GDB=gdb fi check ulimit -c unlimited [ -f Makefile ] && check make libobjid.so $TEST check mkdir $STORAGE # Move to an empty directory to better test by losing any absolute references. EMPTY=$STORAGE/empty check mkdir $EMPTY cd $EMPTY STORAGE2=$STORAGE/`hostname -s` check mkdir $STORAGE2 libs="$(ldd $DIR/$TEST $DIR/libobjid.so | sed -n 's/^\t\(.* => \)\?\([^ ]*\).*$/\2/p' | sort -u)" for obj in $DIR/$TEST $DIR/libobjid.so $libs do if test -L $obj then link=$(readlink $obj) ln -s $link $STORAGE2/`basename $obj` obj=`dirname $obj`/$link fi check cp -p $obj $STORAGE2/`basename $obj` # It may not be present. cp -p /usr/lib/debug/$obj.debug $STORAGE2/`basename $obj`.debug done # Provide relative pathname to lose the reference to the original. check ln -s $DIR/libobjid.so check ln -s $DIR/$TEST LD_PRELOAD=./libobjid.so ./$TEST & pid=$! wait rm -f ./libobjid.so rm -f ./$TEST CORE=$PWD/core.$pid ls -l $CORE strace -s200 -o x -q $GDB --objectdirectory=$STORAGE2 --core=$CORE check rm -f $CORE check rm -rf $STORAGE echo $0 done