[Lldb-commits] [lldb] r230237 - Fix a problem where lldb-mi would not stop the debuggee after -exec-interrupt command.
Hafiz Abid Qadeer
hafiz_abid at mentor.com
Mon Feb 23 10:27:18 PST 2015
Author: abidh
Date: Mon Feb 23 12:27:17 2015
New Revision: 230237
URL: http://llvm.org/viewvc/llvm-project?rev=230237&view=rev
Log:
Fix a problem where lldb-mi would not stop the debuggee after -exec-interrupt command.
Summary:
This revision fixes a problem where lldb-mi would not stop the execution after exec-interrupt call.
On Linux, SIGSTOP is used to stop the debuggee process. LLDB stopped the debuggee alright. But when
lldb-mi received the notification of stopping with reason as SIGSTOP, it would resume the process.
This was heppening in CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal. This function aslo
used hard coded numbers for signal istead of symbolic names.
This revision changes code to treat SIGSTOP reason as SIGINT. Also used symbolic names for signals
instead of numbers.
Reviewers: ki.stfu, clayborg
Reviewed By: ki.stfu, clayborg
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D7783
Modified:
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/test/tools/lldb-mi/signal/TestMiSignal.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py?rev=230237&r1=230236&r2=230237&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py (original)
+++ lldb/trunk/test/tools/lldb-mi/signal/TestMiSignal.py Mon Feb 23 12:27:17 2015
@@ -37,7 +37,7 @@ class MiSignalTestCase(lldbmi_testcase.M
# Test that -exec-interrupt can interrupt an execution
self.runCmd("-exec-interrupt")
- self.expect("\*stopped,reason=\"signal-received\"")
+ self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"")
# Continue (to loop forever)
self.runCmd("-exec-continue")
@@ -45,7 +45,7 @@ class MiSignalTestCase(lldbmi_testcase.M
# Test that Ctrl+C can interrupt an execution
self.child.sendintr() #FIXME: here uses self.child directly
- self.expect("\*stopped,reason=\"signal-received\"")
+ self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"")
@lldbmi_test
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp?rev=230237&r1=230236&r2=230237&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Mon Feb 23 12:27:17 2015
@@ -27,6 +27,7 @@
#include "lldb/API/SBThread.h"
#include "lldb/API/SBCommandInterpreter.h"
#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBUnixSignals.h"
#ifdef _WIN32
#include <io.h> // For the ::_access()
#else
@@ -88,6 +89,11 @@ CMICmnLLDBDebuggerHandleEvents::Initiali
return MIstatus::success;
m_bInitialized = MIstatus::success;
+ m_bSignalsInitialized = false;
+ m_SIGINT = 0;
+ m_SIGSTOP = 0;
+ m_SIGSEGV = 0;
+ m_SIGTRAP = 0;
return m_bInitialized;
}
@@ -832,106 +838,103 @@ CMICmnLLDBDebuggerHandleEvents::HandlePr
{
bool bOk = MIstatus::success;
+ InitializeSignals ();
lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
const MIuint64 nStopReason = sbProcess.GetSelectedThread().GetStopReasonDataAtIndex(0);
- switch (nStopReason)
+ if (nStopReason == m_SIGINT || nStopReason == m_SIGSTOP)
{
- case 2: // Terminal interrupt signal. SIGINT
- {
- // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGNINT\",signal-meaning=\"Interrupt\",frame={%s}"
- const CMICmnMIValueConst miValueConst("signal-received");
- const CMICmnMIValueResult miValueResult("reason", miValueConst);
- CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
- const CMICmnMIValueConst miValueConst2("SIGINT");
- const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
- const CMICmnMIValueConst miValueConst3("Interrupt");
- const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
- CMICmnMIValueTuple miValueTuple;
- bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple);
- const CMICmnMIValueResult miValueResult5("frame", miValueTuple);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
- bOk = bOk && TextToStdout("(gdb)");
- }
- break;
- case 11: // Invalid memory reference. SIGSEGV
- {
- // 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);
- const CMICmnMIValueConst miValueConst2("SIGSEGV");
- const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
- 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);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
- // Note no "(gdb)" output here
- }
- break;
- case 19:
- if (sbProcess.IsValid())
- sbProcess.Continue();
- break;
- case 5: // Trace/breakpoint trap. SIGTRAP
+ // MI print "*stopped,reason=\"signal-received\",signal-name=\"SIGNINT\",signal-meaning=\"Interrupt\",frame={%s}"
+ const CMICmnMIValueConst miValueConst("signal-received");
+ const CMICmnMIValueResult miValueResult("reason", miValueConst);
+ CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
+ const CMICmnMIValueConst miValueConst2("SIGINT");
+ const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
+ bOk = miOutOfBandRecord.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3("Interrupt");
+ const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
+ bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ CMICmnMIValueTuple miValueTuple;
+ bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple);
+ const CMICmnMIValueResult miValueResult5("frame", miValueTuple);
+ bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
+ const CMICmnMIValueConst miValueConst6(strThreadId);
+ const CMICmnMIValueResult miValueResult6("thread-id", 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 && TextToStdout("(gdb)");
+ }
+ else if (nStopReason == m_SIGSEGV)
+ {
+ // 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);
+ const CMICmnMIValueConst miValueConst2("SIGSEGV");
+ const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
+ bOk = miOutOfBandRecord.Add(miValueResult2);
+ 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);
+ bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ // Note no "(gdb)" output here
+ }
+ else if (nStopReason == m_SIGTRAP)
+ {
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
+ const MIuint nFrames = thread.GetNumFrames();
+ if (nFrames > 0)
{
- lldb::SBThread thread = sbProcess.GetSelectedThread();
- const MIuint nFrames = thread.GetNumFrames();
- if (nFrames > 0)
+ lldb::SBFrame frame = thread.GetFrameAtIndex(0);
+ const char *pFnName = frame.GetFunctionName();
+ if (pFnName != nullptr)
{
- lldb::SBFrame frame = thread.GetFrameAtIndex(0);
- const char *pFnName = frame.GetFunctionName();
- if (pFnName != nullptr)
- {
- const CMIUtilString fnName = CMIUtilString(pFnName);
- static const CMIUtilString threadCloneFn = CMIUtilString("__pthread_clone");
+ const CMIUtilString fnName = CMIUtilString(pFnName);
+ static const CMIUtilString threadCloneFn = CMIUtilString("__pthread_clone");
- if (CMIUtilString::Compare(threadCloneFn, fnName))
+ if (CMIUtilString::Compare(threadCloneFn, fnName))
+ {
+ if (sbProcess.IsValid())
{
- if (sbProcess.IsValid())
- {
- sbProcess.Continue();
- vwrbShouldBrk = true;
- break;
- }
+ sbProcess.Continue();
+ vwrbShouldBrk = true;
}
}
}
}
- default:
- {
- // MI print "*stopped,reason=\"signal-received\",signal=\"%lld\",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);
- const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
- const CMICmnMIValueConst miValueConst3(strThreadId);
- const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
- const CMICmnMIValueConst miValueConst4("all");
- const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
- bOk = bOk && TextToStdout("(gdb)");
- }
- } // switch( nStopReason )
-
+ }
+ else
+ {
+ // MI print "*stopped,reason=\"signal-received\",signal=\"%lld\",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);
+ const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
+ const CMICmnMIValueConst miValueConst3(strThreadId);
+ const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3);
+ bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ const CMICmnMIValueConst miValueConst4("all");
+ const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4);
+ bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bOk = bOk && TextToStdout("(gdb)");
+ }
return bOk;
}
@@ -1651,3 +1654,29 @@ CMICmnLLDBDebuggerHandleEvents::TextToSt
{
return CMICmnStreamStderr::TextToStderr(vrTxt);
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Initialize the member variables with the signal values in this process
+// file.
+// Type: Method.
+// Args: None
+// Return: Noen
+// Throws: None.
+//--
+void
+CMICmnLLDBDebuggerHandleEvents::InitializeSignals()
+{
+ if (!m_bSignalsInitialized)
+ {
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ if (sbProcess.IsValid())
+ {
+ lldb::SBUnixSignals unix_signals = sbProcess.GetUnixSignals();
+ m_SIGINT = unix_signals.GetSignalNumberFromName("SIGINT");
+ m_SIGSTOP = unix_signals.GetSignalNumberFromName("SIGSTOP");
+ m_SIGSEGV = unix_signals.GetSignalNumberFromName("SIGSEGV");
+ m_SIGTRAP = unix_signals.GetSignalNumberFromName("SIGTRAP");
+ m_bSignalsInitialized = true;
+ }
+ }
+}
Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h?rev=230237&r1=230236&r2=230237&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h Mon Feb 23 12:27:17 2015
@@ -92,4 +92,10 @@ class CMICmnLLDBDebuggerHandleEvents : p
private:
// From CMICmnBase
/* dtor */ virtual ~CMICmnLLDBDebuggerHandleEvents(void);
+ void InitializeSignals();
+ bool m_bSignalsInitialized;
+ MIuint64 m_SIGINT;
+ MIuint64 m_SIGSTOP;
+ MIuint64 m_SIGSEGV;
+ MIuint64 m_SIGTRAP;
};
More information about the lldb-commits
mailing list