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