Fix -break-enable/-break-disable commands (MI)
authorIlia K <ki.stfu@gmail.com>
Thu, 14 Jul 2016 07:43:14 +0000 (07:43 +0000)
committerIlia K <ki.stfu@gmail.com>
Thu, 14 Jul 2016 07:43:14 +0000 (07:43 +0000)
* Previously -break-enable mistakenly set BP's enabled flag to false.
* These commands print fake =breakpoint-modified messages, what's not
  needed anymore because that events are come in normal way.
* Add tests for -break-enable/-break-disable commands

Initial patch from xuefangliang@hotmail.com. The test case was improved by me.

Differential Revision: http://reviews.llvm.org/D21757

llvm-svn: 275381

lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
lldb/tools/lldb-mi/MICmdCmdBreak.cpp

index f5a221e..c4a801c 100644 (file)
@@ -246,3 +246,48 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
         self.runCmd("-exec-continue")
         self.expect("\^running")
         self.expect("\*stopped,reason=\"exited-normally\"")
+
+    @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+    @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+    def test_lldbmi_break_enable_disable(self):
+        """Test that 'lldb-mi --interpreter' works for enabling / disabling breakpoints."""
+
+        self.spawnLldbMi(args = None)
+
+        self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+        self.expect("\^done")
+
+        self.runCmd("-break-insert main")
+        self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\"")
+        self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
+
+        self.runCmd("-exec-run")
+        self.expect("\^running")
+        self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
+        self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\"")
+
+        self.runCmd("-break-insert ns::foo1")
+        self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\"")
+        self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
+
+        self.runCmd("-break-insert ns::foo2")
+        self.expect("\^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\"")
+        self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+
+        # disable the 2nd breakpoint
+        self.runCmd("-break-disable 2")
+        self.expect("\^done")
+        self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
+
+        # disable the 3rd breakpoint and re-enable
+        self.runCmd("-break-disable 3")
+        self.expect("\^done")
+        self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+
+        self.runCmd("-break-enable 3")
+        self.expect("\^done")
+        self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
index e758a3d..7238200 100644 (file)
@@ -568,19 +568,9 @@ CMICmdCmdBreakDisable::Acknowledge()
 {
     if (m_bBrkPtDisabledOk)
     {
-        const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
-        const CMICmnMIValueResult miValueResult("number", miValueConst);
-        CMICmnMIValueTuple miValueTuple(miValueResult);
-        const CMICmnMIValueConst miValueConst2("n");
-        const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
-        miValueTuple.Add(miValueResult2);
-        const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
-        const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
-        bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
-
         const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
         m_miResultRecord = miRecordResult;
-        return bOk;
+        return MIstatus::success;
     }
 
     const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
@@ -683,7 +673,7 @@ CMICmdCmdBreakEnable::Execute()
     if (brkPt.IsValid())
     {
         m_bBrkPtEnabledOk = true;
-        brkPt.SetEnabled(false);
+        brkPt.SetEnabled(true);
         m_nBrkPtId = nBrk;
     }
 
@@ -704,19 +694,9 @@ CMICmdCmdBreakEnable::Acknowledge()
 {
     if (m_bBrkPtEnabledOk)
     {
-        const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
-        const CMICmnMIValueResult miValueResult("number", miValueConst);
-        CMICmnMIValueTuple miValueTuple(miValueResult);
-        const CMICmnMIValueConst miValueConst2("y");
-        const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
-        miValueTuple.Add(miValueResult2);
-        const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
-        const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
-        bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
-
         const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
         m_miResultRecord = miRecordResult;
-        return bOk;
+        return MIstatus::success;
     }
 
     const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));