I wanted to implement a feature to generate a stack trace if my program
crashes. The use of the command line -x and hook-stop almost gets me there.
Unfortunately, this is a bit over-enthusiastic; it is triggered if my
program gets a fatal signal, but it also is triggered when the program is
finished, which prints a confusing error message in the case where the
program finishes successfully ("no stack").

Is it possible to add another pseudo-hook for this case? I don't see any way
to protect the backtrace command I issue with some kind of test, and I don't
want a complicated script that uses expect...

BTW, in case you're wondering, I don't want to dump core, as these are MPI
jobs running on hundreds or thousands of processors.

Here's the script I'm using:

#!/bin/sh

CMD=$1
shift

cat > /tmp/tombstone.commands.$$ <<EndOfHereDoc
define hook-stop
bt
end
run $*
EndOfHereDoc

/usr/bin/gdb -batch -x /tmp/tombstone.commands.$$ $CMD

Reply via email to