Skip to content

Commit 1994014

Browse files
committed
[lldb-dap] Avoid double 'new' events for dyld on Darwin (llvm#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. Back-ported from commit 7b51339
1 parent 455ce1c commit 1994014

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,22 +540,17 @@ void EventThreadFunction(DAP &dap) {
540540

541541
llvm::StringRef reason;
542542
bool id_only = false;
543-
if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
544-
dap.modules.insert(module_id);
545-
reason = "new";
546-
} else {
547-
// If this is a module we've never told the client about, don't
548-
// send an event.
549-
if (!dap.modules.contains(module_id))
550-
continue;
551-
543+
if (dap.modules.contains(module_id)) {
552544
if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded) {
553545
dap.modules.erase(module_id);
554546
reason = "removed";
555547
id_only = true;
556548
} else {
557549
reason = "changed";
558550
}
551+
} else {
552+
dap.modules.insert(module_id);
553+
reason = "new";
559554
}
560555

561556
llvm::json::Object body;

0 commit comments

Comments
 (0)