From: Marco van Wieringen Date: Sat, 24 Apr 2010 15:09:29 +0000 (+0200) Subject: Do some work on the btraceback on Solaris, we test to see what debugger is available... X-Git-Tag: Release-5.2.1~1410 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dcbaa1b651313f8c98c8d92071ae66d00e2e85c0;p=bacula%2Fbacula Do some work on the btraceback on Solaris, we test to see what debugger is available and we prefer the debuggers in this order: dbx, gdb, mdb. Also enchanced the dbx bactrace somewhat that it always dumps all available threads (e.g. we also changed from lwp to threads for dbx). We also print some variables that the gdb script also dumps on a bactrace. Hopefully we get some better dumps using this. The mdb is used as a last resort as it should be always installed on a Solaris box (dbx and gdb may not) but at the moment I'm still trying to find out how to get some more understandable dumps from mdb as its rather rudimentary and more a crash debugger then a source code debugger. --- diff --git a/bacula/scripts/btraceback.dbx b/bacula/scripts/btraceback.dbx index 91a7d95a78..6c22d3c0ea 100644 --- a/bacula/scripts/btraceback.dbx +++ b/bacula/scripts/btraceback.dbx @@ -1,33 +1,45 @@ # btraceback.dbx -echo "******** RUNNING LWPS/THREADS:" +dbxenv language_mode c++ + +echo "exename ==> \c"; print -l (char *)exename +echo "exepath ==> \c"; print -l (char *)exepath +echo "catalog_db ==> \c"; print -l (char *)catalog_db +echo "version ==> \c"; print -l (char *)version +echo "host_os ==> \c"; print -l (char *)host_os +echo "distname ==> \c"; print -l (char *)distname +echo "distver ==> \c"; print -l (char *)distver +echo "dist_name ==> \c"; print -l (char *)dist_name +echo "beef ==> \c"; print -l (int)dist_name + +echo "******** RUNNING THREADS:" echo -lwps +threads echo echo -echo "******** STACK TRACE OF CURRENT LWP:" +echo "******** STACK TRACE OF CURRENT THREAD:" echo where echo echo -echo "******** VARIABLES DUMP OF CURRENT LWP:" +echo "******** VARIABLES DUMP OF CURRENT THREAD:" echo dump -for LWP in 1 2 3 4 5 6 7 8; do +for THREAD in $(threads | sh sed -e 's/.*@//' -e 's/ .*//'); do ( - if lwp l@$LWP; then + if thread t@$THREAD; then echo echo - echo "******** STACK TRACE OF LWP ${LWP}:" + echo "******** STACK TRACE OF THREAD ${THREAD}:" echo where echo echo - echo "******** VARIABLES DUMP OF LWP ${LWP}:" + echo "******** VARIABLES DUMP OF THREAD ${THREAD}:" echo dump diff --git a/bacula/scripts/btraceback.in b/bacula/scripts/btraceback.in index a9ab1a58e5..7be55817c1 100755 --- a/bacula/scripts/btraceback.in +++ b/bacula/scripts/btraceback.in @@ -11,22 +11,36 @@ # PNAME=`basename $1` WD="$3" -GDB=`which gdb` -if test `uname -s` = SunOS ; then +case `uname -s` in +SunOS) + # + # See what debuggers are available on this platform. + # We need to to some tricks to find out as a which on + # a non existing binary gives: + # + # no in + # + # So we use the return code which is 0 when it finds + # somethings and 1 if not. + # + which gdb > /dev/null 2>&1 && GDB=`which gdb` || GDB='' + which dbx > /dev/null 2>&1 && DBX=`which dbx` || DBX='' + which mdb > /dev/null 2>&1 && MDB=`which mdb` || MDB='' gcore -o ${WD}/${PNAME} $2 - if [ -x /usr/bin/mdb ]; then - mdb -u -p $2 <@scriptdir@/btraceback.mdb >${WD}/bacula.$2.traceback 2>&1 - elif [ -x /usr/bin/dbx ]; then - dbx $1 $2 <@scriptdir@/btraceback.dbx >${WD}/bacula.$2.traceback 2>&1 - elif [ "x${GDB}" != "x" ]; then - gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1 + if [ ! -z "${DBX}" ]; then + ${DBX} $1 $2 < @scriptdir@/btraceback.dbx > ${WD}/bacula.$2.traceback 2>&1 + elif [ ! -z "${GDB}" ]; then + ${GDB} -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 > ${WD}/bacula.$2.traceback 2>&1 + elif [ ! -z "${MDB}" ]; then + ${MDB} -u -p $2 < @scriptdir@/btraceback.mdb > ${WD}/bacula.$2.traceback 2>&1 fi PNAME="${PNAME} on `hostname`" cat ${WD}/bacula.$2.traceback \ | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula DBX traceback of ${PNAME}" @dump_email@ -else + ;; +*) gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >${WD}/bacula.$2.traceback 2>&1 PNAME="${PNAME} on `hostname`" cat ${WD}/bacula.$2.traceback \ | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula GDB traceback of ${PNAME}" @dump_email@ -fi +esac