[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

Ely Ronnen via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 30 12:45:01 PDT 2025


================
@@ -44,6 +44,34 @@ def step_out_with_scripted_plan(self, name):
         stop_desc = thread.GetStopDescription(1000)
         self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+    def test_step_single_instruction(self):
+        self.build()
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "Break on foo call", self.main_source_file
+        )
+
+        err = thread.StepUsingScriptedThreadPlan("Steps.StepSingleInstruction")
+        self.assertSuccess(err)
+
+        # Verify that stepping a single instruction after "foo();" steps into `foo`
+        frame = thread.GetFrameAtIndex(0)
+        self.assertEqual("foo", frame.GetFunctionName())
+
+    def test_step_single_instruction_with_step_over(self):
+        self.build()
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "Break on foo call", self.main_source_file
+        )
+
+        err = thread.StepUsingScriptedThreadPlan(
+            "Steps.StepSingleInstructionWithStepOver"
+        )
+        self.assertSuccess(err)
+
+        # Verify that stepping over an instruction doesn't step into `foo`
+        frame = thread.GetFrameAtIndex(0)
+        self.assertEqual("main", frame.GetFunctionName())
----------------
eronnen wrote:

makes sense, I didn't have any other straightfoward idea for a 100% way to break on a branch instruction but adding a check is a good idea

https://github.com/llvm/llvm-project/pull/137904


More information about the lldb-commits mailing list