[Lldb-commits] [lldb] [lldb] Have TestRunLocker run both styles of launch (PR #200978)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 1 17:45:59 PDT 2026


https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/200978

While debugging flakey behavior with TestRunLocker, I noticed that is intends to run its test once with a stop at the entry function (and then Continues) and once where we launch to the main() loop.  But we were never exercising the stop-at-entry codepath.

This doesn't fix the flakey behavior, although that only happens with the launch-directly-into-main() codepath; I don't get failures when I stop at the entry point and then continue.

>From db19f0cc283d17f45a5c5cfe25d7b858304e80a2 Mon Sep 17 00:00:00 2001
From: Jason Molenda <jmolenda at apple.com>
Date: Mon, 1 Jun 2026 17:39:39 -0700
Subject: [PATCH] [lldb] Have TestRunLocker run both styles of launch

While debugging flakey behavior with TestRunLocker,
I noticed that is intends to run its test once with
a stop at the entry function (and then Continues)
and once where we launch to the main() loop.  But
we were never exercising the stop-at-entry codepath.

This doesn't fix the flakey behavior, although that
only happens with the launch-directly-into-main()
codepath; I don't get failures when I stop at
the entry point and then continue.
---
 .../python_api/run_locker/TestRunLocker.py    | 26 ++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/lldb/test/API/python_api/run_locker/TestRunLocker.py b/lldb/test/API/python_api/run_locker/TestRunLocker.py
index f84d038b5ed34..16b7623367a05 100644
--- a/lldb/test/API/python_api/run_locker/TestRunLocker.py
+++ b/lldb/test/API/python_api/run_locker/TestRunLocker.py
@@ -28,7 +28,7 @@ def test_run_locker(self):
     def test_run_locker_stop_at_entry(self):
         """Test that the run locker is set correctly when we launch"""
         self.build()
-        self.runlocker_test(False)
+        self.runlocker_test(True)
 
     def setUp(self):
         # Call super's setUp().
@@ -43,8 +43,8 @@ def runlocker_test(self, stop_at_entry):
 
         launch_info = target.GetLaunchInfo()
         if stop_at_entry:
-            flags = launch_info.GetFlags()
-            launch_info.SetFlags(flags | lldb.eLaunchFlagStopAtEntry)
+            flags = launch_info.GetLaunchFlags()
+            launch_info.SetLaunchFlags(flags | lldb.eLaunchFlagStopAtEntry)
 
         error = lldb.SBError()
         # We are trying to do things when the process is running, so
@@ -69,16 +69,24 @@ def runlocker_test(self, stop_at_entry):
             )
             state_type = lldb.SBProcess.GetStateFromEvent(event)
 
-        self.assertState(state_type, lldb.eStateRunning, "Didn't get a running event")
+        # A stop_at_entry launch may have already stopped, it may
+        # not be eStateRunning.
+        if stop_at_entry and state_type != lldb.eStateStopped:
+            self.assertState(
+                state_type, lldb.eStateRunning, "Didn't get a running event"
+            )
 
         # We aren't checking the entry state, but just making sure
         # the running state is set properly if we continue in this state.
 
         if stop_at_entry:
-            event_result = listener.WaitForEvent(10, event)
-            self.assertTrue(event_result, "Timed out waiting for stop at entry stop")
-            state_type = lldb.SBProcess.GetStateFromEvent(event)
-            self.assertState(state_type, eStateStopped, "Stop at entry stopped")
+            if state_type != lldb.eStateStopped:
+                event_result = listener.WaitForEvent(10, event)
+                self.assertTrue(
+                    event_result, "Timed out waiting for stop at entry stop"
+                )
+                state_type = lldb.SBProcess.GetStateFromEvent(event)
+                self.assertState(state_type, eStateStopped, "Stop at entry stopped")
             process.Continue()
 
         # Okay, now the process is running, make sure we can't do things
@@ -90,7 +98,7 @@ def runlocker_test(self, stop_at_entry):
         self.assertIn(
             "can't evaluate expressions when the process is running",
             repr(val),
-            "repr works"
+            "repr works",
         )
         error = val.GetError()
         self.assertTrue(error.Fail(), "Failed to run expression")



More information about the lldb-commits mailing list