[Lldb-commits] [lldb] [lldb-dap] Avoid double 'new' events for dyld on Darwin (PR #140810)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue May 20 14:55:10 PDT 2025
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/140810
I got a bug report where a pedantic DAP client complains about getting two "new" module events for the same UUID. This is caused by the dyld transition from the on-disk dyld to the shared cache dyld, which share the same UUID. The transition is not generating an unloaded event (because we're not really unloading dyld) but we do get a loaded event (because the load address changed). This PR fixes the issue by relying on the modules set as the source of truth instead of relying on the event type.
>From e9314a68b7e95aef26a1e75460f2e10b0c4b8ec3 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 20 May 2025 14:05:31 -0700
Subject: [PATCH] [lldb-dap] Avoid double 'new' events for dyld on Darwin
I got a bug report where a pedantic DAP client complains about getting
two "new" module events for the same UUID. This is caused by the dyld
transition from the on-disk dyld to the shared cache dyld, which share
the same UUID. The transition is not generating an unloaded
event (because we're not really unloading dyld) but we do
get a loaded event (because the load address changed). This PR fixes the
issue by relying on the modules set as the source of truth instead of
relying on the event type.
---
lldb/tools/lldb-dap/DAP.cpp | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 3419b2c3a841b..f6241b7d98456 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1292,15 +1292,7 @@ void DAP::EventThread() {
llvm::StringRef reason;
bool id_only = false;
- if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
- modules.insert(module_id);
- reason = "new";
- } else {
- // If this is a module we've never told the client about, don't
- // send an event.
- if (!modules.contains(module_id))
- continue;
-
+ if (modules.contains(module_id)) {
if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded) {
modules.erase(module_id);
reason = "removed";
@@ -1308,6 +1300,9 @@ void DAP::EventThread() {
} else {
reason = "changed";
}
+ } else {
+ modules.insert(module_id);
+ reason = "new";
}
llvm::json::Object body;
More information about the lldb-commits
mailing list