1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00
samba-mirror/source4/script/gdb_backtrace
Andrew Tridgell 5637940838 r8680: try harder to find the binary for gdb in the backtrace
(This used to be commit e84871dd3232de73104bee81dd877cc329cd1970)
2007-10-10 13:29:53 -05:00

29 lines
419 B
Bash
Executable File

#!/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