[Lldb-commits] [lldb] [lldb][Windows] Register the shadow listener in PlatformWindows (PR #227277)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 29 04:19:46 PDT 2026


https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/227277

`PlatformWindows::DebugProcess` and `PlatformWindows::Attach` create the Process and hijack its events, but never call `Process::SetShadowListener` with the listener from the launch or attach info. `PlatformPOSIX`, `PlatformRemoteGDBServer` and `Target::Launch`'s all do.

On Windows a shadow listener set with `SBLaunchInfo::SetShadowListener` therefore never gets an event, which is why `TestEvents.test_shadow_listener` failed on every run (`"Shadow listener got event too"`) on both the lldb-server and the in-process backend.
    
Call `SetShadowListener` in both, and in Attach only touch `process_sp` once it is known to be non-null (HijackProcessEvents was called before the null check).

I was able to reproduce the failure at desk on a machine that's under load. The issue no longer reproduces after this patch.

Fixes https://github.com/llvm/llvm-project/issues/37721.

>From d40ff0830df2d0eb4d1aa186e2cd322f012ef528 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Tue, 29 Sep 2026 11:19:45 +0100
Subject: [PATCH] [lldb][Windows] Register the shadow listener in
 PlatformWindows

---
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 0e1938b080bba..d977d60b9a766 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -632,6 +632,7 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
     return nullptr;
 
   process_sp->HijackProcessEvents(launch_info.GetHijackListener());
+  process_sp->SetShadowListener(launch_info.GetShadowListener());
 
   // We need to launch and attach to the process.
   launch_info.GetFlags().Set(eLaunchFlagDebug);
@@ -678,9 +679,11 @@ lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info,
       target->CreateProcess(attach_info.GetListenerForProcess(debugger),
                             attach_info.GetProcessPluginName(), nullptr, false);
 
-  process_sp->HijackProcessEvents(attach_info.GetHijackListener());
-  if (process_sp)
+  if (process_sp) {
+    process_sp->HijackProcessEvents(attach_info.GetHijackListener());
+    process_sp->SetShadowListener(attach_info.GetShadowListener());
     error = process_sp->Attach(attach_info);
+  }
 
   return process_sp;
 }



More information about the lldb-commits mailing list