[Lldb-commits] [lldb] [lldb-dap] Adjusting multi-stopped event order. (PR #181001)
Sergei Druzhkov via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 11 11:57:05 PST 2026
================
@@ -266,30 +268,38 @@ llvm::Error SendThreadStoppedEvent(DAP &dap, bool on_entry) {
llvm::DenseSet<lldb::tid_t> old_thread_ids;
old_thread_ids.swap(dap.thread_ids);
- lldb::tid_t focused_tid = LLDB_INVALID_THREAD_ID;
+ lldb::SBThread focused_thread;
+ std::vector<lldb::SBThread> stopped_threads;
for (auto thread : process) {
// Collect all known thread ids for sending thread events.
dap.thread_ids.insert(thread.GetThreadID());
if (!ThreadHasStopReason(thread))
continue;
- // When we stop, report allThreadsStopped for the *first* stopped thread to
- // ensure the list of stopped threads is up to date.
- bool first_stop = focused_tid == LLDB_INVALID_THREAD_ID;
- SendStoppedEvent(dap, thread, on_entry, /*all_threads_stopped=*/first_stop,
- /*preserve_focus=*/!first_stop);
-
- // Default focus to the first stopped thread.
- if (focused_tid == LLDB_INVALID_THREAD_ID)
- focused_tid = thread.GetThreadID();
+ // Focus on the first stopped thread
+ if (!focused_thread.IsValid())
+ focused_thread = thread;
+ else
+ stopped_threads.push_back(thread);
}
- if (focused_tid == LLDB_INVALID_THREAD_ID)
+ // If no stopped threads were detected, fallback to the selected thread.
+ if (!focused_thread)
+ focused_thread = process.GetSelectedThread();
+
+ if (!focused_thread)
return make_error<DAPError>("no stopped threads");
+ // Send stopped events for each thread thats stopped.
+ for (auto thread : stopped_threads)
+ SendStoppedEvent(dap, thread, on_entry, false, true);
----------------
DrSergei wrote:
nit: `SendStoppedEvent(dap, thread, on_entry, /*all_threads_stopped=*/false, /*preserve_focus=*/true)` and below
https://github.com/llvm/llvm-project/pull/181001
More information about the lldb-commits
mailing list