Skip to content

[lldb][test] Handle potential compiler differences in TestEmptyFuncThreadStepOut.py#210050

Merged
DavidSpickett merged 1 commit into
llvm:mainfrom
DavidSpickett:lldb-emptyfuncstepout
Jul 17, 2026
Merged

[lldb][test] Handle potential compiler differences in TestEmptyFuncThreadStepOut.py#210050
DavidSpickett merged 1 commit into
llvm:mainfrom
DavidSpickett:lldb-emptyfuncstepout

Conversation

@DavidSpickett

Copy link
Copy Markdown
Contributor

Fixes #195958

It was reported that this test sometimes failed in CI because lldb would step out to line 6 instead of line 7.

Jim Ingham expained on the issue that both could be valid locations (#195958 (comment)).

There's no garauntee that "step out" would go to the source line after the call you step out of. All it does is go to the first location outside of the call. If the compiler so chose, that could be on the same line as the call.

I was not able to reproduce this failure mode, but I think it was happening in CI before, and is possible. So I've made the test accept line 6 or 7. Anything further than that we've gone too far and the test will fail.

…readStepOut.py

Fixes llvm#195958

It was reported that this test sometimes failed in CI because lldb would step
out to line 6 instead of line 7.

Jim Ingham expained on the issue that both could be valid locations
(llvm#195958 (comment)).

There's no garauntee that "step out" would go to the source line
after the call you step out of. All it does is go to the first location
outside of the call. If the compiler so chose, that could be on the same
line as the call.

I was not able to reproduce this failure mode, but I think it
was happening in CI before, and is possible. So I've made the test
accept line 6 or 7. Anything further than that we've gone too far
and the test will fail.
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

Fixes #195958

It was reported that this test sometimes failed in CI because lldb would step out to line 6 instead of line 7.

Jim Ingham expained on the issue that both could be valid locations (#195958 (comment)).

There's no garauntee that "step out" would go to the source line after the call you step out of. All it does is go to the first location outside of the call. If the compiler so chose, that could be on the same line as the call.

I was not able to reproduce this failure mode, but I think it was happening in CI before, and is possible. So I've made the test accept line 6 or 7. Anything further than that we've gone too far and the test will fail.


Full diff: https://github.com/llvm/llvm-project/pull/210050.diff

2 Files Affected:

  • (modified) lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py (+14-5)
  • (modified) lldb/test/API/functionalities/thread/finish-from-empty-func/main.c (+1-1)
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 c95a57ff55815..abf3f1c4ebbf4 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
@@ -41,7 +41,6 @@ def test_finish_from_empty_function(self):
         if self.TraceOn():
             self.runCmd("bt")
 
-        correct_stepped_out_line = line_number("main.c", "leaving main")
         return_statement_line = line_number("main.c", "return 0")
         safety_bp = target.BreakpointCreateByLocation(
             lldb.SBFileSpec("main.c"), return_statement_line
@@ -54,9 +53,19 @@ def test_finish_from_empty_function(self):
         if self.TraceOn():
             self.runCmd("bt")
 
-        frame = thread.GetSelectedFrame()
-        self.assertEqual(
-            frame.line_entry.GetLine(),
-            correct_stepped_out_line,
+        # Compilers may generate source locations differently, so we expect to
+        # either be:
+        # * On the line of the second done() call, or -
+        # * On the puts() line below.
+        #
+        # If we reach the return statement, we did not step out correctly.
+        stepped_out_lines = [
+            line_number("main.c", "leaving main"),
+            line_number("main.c", "Second call to done"),
+        ]
+
+        self.assertIn(
+            thread.GetSelectedFrame().line_entry.GetLine(),
+            stepped_out_lines,
             "Step-out lost control of execution, ran too far",
         )
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 b3f90db5e2562..e0165d7dcc987 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
@@ -3,7 +3,7 @@ void done() {}
 int main() {
   puts("in main");
   done(); // Set breakpoint here
-  done();
+  done(); // Second call to done
   puts("leaving main");
   return 0;
 }

@jimingham jimingham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

step-out is odd because unlike all the other stepping modes it doesn't guarantee that it will finish out source lines, but rather that it stops immediately on returning to the parent frame. So you can't know for certain whether a step out will stop in the calling line, or the following line.

So this is a more appropriate test.

@DavidSpickett
DavidSpickett merged commit 981c0f9 into llvm:main Jul 17, 2026
14 checks passed
@DavidSpickett
DavidSpickett deleted the lldb-emptyfuncstepout branch July 17, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lldb-api :: functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py failing on AArch64 CI

2 participants