Skip to content

Commit 16333e4

Browse files
committed
Add API tests for QueueThreadPlanForStepSingleInstruction
1 parent d3c5fb5 commit 16333e4

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

lldb/test/API/functionalities/step_scripted/Steps.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ def queue_child_thread_plan(self):
4545
return self.thread_plan.QueueThreadPlanForStepScripted("Steps.StepOut")
4646

4747

48+
class StepSingleInstruction(StepWithChild):
49+
def __init__(self, thread_plan, dict):
50+
super().__init__(thread_plan)
51+
52+
def queue_child_thread_plan(self):
53+
return self.thread_plan.QueueThreadPlanForStepSingleInstruction(False)
54+
55+
56+
class StepSingleInstructionWithStepOver(StepWithChild):
57+
def __init__(self, thread_plan, dict):
58+
super().__init__(thread_plan)
59+
60+
def queue_child_thread_plan(self):
61+
return self.thread_plan.QueueThreadPlanForStepSingleInstruction(True)
62+
63+
4864
# This plan does a step-over until a variable changes value.
4965
class StepUntil(StepWithChild):
5066
def __init__(self, thread_plan, args_data):

lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,34 @@ def step_out_with_scripted_plan(self, name):
4444
stop_desc = thread.GetStopDescription(1000)
4545
self.assertIn("Stepping out from", stop_desc, "Got right description")
4646

47+
def test_step_single_instruction(self):
48+
self.build()
49+
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
50+
self, "Break on foo call", self.main_source_file
51+
)
52+
53+
err = thread.StepUsingScriptedThreadPlan("Steps.StepSingleInstruction")
54+
self.assertSuccess(err)
55+
56+
# Verify that stepping a single instruction after "foo();" steps into `foo`
57+
frame = thread.GetFrameAtIndex(0)
58+
self.assertEqual("foo", frame.GetFunctionName())
59+
60+
def test_step_single_instruction_with_step_over(self):
61+
self.build()
62+
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
63+
self, "Break on foo call", self.main_source_file
64+
)
65+
66+
err = thread.StepUsingScriptedThreadPlan(
67+
"Steps.StepSingleInstructionWithStepOver"
68+
)
69+
self.assertSuccess(err)
70+
71+
# Verify that stepping over an instruction doesn't step into `foo`
72+
frame = thread.GetFrameAtIndex(0)
73+
self.assertEqual("main", frame.GetFunctionName())
74+
4775
def test_misspelled_plan_name(self):
4876
"""Test that we get a useful error if we misspell the plan class name"""
4977
self.build()

lldb/test/API/functionalities/step_scripted/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ void foo() {
88
}
99

1010
int main() {
11-
foo();
11+
foo(); // Break on foo call.
1212
return 0;
1313
}

0 commit comments

Comments
 (0)