]> git.sur5r.net Git - bacula/bacula/blob - bacula/scripts/btraceback.in
Allow traceback with gdb on Solaris
[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 GDB=`which gdb`
15 if test `uname -s` = SunOS ; then
16    gcore -o ${WD}/${PNAME} $2
17    if [ -x /usr/bin/mdb ]; then
18       mdb -u -p $2 <@scriptdir@/btraceback.mdb >${WD}/bacula.$2.traceback 2>&1
19    elif [ -x /usr/bin/dbx ]; then
20       dbx $1 $2 <@scriptdir@/btraceback.dbx >${WD}/bacula.$2.traceback 2>&1
21    elif [ "x${GDB}" != "x" ]; then
22       gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1
23    fi
24    PNAME="${PNAME} on `hostname`"
25    cat ${WD}/bacula.$2.traceback \
26     | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula DBX traceback of ${PNAME}" @dump_email@
27 else
28    gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1
29    PNAME="${PNAME} on `hostname`"
30    cat ${WD}/bacula.$2.traceback \
31     | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula GDB traceback of ${PNAME}" @dump_email@
32 fi