- Notifications
You must be signed in to change notification settings - Fork17
Detecting a segfault in dmd itself
Johan Engelen edited this pageJun 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 dmdDMDARGS="-debug -g ..."OUTPUT=$(gdb --batch -ex"run$DMDARGS" -ex'bt 30' dmd2>&1)echo"$OUTPUT"| egrep -q"in dwarf_typidx .+ at backend/dwarf\.c"# adapt for your needs, use fgrep if you don't need regexpsreturn$?
#!/bin/sh# arguments to dmdDMDARGS="-debug -g ..."OUTPUT=$(lldb --batch -o"run$DMDARGS" -k'bt 30' -k'quit' -o'quit' dmd2>&1)echo"$OUTPUT"| egrep -q"in dwarf_typidx .+ at backend/dwarf\.c"# adapt for your needs, use fgrep if you don't need regexpsexit$?
A simpler, but less detailed way, is to do this:
#!/bin/bashdmd ...args...# Segfaulting programs will likely return an error code of 139.if [$?-eq 139 ];thenexit 0elseexit 1fi