https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/210050

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 
(https://github.com/llvm/llvm-project/issues/195958#issuecomment-4384269846).

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.

>From ac0eee35421451b0fe0dcfe86c6da7ee7d773458 Mon Sep 17 00:00:00 2001
From: David Spickett <[email protected]>
Date: Thu, 16 Jul 2026 12:50:44 +0000
Subject: [PATCH] [lldb][test] Handle potential compiler differences in
 TestEmptyFuncThreadStepOut.py

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
(https://github.com/llvm/llvm-project/issues/195958#issuecomment-4384269846).

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.
---
 .../TestEmptyFuncThreadStepOut.py             | 19 ++++++++++++++-----
 .../thread/finish-from-empty-func/main.c      |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

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;
 }

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

Reply via email to