Dear list, I've just churned out lyxdbg0.3c which I would say is pretty solid now.
changes from 0.3b: more intelligent search for LyX executable added output of "lyx --version" to the trace more helpful output for beginner/novice users Please have a go with this script, I'd like either Rob or myself to make a posting in lyx-users pretty soon to let people know it exists. And if all goes well it would be nice to put it in CVS. So when somebody makes a decision about its final resting place we can revise the search path for locating LyX if needed. Darren
#!/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 - 2002/11/28 Initial version by Darren Freeman # 0.2 - 2002/11/29 Greatly improved by Rob Lahaye # 0.2b - 2002/11/30 Revisited by Darren Freeman # 0.3 - 2002/12/01 More commands to gdbcmd, made LyX async for faster loading, added trace gzipping. By Darren Freeman # 0.3b - 2002/12/01 Prettifying by Rob Lahaye. # 0.3c - 2002/12/07 Minor fixes and more messages by Darren. version="LyX automatic testing assistant v0.3c" echo "$version" # Define file names for output. gdbcmd="lyx-gdb-cmd" trace="lyx-trace" lyxout="lyx-stdout" lyxerr="lyx-stderr" # Number of stack frames to investigate further. listframes=4 # Start the trace file with the version string. echo "$version" >$trace # 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 `dirname $0`/src/lyx `dirname $0`/lyx ./src/lyx ./lyx `which lyx 2>/dev/null` 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, copy this script into the LyX build" echo "directory, or 'cd' into there." exit fi # Dump compiled-in LyX version information to the trace. echo "----------*-version--*----------" >>$trace $lyx --version >> $trace 2>&1 # 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 # First grab a backtrace if LyX had problems. Include local variables. echo "bt" >> $gdbcmd echo "info locals" >> $gdbcmd # Rise through the stack dumping local variables. for (( i=1; i<listframes; i++ )) do echo "up" >> $gdbcmd echo "info locals" >> $gdbcmd done # Allow LyX to continue with an emergency save in case of crash. [ -z "$coredump" ] && echo "continue" >> $gdbcmd # 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 have said" echo "plus other useful information intended for the developers." echo "${trace}.gz is the compressed version for emailing." # Extra messages when interesting things are in the trace files. # Add more interesting things below! # echo "desired line length of messages below---------------------60" email="" if ( grep "SIGSEGV" $trace &>/dev/null ) then echo echo "Whoa! It appears that a segmentation fault occurred. This is" echo "probably a very serious fault in LyX that may be hard for" echo "the developers to find without your help." email=true fi if ( grep "Phew." $lyxerr &>/dev/null ) then echo echo "It appears that LyX performed a successful autosave. LyX" echo "should remind you about this recovery file the next time" echo "you open the document(s). Most of the time you will not" echo "lose your work even if you haven't saved it for a while." fi if ( ! test -z "$email" ) then echo echo "Please email the compressed trace file to the LyX team at" echo "[EMAIL PROTECTED] (LyX Developers List)" echo "Don't forget to mention what you were doing before the" echo "error, and remember that:" echo echo "--- THIS SCRIPT REPLACES OLD TRACE FILES AUTOMATICALLY ---" fi # Clean up files. rm -f $gdbcmd $lyxout $lyxerr