r15099: An attempt to fix BSD make portability issues. With these changes Samba 4...
[Samba.git] / source4 / script / gdb_backtrace
blobbff70c389aa5c2e2f1c822dead21eb728ae0802a
1 #!/bin/sh
3 if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then
4 echo "Not running gdb under valgrind"
5 exit 1
6 fi
8 # we want everything on stderr, so the program is not disturbed
9 exec 1>&2
11 PID=$1
12 PROG=$2
14 TMPFILE=/tmp/gdb.$$
15 cat << EOF > $TMPFILE
16 set height 1000
17 bt full
18 quit
19 EOF
21 if [ ! -f $PROG ]; then
22 PROG=`which $PROG`
24 if [ ! -f $PROG ]; then
25 PROG=/proc/$PID/exe
27 if [ ! -f $PROG ]; then
28 echo "Unable to find binary"
29 exit 1
32 gdb -batch -x $TMPFILE $PROG $PID < /dev/null
33 /bin/rm -f $TMPFILE