~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/script/tests/gdb_backtrace

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /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=$( basename $0)
9
 
 
10
 
test -z ${GDB_BIN} && GDB_BIN=$( type -p gdb)
11
 
if [ -z ${GDB_BIN} ]; then
12
 
        echo "ERROR: ${BASENAME} needs an installed gdb. "
13
 
        exit 1
14
 
fi
15
 
 
16
 
if [ -z $1 ]; then
17
 
        echo "ERROR: ${BASENAME} needs a PID. "
18
 
        exit 1
19
 
fi
20
 
PID=$1
21
 
 
22
 
# use /dev/shm as default temp directory
23
 
test -d /dev/shm && \
24
 
        TMP_BASE_DIR=/dev/shm || \
25
 
        TMP_BASE_DIR=/var/tmp
26
 
TMPFILE=$( mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX)
27
 
if [ $? -ne 0 ]; then
28
 
        echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. "
29
 
        exit 1
30
 
fi
31
 
 
32
 
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/rm -f "${TMPFILE}"