From c731d11471ea9edd762b4cdb67bac06e77cb6f45 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 3 Aug 2005 05:46:43 +0000 Subject: r8990: First trivial example of 'make test' (This used to be commit 11c886394970713a226d1fe46a4931ef97bb39a8) --- source3/script/tests/gdb_backtrace | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 source3/script/tests/gdb_backtrace (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace new file mode 100644 index 0000000000..2ea6a4d00a --- /dev/null +++ b/source3/script/tests/gdb_backtrace @@ -0,0 +1,41 @@ +#! /bin/sh +# +# Author: Andrew Tridgell + +# we want everything on stderr, so the program is not disturbed +exec 1>&2 + +BASENAME=$( basename $0) + +test -z ${GDB_BIN} && GDB_BIN=$( type -p gdb) +if [ -z ${GDB_BIN} ]; then + echo "ERROR: ${BASENAME} needs an installed gdb. " + exit 1 +fi + +if [ -z $1 ]; then + echo "ERROR: ${BASENAME} needs a PID. " + exit 1 +fi +PID=$1 + +# use /dev/shm as default temp directory +test -d /dev/shm && \ + TMP_BASE_DIR=/dev/shm || \ + TMP_BASE_DIR=/var/tmp +TMPFILE=$( mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX) +if [ $? -ne 0 ]; then + echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " + exit 1 +fi + +cat << EOF > "${TMPFILE}" +set height 0 +up 8 +bt full +quit +EOF + +${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}" + +/bin/rm -f "${TMPFILE}" -- cgit From 716135eacf8826518c466a6a6d3b3cf69c00550d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 11:49:32 +0000 Subject: r18379: make the gdb_backtrace executable metze (This used to be commit f4023dc39e97bf8b1d1642f7eb0e8cb00557aa7f) --- source3/script/tests/gdb_backtrace | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 source3/script/tests/gdb_backtrace (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace old mode 100644 new mode 100755 -- cgit From c25f331cf9370a461487bf99cb661aa0148e078e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 12:24:51 +0000 Subject: r19040: use more portable shellscripting, hopefully give better results on Tru64 metze (This used to be commit e8dd73f79656d9ef6faf9fceb84dc8702ac8e10a) --- source3/script/tests/gdb_backtrace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace index 2ea6a4d00a..2a5ed1f04d 100755 --- a/source3/script/tests/gdb_backtrace +++ b/source3/script/tests/gdb_backtrace @@ -5,9 +5,9 @@ # we want everything on stderr, so the program is not disturbed exec 1>&2 -BASENAME=$( basename $0) +BASENAME=`basename $0` -test -z ${GDB_BIN} && GDB_BIN=$( type -p gdb) +test -z ${GDB_BIN} && GDB_BIN=`type -p gdb` if [ -z ${GDB_BIN} ]; then echo "ERROR: ${BASENAME} needs an installed gdb. " exit 1 -- cgit From 06e36b4e1860927eb76a2e756d86ef9b525ac743 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Oct 2006 21:30:31 +0000 Subject: r19104: Fix from Björn JACKE "here's a small fix for gdb_backtrace." Jeremy. (This used to be commit a0b4e5d11857cd067c60dd99dc5f00ee62a1354d) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source3/script/tests/gdb_backtrace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace index 2a5ed1f04d..c8fcad45f7 100755 --- a/source3/script/tests/gdb_backtrace +++ b/source3/script/tests/gdb_backtrace @@ -8,7 +8,7 @@ exec 1>&2 BASENAME=`basename $0` test -z ${GDB_BIN} && GDB_BIN=`type -p gdb` -if [ -z ${GDB_BIN} ]; then +if [ -z "${GDB_BIN}" ]; then echo "ERROR: ${BASENAME} needs an installed gdb. " exit 1 fi -- cgit From a856a88ba452b4951edbdfc696f1738e482860d7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Oct 2006 10:14:56 +0000 Subject: r19119: try to be more portable... metze (This used to be commit 380e647534730313ee57d1acf2756708b7c9676d) --- source3/script/tests/gdb_backtrace | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace index c8fcad45f7..8a74d1c101 100755 --- a/source3/script/tests/gdb_backtrace +++ b/source3/script/tests/gdb_backtrace @@ -7,23 +7,23 @@ exec 1>&2 BASENAME=`basename $0` -test -z ${GDB_BIN} && GDB_BIN=`type -p gdb` -if [ -z "${GDB_BIN}" ]; then - echo "ERROR: ${BASENAME} needs an installed gdb. " +PID=$1 +if [ x"$PID" = x"" ]; then + echo "ERROR: ${BASENAME} needs a PID. " exit 1 fi -if [ -z $1 ]; then - echo "ERROR: ${BASENAME} needs a PID. " +test x"${GDB_BIN}" = x"" && GDB_BIN=`type -p gdb` +if [ x"${GDB_BIN}" = x"" ]; then + echo "ERROR: ${BASENAME} needs an installed gdb. " exit 1 fi -PID=$1 # use /dev/shm as default temp directory test -d /dev/shm && \ TMP_BASE_DIR=/dev/shm || \ TMP_BASE_DIR=/var/tmp -TMPFILE=$( mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX) +TMPFILE=`mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX` if [ $? -ne 0 ]; then echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " exit 1 -- cgit From 78d21c7785ae85649b7356a774787d008285133b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 7 Oct 2006 10:33:33 +0000 Subject: r19164: merge the gdb_backtrace script from samba4 this more portable and try to make use of ladebug on Tru64, but that only works when the binary is passed as 2nd arg to gdb_backtrace as Tru64 doesn't know /proc/${PID}/exe we need to find a way to pass the progname in 'panic action' in samba3 metze (This used to be commit 2f55fd82ff5db82974f91648cc386daa423e38be) --- source3/script/tests/gdb_backtrace | 96 ++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 25 deletions(-) (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace index 8a74d1c101..b19a5b2f4b 100755 --- a/source3/script/tests/gdb_backtrace +++ b/source3/script/tests/gdb_backtrace @@ -1,41 +1,87 @@ -#! /bin/sh -# -# Author: Andrew Tridgell +#!/bin/sh + +BASENAME=`basename $0` + +if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then + echo "${BASENAME}: Not running debugger under valgrind" + exit 1 +fi # we want everything on stderr, so the program is not disturbed exec 1>&2 BASENAME=`basename $0` +UNAME=`uname` PID=$1 -if [ x"$PID" = x"" ]; then - echo "ERROR: ${BASENAME} needs a PID. " +BINARY=$2 + +test x"${PID}" = x"" && { + echo "Usage: ${BASENAME} []" exit 1 -fi +} + +DB_LIST="gdb" +case "${UNAME}" in + # + # on Tru64 we need to try ladebug first + # because gdb crashes itself... + # + OSF1) + DB_LIST="ladebug ${DB_LIST}" + ;; +esac -test x"${GDB_BIN}" = x"" && GDB_BIN=`type -p gdb` -if [ x"${GDB_BIN}" = x"" ]; then - echo "ERROR: ${BASENAME} needs an installed gdb. " +for DB in ${DB_LIST}; do + DB_BIN=`which ${DB} 2>/dev/null` + test x"${DB_BIN}" != x"" && { + break + } +done + +test x"${DB_BIN}" = x"" && { + echo "${BASENAME}: ERROR: No debugger found." exit 1 -fi +} -# use /dev/shm as default temp directory -test -d /dev/shm && \ - TMP_BASE_DIR=/dev/shm || \ - TMP_BASE_DIR=/var/tmp -TMPFILE=`mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX` -if [ $? -ne 0 ]; then - echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " +# +# we first try to use /proc/${PID}/exe +# 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 -fi +} + +echo "${BASENAME}: Trying to use ${DB_BIN} on ${BINARY} on PID ${PID}" -cat << EOF > "${TMPFILE}" -set height 0 -up 8 +BATCHFILE_PRE=/tmp/gdb_backtrace_pre.$$ +BATCHFILE_MAIN=/tmp/gdb_backtrace_main.$$ +case "${DB}" in + ladebug) +cat << EOF > ${BATCHFILE_PRE} +set \$stoponattach +EOF + +cat << EOF > ${BATCHFILE_MAIN} +where +quit +EOF + ${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}" + ;; + gdb) +cat << EOF > ${BATCHFILE_MAIN} +set height 1000 bt full quit EOF - -${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}" - -/bin/rm -f "${TMPFILE}" + ${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}" + ;; +esac +/bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN} -- cgit From e9b27a34e35500b9da94ccdf7872d6956bd93566 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 May 2007 09:50:56 +0000 Subject: r22998: merge from SAMBA_4_0: only if the output of which has a leading '/' the output is useful... metze (This used to be commit 5c5aa1f862ad5e765b18c8dbc981af3012b48cb7) --- source3/script/tests/gdb_backtrace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace index b19a5b2f4b..826381e900 100755 --- a/source3/script/tests/gdb_backtrace +++ b/source3/script/tests/gdb_backtrace @@ -33,7 +33,7 @@ case "${UNAME}" in esac for DB in ${DB_LIST}; do - DB_BIN=`which ${DB} 2>/dev/null` + DB_BIN=`which ${DB} 2>/dev/null | grep '^/'` test x"${DB_BIN}" != x"" && { break } -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/script/tests/gdb_backtrace | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 source3/script/tests/gdb_backtrace (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace old mode 100755 new mode 100644 -- cgit From 801c0314b1e5a0df49846aa3c22e17aee457eabb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 18 Oct 2007 11:03:18 +0200 Subject: make gdb_backtrace executable metze (This used to be commit f694df1919fe98c5efef36c867a2be6527efa6ed) --- source3/script/tests/gdb_backtrace | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 source3/script/tests/gdb_backtrace (limited to 'source3/script/tests/gdb_backtrace') diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace old mode 100644 new mode 100755 -- cgit