[Lldb-commits] [lldb] r237426 - Fix a reason of *stopped notifications due to SIGINT/SIGSTOP signals (MI)

Ilia K ki.stfu at gmail.com
Fri May 15 02:29:09 PDT 2015


Author: ki.stfu
Date: Fri May 15 04:29:09 2015
New Revision: 237426

URL: http://llvm.org/viewvc/llvm-project?rev=237426&view=rev
Log:
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


Modified:
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/scripts/interface/SBProcess.i
    lldb/trunk/source/API/SBProcess.cpp
    lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Fri May 15 04:29:09 2015
@@ -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);

Modified: lldb/trunk/scripts/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBProcess.i?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBProcess.i (original)
+++ lldb/trunk/scripts/interface/SBProcess.i Fri May 15 04:29:09 2015
@@ -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

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Fri May 15 04:29:09 2015
@@ -999,6 +999,12 @@ SBProcess::GetProcessFromEvent (const SB
 }
 
 bool
+SBProcess::GetInterruptedFromEvent (const SBEvent &event)
+{
+    return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
+}
+
+bool
 SBProcess::EventIsProcessEvent (const SBEvent &event)
 {
     return event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass();

Modified: lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py (original)
+++ lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py Fri May 15 04:29:09 2015
@@ -66,9 +66,9 @@ class MiSignalTestCase(lldbmi_testcase.M
 
         # 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.M
         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")

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Fri May 15 04:29:09 2015
@@ -835,7 +835,7 @@ CMICmnLLDBDebuggerHandleEvents::HandlePr
             break;
         case lldb::eStateStopped:
             pEventType = "eStateStopped";
-            bOk = HandleProcessEventStateStopped(bShouldBrk);
+            bOk = HandleProcessEventStateStopped(vEvent, bShouldBrk);
             if (bShouldBrk)
                 break;
         case lldb::eStateCrashed:
@@ -924,7 +924,7 @@ CMICmnLLDBDebuggerHandleEvents::HandlePr
 // 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::HandlePr
             break;
         case lldb::eStopReasonSignal:
             pEventType = "eStopReasonSignal";
-            bOk = HandleProcessEventStopSignal(vwrbShouldBrk);
+            bOk = HandleProcessEventStopSignal(vrEvent);
             break;
         case lldb::eStopReasonException:
             pEventType = "eStopReasonException";
@@ -985,22 +985,23 @@ CMICmnLLDBDebuggerHandleEvents::HandlePr
 //++ ------------------------------------------------------------------------------------
 // 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::HandlePr
         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::HandlePr
         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::HandlePr
                 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);

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h?rev=237426&r1=237425&r2=237426&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h Fri May 15 04:29:09 2015
@@ -63,10 +63,10 @@ class CMICmnLLDBDebuggerHandleEvents : p
     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);





More information about the lldb-commits mailing list