3 # Author: Andrew Tridgell <tridge at samba dot org>
5 # we want everything on stderr, so the program is not disturbed
8 BASENAME
=$
(basename $0)
10 test -z ${GDB_BIN} && GDB_BIN
=$
(type -p gdb
)
11 if [ -z ${GDB_BIN} ]; then
12 echo "ERROR: ${BASENAME} needs an installed gdb. "
17 echo "ERROR: ${BASENAME} needs a PID. "
22 # use /dev/shm as default temp directory
24 TMP_BASE_DIR
=/dev
/shm ||
26 TMPFILE
=$
(mktemp
-p ${TMP_BASE_DIR} backtrace.XXXXXX
)
28 echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. "
32 cat <<EOF >"${TMPFILE}"
39 ${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}"
41 /bin/rm -f "${TMPFILE}"