@@ -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"""
0 commit comments