This is an archive of the discontinued LLVM Phabricator instance.

Remember to check whether the current thread is stopped for a no-stop signal
ClosedPublic

Authored by jingham on Jul 23 2021, 2:05 PM.

Details

Summary

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.

Diff Detail

Event Timeline

jingham requested review of this revision.Jul 23 2021, 2:05 PM
jingham created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2021, 2:05 PM
shafik added a subscriber: shafik.Jul 26 2021, 4:02 PM
shafik added inline comments.
lldb/source/Target/Process.cpp
780–781

If we are setting prefer_curr_thread here, which I think is good, then I don't think we need to the prefer_curr_thread = false; lines in the switch. This will simplfiy the if/else below since we only care about the true case then.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 27 2021, 1:38 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.