-
Notifications
You must be signed in to change notification settings - Fork 16
Detecting a segfault in dmd itself
Johan Engelen edited this page Jun 3, 2016
·
3 revisions
One way to do it is this, which has the advantage of providing dmd's output before segfaulting:
#!/bin/sh
# arguments to dmd
DMDARGS="-debug -g ..."
OUTPUT=$(gdb --batch -ex "run $DMDARGS" -ex 'bt 30' dmd 2>&1)
echo "$OUTPUT" | egrep -q "in dwarf_typidx .+ at backend/dwarf\.c" # adapt for your needs, use fgrep if you don't need regexps
return $?
#!/bin/sh
# arguments to dmd
DMDARGS="-debug -g ..."
OUTPUT=$(lldb --batch -o "run $DMDARGS" -k 'bt 30' -k 'quit' -o 'quit' dmd 2>&1)
echo "$OUTPUT" | egrep -q "in dwarf_typidx .+ at backend/dwarf\.c" # adapt for your needs, use fgrep if you don't need regexps
exit $?
A simpler, but less detailed way, is to do this:
#!/bin/bash
dmd ...args...
# Segfaulting programs will likely return an error code of 139.
if [ $? -eq 139 ]; then
exit 0
else
exit 1
fi