]> git.sur5r.net Git - bacula/bacula/blob - bacula/scripts/btraceback.in
Start adding DeltaSeq
[bacula/bacula] / bacula / scripts / btraceback.in
1 #!/bin/sh
2
3 # Script to do a stackdump of a Bacula daemon/program.
4 #
5 # We attempt to attach to running program
6 #
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
11 #
12 PNAME=`basename $1`
13 WD="$3"
14 case `uname -s` in
15 SunOS)
16    #
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:
20    #
21    # no <debugger> in <PATH>
22    #
23    # So we use the return code which is 0 when it finds
24    # somethings and 1 if not.
25    #
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
36    fi
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@
40    ;;
41 *)
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@
46    ;;
47 esac