forked from OSchip/llvm-project
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> llvm-svn: 277662
This commit is contained in:
parent
1873998b16
commit
298de8f6a3
|
@ -36,6 +36,13 @@ class BreakpointConditionsTestCase(TestBase):
|
|||
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(TestBase):
|
|||
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)
|
||||
|
||||
|
||||
|
|
|
@ -272,6 +272,8 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
|
|||
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 (ExecutionContext &exe_ctx, Error &error)
|
|||
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 (ExecutionContext &exe_ctx, Error &error)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue