| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Author: Andrew Tridgell <tridge at samba dot org> |
| 4 | |
| 5 | # we want everything on stderr, so the program is not disturbed |
| 6 | exec 1>&2 |
| 7 | |
| 8 | BASENAME=$(basenamescip-shell system . . basename. $0) |
| 9 | |
| 10 | testscip-shell system . . test. -z ${GDB_BIN} && GDB_BIN=$(type -p gdb) |
| 11 | if [scip-shell system . . `[`. -z ${GDB_BIN} ]; then |
| 12 | echoscip-shell system . . echo. "ERROR: ${BASENAME} needs an installed gdb. " |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | if [scip-shell system . . `[`. -z $1 ]; then |
| 17 | echoscip-shell system . . echo. "ERROR: ${BASENAME} needs a PID. " |
| 18 | exit 1 |
| 19 | fi |
| 20 | PID=$1 |
| 21 | |
| 22 | # use /dev/shm as default temp directory |
| 23 | testscip-shell system . . test. -d /dev/shmscip-shell filesystem . . `/dev/shm`. && |
| 24 | TMP_BASE_DIR=/dev/shmscip-shell filesystem . . `/dev/shm`. || |
| 25 | TMP_BASE_DIR=/var/tmpscip-shell filesystem . . `/var/tmp`. |
| 26 | TMPFILE=$(mktempscip-shell system . . mktemp. -p ${TMP_BASE_DIR} backtrace.XXXXXX) |
| 27 | if [scip-shell system . . `[`. $? -ne 0 ]; then |
| 28 | echoscip-shell system . . echo. "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | catscip-shell system . . cat. <<EOF >"${TMPFILE}" |
| 33 | set height 0 |
| 34 | up 8 |
| 35 | bt full |
| 36 | quit |
| 37 | EOF |
| 38 | |
| 39 | ${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}" |
| 40 | |
| 41 | /bin/rmscip-shell filesystem . . `/bin/rm`. -f "${TMPFILE}" |