[Lldb-commits] [lldb] [lldb][test] Fix TestEmptyFuncThreadStepOut.py (PR #161788)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 2 23:18:07 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Igor Kudrin (igorkudrin)
<details>
<summary>Changes</summary>
The test did not work as intended when the empty function 'done()' contained epilog code, because a breakpoint was set on the first instruction of the epilog instead of on the last instruction of the function. This caused the test to pass even with the fix from #<!-- -->126838 reverted.
---
Full diff: https://github.com/llvm/llvm-project/pull/161788.diff
2 Files Affected:
- (modified) lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py (+16-4)
- (modified) lldb/test/API/functionalities/thread/finish-from-empty-func/main.c (+1)
``````````diff
diff --git a/lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py b/lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py
index f5d3da530f4f5..be0d47d1d8fe6 100644
--- a/lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py
+++ b/lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py
@@ -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
+ ret_bp = target.BreakpointCreateByAddress(ret_bp_addr.GetLoadAddress(target))
+ self.assertTrue(ret_bp.IsValid())
+ self.runCmd("cont")
if self.TraceOn():
self.runCmd("bt")
@@ -29,7 +42,6 @@ def test_finish_from_empty_function(self):
)
self.assertTrue(safety_bp.IsValid())
- error = lldb.SBError()
thread.StepOut(error)
self.assertTrue(error.Success())
diff --git a/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c b/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c
index bc66a548a89df..b3f90db5e2562 100644
--- a/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c
+++ b/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c
@@ -2,6 +2,7 @@
void done() {}
int main() {
puts("in main");
+ done(); // Set breakpoint here
done();
puts("leaving main");
return 0;
``````````
</details>
https://github.com/llvm/llvm-project/pull/161788
More information about the lldb-commits
mailing list