This is an archive of the discontinued LLVM Phabricator instance.

Report inferior SIGSEGV as a signal instead of an exception on linux
ClosedPublic

Authored by labath on May 27 2015, 3:12 AM.

Details

Summary

Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.

This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.

I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 26583.May 27 2015, 3:12 AM
labath retitled this revision from to Report inferior SIGSEGV as a signal instead of an exception on linux.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: ovyalov, clayborg, emaste.
labath added a subscriber: Unknown Object (MLST).
labath added inline comments.May 27 2015, 3:21 AM
test/functionalities/signal/handle-segv/TestHandleSegv.py
16 ↗(On Diff #26583)

This test fails on osx, but I think that's expected as segfaults are treated differently there. I have skipped it on darwin.

I am not sure about freebsd. I expect the test will fail, but I don't know if that is supposed to happen or not. I expect segv and mmap should behave the same way as on linux, in which case this should be XFAILed.

clayborg accepted this revision.May 27 2015, 9:50 AM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.May 27 2015, 9:50 AM
ovyalov accepted this revision.May 27 2015, 5:33 PM
ovyalov edited edge metadata.

LGTM

test/functionalities/inferior-crashing/TestInferiorCrashing.py
146 ↗(On Diff #26583)

Please consider using assertEqual instead of if->fail

test/functionalities/signal/handle-segv/main.c
27 ↗(On Diff #26583)

Please add constant for 47.

This revision was automatically updated to reflect the committed changes.