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/NativeThreadLinux.cpp | 40 +++++++++------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index cd0dd7edc511..8950702c532c 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -125,15 +125,7 @@ NativeThreadLinux::GetStopReason (ThreadStopInfo &stop_info, std::string& descri if (log) LogThreadStopInfo (*log, m_stop_info, "m_stop_info in thread:"); stop_info = m_stop_info; - switch (m_stop_info.reason) - { - case StopReason::eStopReasonException: - case StopReason::eStopReasonBreakpoint: - case StopReason::eStopReasonWatchpoint: - description = m_stop_description; - default: - break; - } + description = m_stop_description; if (log) LogThreadStopInfo (*log, stop_info, "returned stop_info:"); @@ -250,7 +242,7 @@ NativeThreadLinux::SetStepping () } void -NativeThreadLinux::SetStoppedBySignal (uint32_t signo) +NativeThreadLinux::SetStoppedBySignal(uint32_t signo, const siginfo_t *info) { Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD)); if (log) @@ -262,6 +254,20 @@ NativeThreadLinux::SetStoppedBySignal (uint32_t signo) m_stop_info.reason = StopReason::eStopReasonSignal; m_stop_info.details.signal.signo = signo; + + m_stop_description.clear(); + switch (signo) + { + case SIGSEGV: + case SIGBUS: + case SIGFPE: + case SIGILL: + if (! info) + break; + const auto reason = GetCrashReason(*info); + m_stop_description = GetCrashReasonString(reason, reinterpret_cast(info->si_addr)); + break; + } } bool @@ -355,20 +361,6 @@ NativeThreadLinux::SetStoppedByTrace () m_stop_info.details.signal.signo = SIGTRAP; } -void -NativeThreadLinux::SetCrashedWithException (const siginfo_t& info) -{ - const StateType new_state = StateType::eStateCrashed; - MaybeLogStateChange (new_state); - m_state = new_state; - - m_stop_info.reason = StopReason::eStopReasonException; - m_stop_info.details.signal.signo = info.si_signo; - - const auto reason = GetCrashReason (info); - m_stop_description = GetCrashReasonString (reason, reinterpret_cast(info.si_addr)); -} - void NativeThreadLinux::SetSuspended () { -- cgit v1.2.3