diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/step_scripted')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py | 17 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py | 26 |
2 files changed, 37 insertions, 6 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py index f93559af736..4133cbbe608 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py @@ -38,18 +38,29 @@ class StepScripted(StepWithChild): # This plan does a step-over until a variable changes value. class StepUntil(StepWithChild): - def __init__(self, thread_plan, dict): + def __init__(self, thread_plan, args_data, dict): self.frame = thread_plan.GetThread().frames[0] self.target = thread_plan.GetThread().GetProcess().GetTarget() - self.value = self.frame.FindVariable("foo") + func_entry = args_data.GetValueForKey("variable_name") + + if not func_entry.IsValid(): + print("Did not get a valid entry for variable_name") + func_name = func_entry.GetStringValue(100) + + self.value = self.frame.FindVariable(func_name) + if self.value.GetError().Fail(): + print("Failed to get foo value: %s"%(self.value.GetError().GetCString())) + else: + print("'foo' value: %d"%(self.value.GetValueAsUnsigned())) + StepWithChild.__init__(self, thread_plan) + def queue_child_thread_plan(self): le = self.frame.GetLineEntry() start_addr = le.GetStartAddress() start = start_addr.GetLoadAddress(self.target) end = le.GetEndAddress().GetLoadAddress(self.target) - print("Stepping from 0x%x to 0x%x (0x%x)"%(start, end, end - start)) return self.thread_plan.QueueThreadPlanForStepOverRange(start_addr, end - start) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py index cadadde9677..eb1b5822580 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py @@ -63,7 +63,14 @@ class StepScriptedTestCase(TestBase): self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") def test_checking_variable(self): - """Test that we can call SBValue API's from a scripted thread plan""" + """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" + self.do_test_checking_variable(False) + + def test_checking_variable_cli(self): + """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" + self.do_test_checking_variable(True) + + def do_test_checking_variable(self, use_cli): self.build() (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here", @@ -75,8 +82,21 @@ class StepScriptedTestCase(TestBase): self.assertTrue(foo_val.GetError().Success(), "Got the foo variable") self.assertEqual(foo_val.GetValueAsUnsigned(), 10, "foo starts at 10") - err = thread.StepUsingScriptedThreadPlan("Steps.StepUntil") - self.assertTrue(err.Success(), err.GetCString()) + if use_cli: + result = lldb.SBCommandReturnObject() + self.dbg.GetCommandInterpreter().HandleCommand( + "thread step-scripted -C Steps.StepUntil -k variable_name -v foo", + result) + self.assertTrue(result.Succeeded()) + else: + args_data = lldb.SBStructuredData() + data = lldb.SBStream() + data.Print('{"variable_name" : "foo"}') + error = args_data.SetFromJSON(data) + self.assertTrue(error.Success(), "Made the args_data correctly") + + err = thread.StepUsingScriptedThreadPlan("Steps.StepUntil", args_data, True) + self.assertTrue(err.Success(), err.GetCString()) # We should not have exited: self.assertEqual(process.GetState(), lldb.eStateStopped, "We are stopped") |