Darren Freeman wrote:
> Rob, all,
>
> I just overhauled lyxdbg again, now v0.3
Darren, have a look at v0.3b :)
Prettyfied it a bit; functionality is same.
Rob.
---
#!/bin/sh
#
# This file is copyright 2002 Darren Freeman and Rob Lahaye.
# It is covered by the GNU General Public License which was supplied with LyX.
# 0.1 - Initial version by Darren Freeman
# 0.2 - Greatly improved by Rob Lahaye
# 0.2b - Revisited by Darren Freeman
# 0.3 - More commands to gdbcmd, made LyX async for faster loading, added trace
gzipping. By Darren Freeman
# 0.3b - 2002/12/01 Prettifying by Rob.
version="LyX automatic backtrace generator v0.3b"
echo "$version"
# Define file names for output.
gdbcmd="lyx-gdb-cmd"
trace="lyx-trace"
lyxout="lyx-stdout"
lyxerr="lyx-stderr"
# lyx executable is either the first argument or assume it to be in ./ or ./src/
if ( test -x "$1" -a ! -d "$1" )
then
lyx=$1
shift
else
for i in ./lyx ./src/lyx
do
if ( test -x "$i" -a ! -d "$i" )
then
lyx=$i
break
fi
done
fi
if ( test -z "$lyx" )
then
echo "Error: cannot find LyX executable!"
echo "Either supply the full path of the LyX executable as the"
echo "first argument or 'cd' into the LyX build directory."
exit
fi
# Check next argument for coredump file.
[ -n "`file -i $1 2>/dev/null | grep coredump`" ] && { coredump=$1; shift; }
# Create stdin for GDB.
echo -n > $gdbcmd
# GDB needs to wait for LyX as we will spawn it below.
[ -z "$coredump" ] && echo "finish" >> $gdbcmd
echo "bt" >> $gdbcmd
echo "info locals" >> $gdbcmd
echo "up" >> $gdbcmd
echo "info locals" >> $gdbcmd
echo "up" >> $gdbcmd
echo "info locals" >> $gdbcmd
echo "up" >> $gdbcmd
echo "info locals" >> $gdbcmd
# Allow LyX to continue with an emergency save in case of crash.
[ -z "$coredump" ] && echo "continue" >> $gdbcmd
# Start the trace file with the version string.
echo "$version" > $trace
# Append the GDB commands to the trace.
echo "----------*-commands-*----------" >> $trace
cat "$gdbcmd" >> $trace
echo "----------*---gdb----*----------" >> $trace
if ( test -z "$coredump" )
then
# Spawn LyX in the background and save its PID.
echo "Starting $lyx ..."
$lyx $@ > $lyxout 2> $lyxerr &
lyxpid=$!
echo "Attaching the debugger..."
else
echo "Executing the debugger on core file $coredump ..."
fi
# Start GDB; either attach to running LyX pid or read the core dump.
gdb < $gdbcmd >> $trace 2>&1 $lyx $lyxpid$coredump
echo >> $trace
# If we started LyX ourselves we can append the output of LyX.
if ( test -z "$coredump" )
then
# Append the stdout and stderr from LyX.
echo "----------*--stdout--*----------" >> $trace
cat $lyxout >> $trace
echo "----------*--stderr--*----------" >> $trace
cat $lyxerr >> $trace
fi
# Compress without removing original.
gzip -c $trace > ${trace}.gz
echo
echo "The file $trace contains everything GDB and LyX has said."
echo "${trace}.gz is the compressed version for emailing."
# Clean up files.
rm -f $gdbcmd $lyxout $lyxerr
# Extra messages when interesting things are in lyx-trace..
# add more interesting things below!
if ( grep SIGSEGV $trace )
then
echo
echo "Whoa! Looks like something nasty happened."
echo "*Please* email the above file to the LyX team at:"
echo "[EMAIL PROTECTED]"
echo "Don't forget to include what you were doing when it bombed!"
fi