================
@@ -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
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits