From c4e25c96483643748e6fcf669a776603697365ef Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 29 May 2015 10:13:03 +0000 Subject: Report inferior SIGSEGV as a signal instead of an exception on linux 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.). Test Plan: All tests pass on linux and osx. Reviewers: ovyalov, clayborg, emaste Subscribers: emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D10057 llvm-svn: 238549 --- .../Plugins/Process/Linux/NativeProcessLinux.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 489890aa5132..ec286b055c4b 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -2177,7 +2177,7 @@ NativeProcessLinux::MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool e // leave the signal intact if this is the thread that was chosen as the // triggering thread. if (m_pending_notification_up && m_pending_notification_up->triggering_tid == pid) - linux_thread_sp->SetStoppedBySignal(SIGSTOP); + linux_thread_sp->SetStoppedBySignal(SIGSTOP, info); else linux_thread_sp->SetStoppedBySignal(0); @@ -2217,22 +2217,8 @@ NativeProcessLinux::MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool e // This thread is stopped. ThreadDidStop (pid, false); - switch (signo) - { - case SIGSEGV: - case SIGILL: - case SIGFPE: - case SIGBUS: - if (thread_sp) - std::static_pointer_cast (thread_sp)->SetCrashedWithException (*info); - break; - default: - // This is just a pre-signal-delivery notification of the incoming signal. - if (thread_sp) - std::static_pointer_cast (thread_sp)->SetStoppedBySignal (signo); - - break; - } + if (thread_sp) + std::static_pointer_cast (thread_sp)->SetStoppedBySignal(signo, info); // Send a stop to the debugger after we get all other threads to stop. StopRunningThreads (pid); -- cgit v1.2.3