Skip to content

Commit 7ab3ffd

Browse files
committed
improve QueueThreadPlanForStepSingleInstruction tests
1 parent 8d8f4d7 commit 7ab3ffd

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,23 @@ 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):
47+
def run_until_branch_instruction(self):
4848
self.build()
4949
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
50-
self, "Break on foo call", self.main_source_file
50+
self, "Break on branch instruction", self.main_source_file
51+
)
52+
53+
# Check that we landed in a call instruction
54+
frame = thread.GetFrameAtIndex(0)
55+
current_instruction = target.ReadInstructions(frame.GetPCAddress(), 1)[0]
56+
self.assertEqual(
57+
lldb.eInstructionControlFlowKindCall,
58+
current_instruction.GetControlFlowKind(target),
5159
)
60+
return (target, process, thread, bkpt)
61+
62+
def test_step_single_instruction(self):
63+
(target, process, thread, bkpt) = self.run_until_branch_instruction()
5264

5365
err = thread.StepUsingScriptedThreadPlan("Steps.StepSingleInstruction")
5466
self.assertSuccess(err)
@@ -58,10 +70,11 @@ def test_step_single_instruction(self):
5870
self.assertEqual("foo", frame.GetFunctionName())
5971

6072
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-
)
73+
(target, process, thread, bkpt) = self.run_until_branch_instruction()
74+
75+
frame = thread.GetFrameAtIndex(0)
76+
next_instruction = target.ReadInstructions(frame.GetPCAddress(), 2)[1]
77+
next_instruction_address = next_instruction.GetAddress()
6578

6679
err = thread.StepUsingScriptedThreadPlan(
6780
"Steps.StepSingleInstructionWithStepOver"
@@ -71,6 +84,7 @@ def test_step_single_instruction_with_step_over(self):
7184
# Verify that stepping over an instruction doesn't step into `foo`
7285
frame = thread.GetFrameAtIndex(0)
7386
self.assertEqual("main", frame.GetFunctionName())
87+
self.assertEqual(next_instruction_address, frame.GetPCAddress())
7488

7589
def test_misspelled_plan_name(self):
7690
"""Test that we get a useful error if we misspell the plan class name"""

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(); // Break on foo call.
11+
foo(); // Break on branch instruction.
1212
return 0;
1313
}

0 commit comments

Comments
 (0)