https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/167981

>From cc6e5f20631c5f69c70729a66a727a903daefb5c Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Thu, 13 Nov 2025 15:55:19 -0800
Subject: [PATCH 1/2] [lldb-dap] Address a unit test race condition during
 initialization.

During the initialization sequence in our tests the first 'threads' response 
sould only be kept if the process is actually stopped, otherwise we will have 
stale data.

In VSCode, during the debug session startup sequence immediately after 
'configurationDone' a 'threads' request is made. This initial request is to 
retrieve the main threads name and id so the UI can be populated. However, in 
our tests we do not want to cache this value unless the process is actually 
stopped. We do need to make this initial request because lldb-dap is caching 
the initial thread list during configurationDone before the process is resumed. 
We need to make this call to ensure the cached initial threads are purged.

I noticed this in a CI job for another review 
(https://github.com/llvm/llvm-project/actions/runs/19348261989/job/55353961798) 
where the tests incorrectly failed to fetch the threads prior to validating the 
thread names.
---
 .../lldbsuite/test/tools/lldb-dap/dap_server.py   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index ac550962cfb85..98a06715ae6a4 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -191,6 +191,11 @@ class NotSupportedError(KeyError):
 
 
 class DebugCommunication(object):
+    @property
+    def is_stopped(self) -> bool:
+        """Returns True if the debuggee is stopped, otherwise False."""
+        return len(self.thread_stop_reasons) > 0 or self.exit_status is not 
None
+
     def __init__(
         self,
         recv: BinaryIO,
@@ -860,7 +865,17 @@ def request_configurationDone(self):
         response = self._send_recv(command_dict)
         if response:
             self.configuration_done_sent = True
+            stopped_on_entry = self.is_stopped
             self.request_threads()
+            if not stopped_on_entry:
+                # Drop the initial cached threads if we did not stop-on-entry.
+                # In VSCode, immediately following 'configurationDone', a 
+                # 'threads' request is made to get the initial set of threads, 
+                # specifically the main threads id and name.
+                # We issue the threads request to mimic this pattern but in our
+                # tests we don't want to cache the result unless the process is
+                # actually stopped.
+                self.threads = None
         return response
 
     def _process_stopped(self):

>From 481c54ebdc56e06b3e290c81ca6a7f1341635923 Mon Sep 17 00:00:00 2001
From: John Harrison <[email protected]>
Date: Thu, 13 Nov 2025 16:04:25 -0800
Subject: [PATCH 2/2] Applying formatting.

---
 .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 98a06715ae6a4..b207a7a3fa43c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -869,8 +869,8 @@ def request_configurationDone(self):
             self.request_threads()
             if not stopped_on_entry:
                 # Drop the initial cached threads if we did not stop-on-entry.
-                # In VSCode, immediately following 'configurationDone', a 
-                # 'threads' request is made to get the initial set of threads, 
+                # In VSCode, immediately following 'configurationDone', a
+                # 'threads' request is made to get the initial set of threads,
                 # specifically the main threads id and name.
                 # We issue the threads request to mimic this pattern but in our
                 # tests we don't want to cache the result unless the process is

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

Reply via email to