3 # Bacula(R) - The Network Backup Solution
5 # Copyright (C) 2000-2016 Kern Sibbald
6 # Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
8 # The original author of Bacula is Kern Sibbald, with contributions
9 # from many others, a complete list can be found in the file AUTHORS.
11 # You may use this file and others of this release according to the
12 # license defined in the LICENSE file, which includes the Affero General
13 # Public License, v3.0 ("AGPLv3") and some additional permissions and
14 # terms pursuant to its AGPLv3 Section 7.
16 # This notice must be preserved when any source code is
17 # conveyed and/or propagated.
19 # Bacula(R) is a registered trademark of Kern Sibbald.
21 # Script to do a stackdump of a Bacula daemon/program.
23 # We attempt to attach to running program
25 # Arguments to this script are
26 # $1 = path to executable
27 # $2 = main pid of running program to be traced back.
28 # $3 = working directory
35 # See what debuggers are available on this platform.
36 # We need to to some tricks to find out as a which on
37 # a non existing binary gives:
39 # no <debugger> in <PATH>
41 # So we use the return code which is 0 when it finds
42 # somethings and 1 if not.
44 which gdb > /dev/null 2>&1 && GDB=`which gdb` || GDB=''
45 which dbx > /dev/null 2>&1 && DBX=`which dbx` || DBX=''
46 which mdb > /dev/null 2>&1 && MDB=`which mdb` || MDB=''
47 gcore -o ${WD}/${PNAME} $2
48 if [ ! -z "${DBX}" ]; then
49 ${DBX} $1 $2 < @scriptdir@/btraceback.dbx > ${WD}/bacula.$2.traceback 2>&1
50 elif [ ! -z "${GDB}" ]; then
51 ${GDB} -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 > ${WD}/bacula.$2.traceback 2>&1
52 elif [ ! -z "${MDB}" ]; then
53 ${MDB} -u -p $2 < @scriptdir@/btraceback.mdb > ${WD}/bacula.$2.traceback 2>&1
55 PNAME="${PNAME} on `hostname`"
56 cat ${WD}/bacula.$2.traceback \
57 | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula DBX traceback of ${PNAME}" @dump_email@
60 gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1
61 PNAME="${PNAME} on `hostname`"
62 cat ${WD}/bacula.$2.traceback \
63 | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula GDB traceback of ${PNAME}" @dump_email@