[Lldb-commits] [lldb] 78d4eac - [lldb][Windows] Suspend new threads when stopped (#201558)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 4 07:02:15 PDT 2026
Author: Charles Zablit
Date: 2026-06-04T15:02:10+01:00
New Revision: 78d4eac701720c252ed1c835d1f635a223bf70ce
URL: https://github.com/llvm/llvm-project/commit/78d4eac701720c252ed1c835d1f635a223bf70ce
DIFF: https://github.com/llvm/llvm-project/commit/78d4eac701720c252ed1c835d1f635a223bf70ce.diff
LOG: [lldb][Windows] Suspend new threads when stopped (#201558)
`OnCreateThread` runs from the `DebuggerThread` loop after a
`CREATE_THREAD_DEBUG_EVENT`. Each iteration of that loop ends with a
`ContinueDebugEvent`, which on Windows resumes every thread in the
debuggee that *isn't* individually suspended with `SuspendThread`.
If a thread is created while the debuggee is stopped, all the existing
threads are suspended expect the new one. After the next
ContinueDebugEvent it just runs, while lldb's StateType still reads
eStateStopped.
This patch suspends the new thread when the debuggee is stopped.
This fixes `TestTwoHitsOneActual.py` and `TestBreakOnLambdaCapture.py`
when running the test suite with `LLDB_USE_LLDB_SERVER=1`.
rdar://178718627
Added:
Modified:
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 73989f18173c9..60cd4106d9db4 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -633,6 +633,18 @@ void NativeProcessWindows::OnCreateThread(const HostThread &new_thread) {
wp.m_hardware);
}
+ if (StateType state = GetState();
+ state == eStateStopped || state == eStateCrashed) {
+ if (Status error = thread->DoStop(); error.Fail()) {
+ Log *log = GetLog(WindowsLog::Thread);
+ LLDB_LOG(log, "failed to suspend newly-created thread {0}: {1}",
+ thread->GetID(), error);
+ }
+ ThreadStopInfo stop_info;
+ stop_info.reason = lldb::eStopReasonNone;
+ thread->SetStopReason(stop_info, "");
+ }
+
m_threads.push_back(std::move(thread));
}
More information about the lldb-commits
mailing list