================
@@ -15,10 +15,23 @@ class FinishFromEmptyFunctionTestCase(TestBase):
     def test_finish_from_empty_function(self):
         """Test that when stopped at a breakpoint in an empty function, finish 
leaves it correctly."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-        target, process, thread, _ = lldbutil.run_to_name_breakpoint(
-            self, "done", exe_name=exe
+        target, _, thread, _ = lldbutil.run_to_source_breakpoint(
+            self, "// Set breakpoint here", lldb.SBFileSpec("main.c")
         )
+        # Find the last instruction address of 'done()' and set a breakpoint 
there.
+        error = lldb.SBError()
+        ret_bp_addr = lldb.SBAddress()
+        while True:
+            thread.StepInstruction(False, error)
+            self.assertTrue(error.Success())
+            frame = thread.GetSelectedFrame()
+            if "done" in frame.GetFunctionName():
+                ret_bp_addr = frame.GetPCAddress()
+            elif ret_bp_addr.IsValid():
+                break
----------------
igorkudrin wrote:

In theory, we could disassemble the function and take the last instruction, but 
I believe that stepping through it is a simpler approach.

https://github.com/llvm/llvm-project/pull/161788
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to