r18883: Start including test_functions.sh.
[jra/samba/.git] / source4 / script / gdb_backtrace
1 #!/bin/sh
2
3 if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then
4     echo "Not running gdb under valgrind"
5     exit 1
6 fi
7
8 # we want everything on stderr, so the program is not disturbed
9 exec 1>&2
10
11 PID=$1
12 PROG=$2
13
14 TMPFILE=/tmp/gdb.$$
15 cat << EOF  > $TMPFILE
16 set height 1000
17 bt full
18 quit
19 EOF
20
21 if [ ! -f $PROG ]; then
22     PROG=`which $PROG`
23 fi
24 if [ ! -f $PROG ]; then
25     PROG=/proc/$PID/exe
26 fi
27 if [ ! -f $PROG ]; then
28     echo "Unable to find binary"
29     exit 1
30 fi
31
32 gdb -batch -x $TMPFILE $PROG $PID < /dev/null 
33 /bin/rm -f $TMPFILE