summaryrefslogtreecommitdiff
path: root/source4/script/gdb_backtrace
blob: 72d1f75be994a6f51159a781defa6d9c8e9d12c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

# we want everything on stderr, so the program is not disturbed
exec 1>&2

PID=$1
PROG=$2

TMPFILE=/tmp/gdb.$$
cat << EOF  > $TMPFILE
set height 1000
bt full
quit
EOF

if [ ! -f $PROG ]; then
    PROG=`which $PROG`
fi
if [ ! -f $PROG ]; then
    PROG=/proc/$PID/exe
fi
if [ ! -f $PROG ]; then
    echo "Unable to find binary"
    exit 1
fi

gdb -batch -x $TMPFILE $PROG $PID < /dev/null 
/bin/rm -f $TMPFILE