[Lldb-commits] [PATCH] D106712: Remember to check whether the current thread is stopped for a no-stop signal
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 23 14:05:13 PDT 2021
jingham created this revision.
jingham added reviewers: clayborg, JDevlieghere.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
When calculating the "currently selected thread" in Process::HandleStateChangedEvent, we check whether a thread stopped for eStopReasonSignal is stopped for a signal that's currently set to "no-stop". If it is, then we don't set that thread as the currently selected thread.
But that only happens in the part of the algorithm that's handling the case where the previously selected thread has no stop reason. Since we want to keep on a thread as long as it is doing something interesting, we always prefer the current thread. That's almost right, but we forgot to check whether the previously selected thread stopped with an eStopReasonSignal for a "no-stop" signal. If it did, then we shouldn't select it.
This patch adds that check. I can't figure out a good way to test this. This is the sort of thing that Ismail's scripted process plugin will make easy once it is a real boy. But figuring out how to do this in a real process is not trivial.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106712
Files:
lldb/source/Target/Process.cpp
Index: lldb/source/Target/Process.cpp
===================================================================
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -777,13 +777,34 @@
ThreadSP curr_thread(thread_list.GetSelectedThread());
ThreadSP thread;
StopReason curr_thread_stop_reason = eStopReasonInvalid;
- if (curr_thread) {
+ bool prefer_curr_thread = false;
+ if (curr_thread && curr_thread->IsValid()) {
curr_thread_stop_reason = curr_thread->GetStopReason();
+ switch (curr_thread_stop_reason) {
+ case eStopReasonNone:
+ case eStopReasonInvalid:
+ prefer_curr_thread = false;
+ break;
+ case eStopReasonSignal:
+ {
+ // We need to do the same computation we do for other threads
+ // below in case the current thread happens to be the one that
+ // stopped for the no-stop signal.
+ uint64_t signo = curr_thread->GetStopInfo()->GetValue();
+ if (process_sp->GetUnixSignals()->GetShouldStop(signo))
+ prefer_curr_thread = true;
+ else
+ prefer_curr_thread = false;
+ }
+ break;
+ default:
+ prefer_curr_thread = true;
+ break;
+ }
curr_thread_stop_info_sp = curr_thread->GetStopInfo();
}
- if (!curr_thread || !curr_thread->IsValid() ||
- curr_thread_stop_reason == eStopReasonInvalid ||
- curr_thread_stop_reason == eStopReasonNone) {
+
+ if (!prefer_curr_thread) {
// Prefer a thread that has just completed its plan over another
// thread as current thread.
ThreadSP plan_thread;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106712.361342.patch
Type: text/x-patch
Size: 1784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210723/65a5eeaf/attachment.bin>
More information about the lldb-commits
mailing list