#! /usr/bin/env bash
#
# $Id: crash-diag.in 6811 2009-07-06 20:41:10Z robin $
#
# crash-diag <cwd>

(

cd $1

if [ -e stderr.log ]; then
   echo ==== stderr.log 
   tail -30 stderr.log 
else
   echo ==== No stderr.log.
fi

if [ -e stdout.log ]; then
   echo ==== stdout.log 
   tail -30 stdout.log 
else
   echo ==== No stdout.log.
fi

echo

if [ -e .status ]; then
   echo ==== .status
   tail -30 .status
else
   echo ==== No .status.
fi

echo

if [ -e prof.log ]; then
   echo ==== prof.log 
   tail -30 prof.log 
else
   echo ==== No prof.log.
fi

echo

core=`ls -t *core* 2>&1`

for c in $core; do 
   if [ -e $c ]; then
      echo $c
      echo "bt" | gdb --batch -x /dev/stdin /usr/bin/bro $c
   fi
done

) >.crash-diag.log

cat .crash-diag.log
