[Lldb-commits] [lldb] [lldb-dap][windows] fix dap tests (PR #201836)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 5 07:39:28 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/201836

>From c7f4a6f85ab9a1426f7f58c19fa63aee52d56eb2 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 5 Jun 2026 14:20:48 +0100
Subject: [PATCH] [lldb-dap][windows] replay module load events

---
 .../attach-commands/TestDAP_attachCommands.py |  1 -
 .../TestDAP_launch_extra_launch_commands.py   |  3 +--
 lldb/tools/lldb-dap/DAP.cpp                   | 22 +++++++++++++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py b/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
index 525783b3785fb..f24a32edbaa7b 100644
--- a/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
+++ b/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
@@ -12,7 +12,6 @@
 class TestDAP_attachCommands(lldbdap_testcase.DAPTestCaseBase):
     SHARED_BUILD_TESTCASE = False
 
-    @skipIfWindows  # Wait for module events fails.
     @skipIfNetBSD  # Hangs on NetBSD as well
     def test_commands(self):
         """
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
index cc3c4764a5fd7..ad48af6364aba 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
@@ -2,7 +2,7 @@
 Test lldb-dap launch request.
 """
 
-from lldbsuite.test.decorators import skipIf, skipIfWindows
+from lldbsuite.test.decorators import skipIf
 from lldbsuite.test.lldbtest import line_number
 import lldbdap_testcase
 
@@ -12,7 +12,6 @@ class TestDAP_launch_extra_launch_commands(lldbdap_testcase.DAPTestCaseBase):
     Tests the "launchCommands" with extra launching settings
     """
 
-    @skipIfWindows  # Wait for module events fails.
     # Flakey on 32-bit Arm Linux.
     @skipIf(oslist=["linux"], archs=["arm$"])
     def test(self):
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index cb34c7b2fd1e8..0a8cb134c42e7 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -802,6 +802,28 @@ void DAP::SetTarget(const lldb::SBTarget target) {
             lldb::SBTarget::eBroadcastBitNewTargetCreated);
     listener.StartListeningForEvents(this->broadcaster,
                                      eBroadcastBitStopEventThread);
+
+    // Replay "module"/eReasonNew events for any modules already loaded into
+    // the target.
+    lldb::SBMutex api_mutex = this->target.GetAPIMutex();
+    const std::scoped_lock<lldb::SBMutex, std::mutex> guard(
+        api_mutex, this->modules_mutex);
+    const uint32_t num_modules = this->target.GetNumModules();
+    for (uint32_t i = 0; i < num_modules; ++i) {
+      lldb::SBModule module = this->target.GetModuleAtIndex(i);
+      std::optional<protocol::Module> p_module =
+          CreateModule(this->target, module);
+      if (!p_module)
+        continue;
+      llvm::StringRef module_id = p_module->id;
+      if (this->modules.contains(module_id))
+        continue;
+      this->modules.insert(module_id);
+      Send(protocol::Event{
+          "module",
+          protocol::ModuleEventBody{std::move(p_module).value(),
+                                    protocol::ModuleEventBody::eReasonNew}});
+    }
   }
 }
 



More information about the lldb-commits mailing list