X-Git-Url: http://git.samba.org/samba.git/?p=gd%2Fsamba-autobuild%2F.git;a=blobdiff_plain;f=selftest%2Fgdb_backtrace;h=28ac064bcd400fbfc09b40697f34de422926e0b5;hp=1d8249b08a0378808629bd26ff7ff69f29ebf1ac;hb=5e7cf194d2d25787e3af807a3a37f570ce5298dc;hpb=f79ff9582f3c5e1c1d756ef3b3dc0379fdb9912d diff --git a/selftest/gdb_backtrace b/selftest/gdb_backtrace index 1d8249b08a0..28ac064bcd4 100755 --- a/selftest/gdb_backtrace +++ b/selftest/gdb_backtrace @@ -30,6 +30,20 @@ case "${UNAME}" in OSF1) DB_LIST="ladebug ${DB_LIST}" ;; + # + # On solaris dbx is working way more better than gdb + # let's try it first + # + SunOS) + DB_LIST="dbx ${DB_LIST}" + ;; + # + # FreeBSD comes with a flavor that works gdb66 and one that don't gdb + # (gdb 6.1) let's try it first the one that works ! + # + FreeBSD) + DB_LIST="gdb66 ${DB_LIST}" + ;; esac for DB in ${DB_LIST}; do @@ -44,23 +58,38 @@ test x"${DB_BIN}" = x"" && { exit 1 } -# -# we first try to use /proc/${PID}/exe +need_binary="no" +case "${DB}" in +# These debuggers need the process binary specified: + ladebug) + need_binary="yes" + ;; + gdb66) + need_binary="yes" + ;; + dbx) + need_binary="yes" + ;; +esac + +test x"${need_binary}" = x"yes" && { + +# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris # then fallback to the binary from the commandline # then we search for the commandline argument with # 'which' # -test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe" -test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe" -test -f "${BINARY}" || BINARY=`which ${BINARY}` - -test -f "${BINARY}" || { - echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'." - exit 1 + test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe" + test -f "/proc/${PID}/path/a.out" && BINARY=`ls -l /proc/${PID}/path/a.out |sed 's/.*-> //'` + test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe" + test -f "${BINARY}" || BINARY=`which ${BINARY}` + + test -f "${BINARY}" || { + echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'." + exit 1 + } } -echo "${BASENAME}: Trying to use ${DB_BIN} on ${BINARY} on PID ${PID}" - BATCHFILE_PRE=/tmp/gdb_backtrace_pre.$$ BATCHFILE_MAIN=/tmp/gdb_backtrace_main.$$ case "${DB}" in @@ -75,14 +104,28 @@ quit EOF ${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}" ;; - gdb) + gdb66) cat << EOF > ${BATCHFILE_MAIN} set height 1000 bt full info locals +kill quit EOF ${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}" ;; + gdb) +cat << EOF > ${BATCHFILE_MAIN} +set height 0 +bt full +thread apply all bt full +info locals +quit +EOF + ${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" < /dev/null + ;; +dbx) + ${DB_BIN} "where;dump;kill;quit" "${BINARY}" "${PID}" + ;; esac /bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN}