diff options
| author | Ilia K <ki.stfu@gmail.com> | 2015-05-15 09:29:09 +0000 |
|---|---|---|
| committer | Ilia K <ki.stfu@gmail.com> | 2015-05-15 09:29:09 +0000 |
| commit | 06d2855fb3fd7dcc623f14c2d0469bc173ca00c0 (patch) | |
| tree | 34955079b79829a5e533af6f9010141a2db235fd | |
| parent | d50ea2fc158a690a83d45d5cca49be72c6861356 (diff) | |
| download | bcm5719-llvm-06d2855fb3fd7dcc623f14c2d0469bc173ca00c0.tar.gz bcm5719-llvm-06d2855fb3fd7dcc623f14c2d0469bc173ca00c0.zip | |
Fix a reason of *stopped notifications due to SIGINT/SIGSTOP signals (MI)
# Add SBProcess::GetInterruptedFromEvent
# Add vrEvent arg in CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped
and CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal
# Refactor CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal
## Clean up and fix typos
## Remove vwrbShouldBrk arg
# Fix MiSignalTestCase.test_lldbmi_stopped_when_stopatentry_{local,remote}
to expect SIGSTOP instead of SIGINT
llvm-svn: 237426
| -rw-r--r-- | lldb/include/lldb/API/SBProcess.h | 3 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBProcess.i | 3 | ||||
| -rw-r--r-- | lldb/source/API/SBProcess.cpp | 6 | ||||
| -rw-r--r-- | lldb/test/tools/lldb-mi/signal/TestMiSignal.py | 6 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp | 93 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h | 4 |
6 files changed, 81 insertions, 34 deletions
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index b73c83af075..d62d4116a4a 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -260,6 +260,9 @@ public: static lldb::SBProcess GetProcessFromEvent (const lldb::SBEvent &event); + + static bool + GetInterruptedFromEvent (const lldb::SBEvent &event); static bool EventIsProcessEvent (const lldb::SBEvent &event); diff --git a/lldb/scripts/interface/SBProcess.i b/lldb/scripts/interface/SBProcess.i index e6f5464d0e6..91efd4e703a 100644 --- a/lldb/scripts/interface/SBProcess.i +++ b/lldb/scripts/interface/SBProcess.i @@ -349,6 +349,9 @@ public: GetProcessFromEvent (const lldb::SBEvent &event); static bool + GetInterruptedFromEvent (const lldb::SBEvent &event); + + static bool EventIsProcessEvent (const lldb::SBEvent &event); lldb::SBBroadcaster diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index aad3f85ae63..c84da7f8ed9 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -999,6 +999,12 @@ SBProcess::GetProcessFromEvent (const SBEvent &event) } bool +SBProcess::GetInterruptedFromEvent (const SBEvent &event) +{ + return Process::ProcessEventData::GetInterruptedFromEvent(event.get()); +} + +bool SBProcess::EventIsProcessEvent (const SBEvent &event) { return event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass(); diff --git a/lldb/test/tools/lldb-mi/signal/TestMiSignal.py b/lldb/test/tools/lldb-mi/signal/TestMiSignal.py index 0b1e0519468..f542c81de4d 100644 --- a/lldb/test/tools/lldb-mi/signal/TestMiSignal.py +++ b/lldb/test/tools/lldb-mi/signal/TestMiSignal.py @@ -66,9 +66,9 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase): # Test that *stopped is printed # Note that message is different in Darwin and Linux: - # Darwin: "*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",frame={level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\" + # Darwin: "*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame={level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\" # Linux: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"??\",args=[],file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\" - self.expect([ "\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\},thread-id=\"1\",stopped-threads=\"all\"", + self.expect([ "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\},thread-id=\"1\",stopped-threads=\"all\"", "\*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"\?\?\",args=\[\],file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"" ]) # Run to main to make sure we have not exited the application @@ -111,7 +111,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\^done") # Test that *stopped is printed - self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.+?thread-id=\"1\",stopped-threads=\"all\"") + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.+?thread-id=\"1\",stopped-threads=\"all\"") # Exit self.runCmd("-gdb-exit") diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp index 37e75bdacf9..c3793d9f8bc 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -835,7 +835,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventBroadcastBitStateChanged(const break; case lldb::eStateStopped: pEventType = "eStateStopped"; - bOk = HandleProcessEventStateStopped(bShouldBrk); + bOk = HandleProcessEventStateStopped(vEvent, bShouldBrk); if (bShouldBrk) break; case lldb::eStateCrashed: @@ -924,7 +924,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended(const lldb::SBE // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(bool &vwrbShouldBrk) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(const lldb::SBEvent &vrEvent, bool &vwrbShouldBrk) { if (!UpdateSelectedThread()) return MIstatus::failure; @@ -955,7 +955,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(bool &vwrbShouldB break; case lldb::eStopReasonSignal: pEventType = "eStopReasonSignal"; - bOk = HandleProcessEventStopSignal(vwrbShouldBrk); + bOk = HandleProcessEventStopSignal(vrEvent); break; case lldb::eStopReasonException: pEventType = "eStopReasonException"; @@ -985,22 +985,23 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(bool &vwrbShouldB //++ ------------------------------------------------------------------------------------ // Details: Asynchronous event handler for LLDB Process stop signal. // Type: Method. -// Args: vwrbShouldBrk - (W) True = Yes break, false = do not. +// Args: vrEvent - (R) An LLDB broadcast event. // Return: MIstatus::success - Functionality succeeded. // MIstatus::failure - Functionality failed. // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent &vrEvent) { bool bOk = MIstatus::success; InitializeSignals (); lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); const MIuint64 nStopReason = sbProcess.GetSelectedThread().GetStopReasonDataAtIndex(0); - if (nStopReason == m_SIGINT || nStopReason == m_SIGSTOP) + const bool bInterrupted = lldb::SBProcess::GetInterruptedFromEvent(vrEvent); + if (nStopReason == m_SIGINT || (nStopReason == m_SIGSTOP && bInterrupted)) { - // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGNINT\",signal-meaning=\"Interrupt\",frame={%s}" + // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",frame={%s},thread-id=\"%d\",stopped-threads=\"all\"" const CMICmnMIValueConst miValueConst("signal-received"); const CMICmnMIValueResult miValueResult("reason", miValueConst); CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); @@ -1012,22 +1013,47 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk bOk = bOk && miOutOfBandRecord.Add(miValueResult3); CMICmnMIValueTuple miValueTuple; bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); - const CMICmnMIValueResult miValueResult5("frame", miValueTuple); + const CMICmnMIValueResult miValueResult4("frame", miValueTuple); + bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID())); + const CMICmnMIValueConst miValueConst5(strThreadId); + const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); bOk = bOk && miOutOfBandRecord.Add(miValueResult5); - const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); - const CMICmnMIValueConst miValueConst6(strThreadId); - const CMICmnMIValueResult miValueResult6("thread-id", miValueConst6); + const CMICmnMIValueConst miValueConst6("all"); + const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6); + bOk = bOk && miOutOfBandRecord.Add(miValueResult6); + bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); + bOk = bOk && CMICmnStreamStdout::WritePrompt(); + } + else if (nStopReason == m_SIGSTOP) + { + // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame={%s},thread-id=\"%d\",stopped-threads=\"all\"" + const CMICmnMIValueConst miValueConst("signal-received"); + const CMICmnMIValueResult miValueResult("reason", miValueConst); + CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); + const CMICmnMIValueConst miValueConst2("SIGSTOP"); + const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); + bOk = miOutOfBandRecord.Add(miValueResult2); + const CMICmnMIValueConst miValueConst3("Stop"); + const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3); + bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + CMICmnMIValueTuple miValueTuple; + bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); + const CMICmnMIValueResult miValueResult4("frame", miValueTuple); + bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID())); + const CMICmnMIValueConst miValueConst5(strThreadId); + const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); + bOk = bOk && miOutOfBandRecord.Add(miValueResult5); + const CMICmnMIValueConst miValueConst6("all"); + const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6); bOk = bOk && miOutOfBandRecord.Add(miValueResult6); - const CMICmnMIValueConst miValueConst7("all"); - const CMICmnMIValueResult miValueResult7("stopped-threads", miValueConst7); - bOk = bOk && miOutOfBandRecord.Add(miValueResult7); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); } else if (nStopReason == m_SIGSEGV) { - // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGSEGV\",signal-meaning=\"Segmentation - // fault\",thread-id=\"%d\",frame={%s}" + // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGSEGV\",signal-meaning=\"Segmentation fault\",thread-id=\"%d\",frame={%s}" const CMICmnMIValueConst miValueConst("signal-received"); const CMICmnMIValueResult miValueResult("reason", miValueConst); CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); @@ -1037,13 +1063,13 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk const CMICmnMIValueConst miValueConst3("Segmentation fault"); const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3); bOk = bOk && miOutOfBandRecord.Add(miValueResult3); - const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); - const CMICmnMIValueConst miValueConst4(strThreadId); - const CMICmnMIValueResult miValueResult4("thread-id", miValueConst4); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); CMICmnMIValueTuple miValueTuple; bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); - const CMICmnMIValueResult miValueResult5("frame", miValueTuple); + const CMICmnMIValueResult miValueResult4("frame", miValueTuple); + bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); + const CMICmnMIValueConst miValueConst5(strThreadId); + const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); bOk = bOk && miOutOfBandRecord.Add(miValueResult5); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); // Note no "(gdb)" output here @@ -1064,24 +1090,33 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk if (CMIUtilString::Compare(threadCloneFn, fnName)) { if (sbProcess.IsValid()) - { sbProcess.Continue(); - vwrbShouldBrk = true; - } } } } } else { - // MI print "*stopped,reason=\"signal-received\",signal=\"%lld\",thread-id=\"%d\",stopped-threads=\"all\"" + // MI print "*stopped,reason=\"signal-received\",signal-name=\"%s\",thread-id=\"%d\",stopped-threads=\"all\"" + // MI print "*stopped,reason=\"signal-received\",signal=\"%d\",thread-id=\"%d\",stopped-threads=\"all\"" const CMICmnMIValueConst miValueConst("signal-received"); const CMICmnMIValueResult miValueResult("reason", miValueConst); CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); - const CMIUtilString strReason(CMIUtilString::Format("%lld", nStopReason)); - const CMICmnMIValueConst miValueConst2(strReason); - const CMICmnMIValueResult miValueResult2("signal", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + lldb::SBUnixSignals sbUnixSignals = sbProcess.GetUnixSignals(); + const MIchar *pSignal = sbUnixSignals.GetSignalAsCString(nStopReason); + if (pSignal) + { + const CMICmnMIValueConst miValueConst2(pSignal); + const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); + bOk = miOutOfBandRecord.Add(miValueResult2); + } + else + { + const CMIUtilString strSignal(CMIUtilString::Format("%" PRIu64, nStopReason)); + const CMICmnMIValueConst miValueConst2(strSignal); + const CMICmnMIValueResult miValueResult2("signal", miValueConst2); + bOk = miOutOfBandRecord.Add(miValueResult2); + } const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); const CMICmnMIValueConst miValueConst3(strThreadId); const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3); diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h index 00ac5779fe7..9b7b5d6f7b0 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h +++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h @@ -63,10 +63,10 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton< bool HandleProcessEventBroadcastBitStateChanged(const lldb::SBEvent &vEvent); bool HandleProcessEventStateRunning(void); bool HandleProcessEventStateExited(void); - bool HandleProcessEventStateStopped(bool &vwrbShouldBrk); + bool HandleProcessEventStateStopped(const lldb::SBEvent &vrEvent, bool &vwrbShouldBrk); bool HandleProcessEventStopReasonTrace(void); bool HandleProcessEventStopReasonBreakpoint(void); - bool HandleProcessEventStopSignal(bool &vwrbShouldBrk); + bool HandleProcessEventStopSignal(const lldb::SBEvent &vrEvent); bool HandleProcessEventStopException(void); bool HandleProcessEventStateSuspended(const lldb::SBEvent &vEvent); bool HandleTargetEventBroadcastBitModulesLoaded(const lldb::SBEvent &vEvent); |

