#!/bin/sh
# 
# Script to do a stackdump of a Bacula daemon/program.
#
# We attempt to attach to running program
#
# Arguments to this script are
#  $1 = path to executable
#  $2 = main pid of running program to be traced back.
#
PNAME=`basename $1`
if test `uname -s` = SunOS ; then
  gcore -o /var/db/bacula/${PNAME} $2
  dbx $1 $2 </usr/local/share/bacula/btraceback.dbx 2>&1 \
   | /usr/local/sbin/bsmtp -h localhost -f root@localhost -s "Bacula DBX traceback of ${PNAME}" root@localhost
else
  gdb -quiet -batch -x /usr/local/share/bacula/btraceback.gdb $1 $2 2>&1 \
   | /usr/local/sbin/bsmtp -h localhost -f root@localhost -s "Bacula GDB traceback of ${PNAME}" root@localhost
fi 
