[Lldb-commits] [lldb] [lldb][Windows] handle exception first to keep track of the stop reason (PR #206469)

via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 29 05:22:21 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

The launch thread blocks on that event in `WaitForDebuggerConnection()` and, once released, returns, immediately starts serving GDB-remote packets. If the state were still `eStateInvalid` at that point, a `continue` would race past the state transition and be rejected by `CanResume()`.

This fixes flakyness in the following tests:

```
lldb-api :: commands/process/reverse-continue/TestReverseContinue.py
lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py
lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py
lldb-api :: tools/lldb-server/TestGdbRemoteAttach.py
lldb-api :: tools/lldb-server/TestGdbRemoteExitCode.py
lldb-api :: tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
lldb-api :: tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
lldb-api :: tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
lldb-api :: tools/lldb-server/TestLldbGdbServer.py
lldb-api :: tools/lldb-server/TestNonStop.py
lldb-api :: tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
```

---
Full diff: https://github.com/llvm/llvm-project/pull/206469.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp (+13-6) 


``````````diff
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 889a2e743c07f..ce4fa3d1f0152 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -653,19 +653,26 @@ NativeProcessWindows::OnDebugException(bool first_chance,
                                        const ExceptionRecord &record) {
   llvm::sys::ScopedLock lock(m_mutex);
 
-  // Let the debugger establish the internal status.
-  ProcessDebugger::OnDebugException(first_chance, record);
-
+  // Handle the exception first to keep track of the stop reason.
+  ExceptionResult result;
   switch (record.GetExceptionValue()) {
   case DWORD(STATUS_SINGLE_STEP):
   case STATUS_WX86_SINGLE_STEP:
-    return HandleSingleStepException(record);
+    result = HandleSingleStepException(record);
+    break;
   case DWORD(STATUS_BREAKPOINT):
   case STATUS_WX86_BREAKPOINT:
-    return HandleBreakpointException(record);
+    result = HandleBreakpointException(record);
+    break;
   default:
-    return HandleGenericException(first_chance, record);
+    result = HandleGenericException(first_chance, record);
+    break;
   }
+
+  // Let the debugger establish the internal status.
+  ProcessDebugger::OnDebugException(first_chance, record);
+
+  return result;
 }
 
 void NativeProcessWindows::OnCreateThread(const HostThread &new_thread) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/206469


More information about the lldb-commits mailing list