[Lldb-commits] [lldb] [lldb][gdb-remote] Mark thread as stopped in RefreshStateAfterStop (PR #201605)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 4 07:57:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

Currently, the default state of a thread is `eStateUnloaded`. However, `ThreadList::DidStop` only converts threads that were`eStateRunning` to `eStateStopped`. Because of this, new threads stay `eStateUnloaded` forever, and `SBThread::IsStopped()` returns false.

On Windows, `TargetThreadWindows::RefreshStateAfterStop` calls `SetState(eStateStopped)`. When using `LLDB_USE_LLDB_SERVER=1`, lldb uses the gdb-remote code path, which does not have that fix, causing `TestThreadStates::test_state_after_breakpoint` and `TestBreakAfterJoin` to fail.

This patch ports the fix to `ThreadGDBRemote`. When running with `LLDB_USE_LLDB_SERVER=1`, it fixes:
- `TestThreadStates::test_state_after_breakpoint`
- `TestBreakAfterJoin`

This could help fix llvm.org/pr15824 on POSIX.

rdar://178727939

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


1 Files Affected:

- (modified) lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (+3) 


``````````diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index c0171734343a6..86c9843eeedd8 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -271,6 +271,9 @@ void ThreadGDBRemote::WillResume(StateType resume_state) {
 }
 
 void ThreadGDBRemote::RefreshStateAfterStop() {
+  // Mark this thread as stopped. ThreadList::DidStop only transitions
+  // threads from a running state to stopped.
+  SetState(eStateStopped);
   // Invalidate all registers in our register context. We don't set "force" to
   // true because the stop reply packet might have had some register values
   // that were expedited and these will already be copied into the register

``````````

</details>


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


More information about the lldb-commits mailing list