[Lldb-commits] [lldb] r277662 - Errors compiling breakpoint conditions will cause the breakpoint not to be hit

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 3 15:46:12 PDT 2016


Author: jingham
Date: Wed Aug  3 17:46:11 2016
New Revision: 277662

URL: http://llvm.org/viewvc/llvm-project?rev=277662&view=rev
Log:
Errors compiling breakpoint conditions will cause the breakpoint not to be hit

This was a shadowed variable error from the big Expression Parser plugin-ification.  I also 
added a test case for this.

<rdar://problem/27682376>

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py?rev=277662&r1=277661&r2=277662&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py Wed Aug  3 17:46:11 2016
@@ -36,6 +36,13 @@ class BreakpointConditionsTestCase(TestB
         self.build()
         self.breakpoint_conditions_python()
 
+    @skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232)
+    @add_test_categories(['pyapi'])
+    def test_breakpoint_invalid_condition_and_python_api(self):
+        """Use Python APIs to set breakpoint conditions."""
+        self.build()
+        self.breakpoint_invalid_conditions_python()
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -186,3 +193,40 @@ class BreakpointConditionsTestCase(TestB
         value = frame0.EvaluateExpression("$0", options)
         self.assertTrue(value.GetError().Fail(), "Conditions should not make result variables.")
         process.Continue()
+
+    def breakpoint_invalid_conditions_python(self):
+        """Use Python APIs to set breakpoint conditions."""
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        # Create a target by the debugger.
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        # Now create a breakpoint on main.c by name 'c'.
+        breakpoint = target.BreakpointCreateByName('c', 'a.out')
+        #print("breakpoint:", breakpoint)
+        self.assertTrue(breakpoint and
+                        breakpoint.GetNumLocations() == 1,
+                        VALID_BREAKPOINT)
+
+        # Set the condition on the breakpoint.
+        breakpoint.SetCondition('no_such_variable == not_this_one_either')
+        self.expect(breakpoint.GetCondition(), exe=False,
+            startstr = 'no_such_variable == not_this_one_either')
+
+        # Now launch the process, and do not stop at entry point.
+        process = target.LaunchSimple (None, None, self.get_process_working_directory())
+        self.assertTrue(process, PROCESS_IS_VALID)
+
+        # Frame #0 should be on self.line1 and the break condition should hold.
+        from lldbsuite.test.lldbutil import get_stopped_thread
+        thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+        self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+        frame0 = thread.GetFrameAtIndex(0)
+        var = frame0.FindValue('val', lldb.eValueTypeVariableArgument)
+        self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1)
+
+        # The hit count for the breakpoint should be 1.
+        self.assertTrue(breakpoint.GetHitCount() == 1)
+
+

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=277662&r1=277661&r2=277662&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Wed Aug  3 17:46:11 2016
@@ -272,6 +272,8 @@ BreakpointLocation::ConditionSaysStop (E
         return false;
     }
 
+    error.Clear();
+        
     DiagnosticManager diagnostics;
 
     if (condition_hash != m_condition_hash || !m_user_expression_sp || !m_user_expression_sp->MatchesContext(exe_ctx))
@@ -282,7 +284,6 @@ BreakpointLocation::ConditionSaysStop (E
         if (comp_unit)
             language = comp_unit->GetLanguage();
         
-        Error error;
         m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text,
                                                                             nullptr,
                                                                             language,
@@ -302,7 +303,7 @@ BreakpointLocation::ConditionSaysStop (E
             error.SetErrorStringWithFormat("Couldn't parse conditional expression:\n%s",
                                            diagnostics.GetString().c_str());
             m_user_expression_sp.reset();
-            return false;
+            return true;
         }
 
         m_condition_hash = condition_hash;




More information about the lldb-commits mailing list