3 # Script to do a stackdump of a Bacula daemon/program.
5 # Author: Kern Sibbald, 2002
8 # We attempt to attach to running program
10 # Arguments to this script are
11 # $1 = path to executable
12 # $2 = main pid of running program to be traced back.
13 # $3 = working directory
20 # See what debuggers are available on this platform.
21 # We need to to some tricks to find out as a which on
22 # a non existing binary gives:
24 # no <debugger> in <PATH>
26 # So we use the return code which is 0 when it finds
27 # somethings and 1 if not.
29 which gdb > /dev/null 2>&1 && GDB=`which gdb` || GDB=''
30 which dbx > /dev/null 2>&1 && DBX=`which dbx` || DBX=''
31 which mdb > /dev/null 2>&1 && MDB=`which mdb` || MDB=''
32 gcore -o ${WD}/${PNAME} $2
33 if [ ! -z "${DBX}" ]; then
34 ${DBX} $1 $2 < @scriptdir@/btraceback.dbx > ${WD}/bacula.$2.traceback 2>&1
35 elif [ ! -z "${GDB}" ]; then
36 ${GDB} -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 > ${WD}/bacula.$2.traceback 2>&1
37 elif [ ! -z "${MDB}" ]; then
38 ${MDB} -u -p $2 < @scriptdir@/btraceback.mdb > ${WD}/bacula.$2.traceback 2>&1
40 PNAME="${PNAME} on `hostname`"
41 cat ${WD}/bacula.$2.traceback \
42 | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula DBX traceback of ${PNAME}" @dump_email@
45 gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1
46 PNAME="${PNAME} on `hostname`"
47 cat ${WD}/bacula.$2.traceback \
48 | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula GDB traceback of ${PNAME}" @dump_email@