-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo #134160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felipepiovezan
merged 3 commits into
llvm:main
from
felipepiovezan:felipe/shouldshow_simplification
Apr 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -808,85 +808,35 @@ bool Process::HandleProcessStateChangedEvent( | |||||||||||
| std::lock_guard<std::recursive_mutex> guard(thread_list.GetMutex()); | ||||||||||||
|
|
||||||||||||
| ThreadSP curr_thread(thread_list.GetSelectedThread()); | ||||||||||||
| ThreadSP thread; | ||||||||||||
| StopReason curr_thread_stop_reason = eStopReasonInvalid; | ||||||||||||
| 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: | ||||||||||||
| // Don't prefer the current thread if it didn't stop for a reason. | ||||||||||||
| 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; | ||||||||||||
| } break; | ||||||||||||
| default: | ||||||||||||
| prefer_curr_thread = true; | ||||||||||||
| break; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (curr_thread && curr_thread->IsValid()) | ||||||||||||
| curr_thread_stop_info_sp = curr_thread->GetStopInfo(); | ||||||||||||
| } | ||||||||||||
| bool prefer_curr_thread = curr_thread_stop_info_sp && | ||||||||||||
| curr_thread_stop_info_sp->ShouldSelect(); | ||||||||||||
|
|
||||||||||||
| if (!prefer_curr_thread) { | ||||||||||||
| // Prefer a thread that has just completed its plan over another | ||||||||||||
| // thread as current thread. | ||||||||||||
| ThreadSP plan_thread; | ||||||||||||
| ThreadSP other_thread; | ||||||||||||
|
|
||||||||||||
| const size_t num_threads = thread_list.GetSize(); | ||||||||||||
| size_t i; | ||||||||||||
| for (i = 0; i < num_threads; ++i) { | ||||||||||||
| thread = thread_list.GetThreadAtIndex(i); | ||||||||||||
| StopReason thread_stop_reason = thread->GetStopReason(); | ||||||||||||
| switch (thread_stop_reason) { | ||||||||||||
| case eStopReasonInvalid: | ||||||||||||
| case eStopReasonNone: | ||||||||||||
| case eStopReasonHistoryBoundary: | ||||||||||||
| break; | ||||||||||||
|
|
||||||||||||
| case eStopReasonSignal: { | ||||||||||||
| // Don't select a signal thread if we weren't going to stop at | ||||||||||||
| // that signal. We have to have had another reason for stopping | ||||||||||||
| // here, and the user doesn't want to see this thread. | ||||||||||||
| uint64_t signo = thread->GetStopInfo()->GetValue(); | ||||||||||||
| if (process_sp->GetUnixSignals()->GetShouldStop(signo)) { | ||||||||||||
| if (!other_thread) | ||||||||||||
| other_thread = thread; | ||||||||||||
| } | ||||||||||||
| break; | ||||||||||||
| } | ||||||||||||
| case eStopReasonTrace: | ||||||||||||
| case eStopReasonBreakpoint: | ||||||||||||
| case eStopReasonWatchpoint: | ||||||||||||
| case eStopReasonException: | ||||||||||||
| case eStopReasonExec: | ||||||||||||
| case eStopReasonFork: | ||||||||||||
| case eStopReasonVFork: | ||||||||||||
| case eStopReasonVForkDone: | ||||||||||||
| case eStopReasonThreadExiting: | ||||||||||||
| case eStopReasonInstrumentation: | ||||||||||||
| case eStopReasonProcessorTrace: | ||||||||||||
| case eStopReasonInterrupt: | ||||||||||||
| if (!other_thread) | ||||||||||||
| other_thread = thread; | ||||||||||||
| break; | ||||||||||||
| case eStopReasonPlanComplete: | ||||||||||||
| for (ThreadSP thread : thread_list.Threads()) { | ||||||||||||
| StopInfoSP stop_info = thread->GetStopInfo(); | ||||||||||||
| if (!stop_info || !stop_info->ShouldSelect()) | ||||||||||||
| continue; | ||||||||||||
| StopReason thread_stop_reason = stop_info->GetStopReason(); | ||||||||||||
| if (thread_stop_reason == eStopReasonPlanComplete) { | ||||||||||||
| if (!plan_thread) | ||||||||||||
| plan_thread = thread; | ||||||||||||
| break; | ||||||||||||
| } | ||||||||||||
| } else if (!other_thread) | ||||||||||||
| other_thread = thread; | ||||||||||||
|
||||||||||||
| } else if (!other_thread) | |
| other_thread = thread; | |
| } else if (!other_thread) { | |
| other_thread = thread; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1080,12 +1080,7 @@ class StopInfoUnixSignal : public StopInfo { | |||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| bool ShouldStop(Event *event_ptr) override { | ||||||||||||||
| ThreadSP thread_sp(m_thread_wp.lock()); | ||||||||||||||
| if (thread_sp) | ||||||||||||||
| return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| bool ShouldStop(Event *event_ptr) override { return IsShouldStopSignal(); } | ||||||||||||||
|
|
||||||||||||||
| // If should stop returns false, check if we should notify of this event | ||||||||||||||
| bool DoShouldNotify(Event *event_ptr) override { | ||||||||||||||
|
|
@@ -1137,9 +1132,18 @@ class StopInfoUnixSignal : public StopInfo { | |||||||||||||
| return m_description.c_str(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| bool ShouldSelect() const override { return IsShouldStopSignal(); } | ||||||||||||||
|
|
||||||||||||||
| private: | ||||||||||||||
| // In siginfo_t terms, if m_value is si_signo, m_code is si_code. | ||||||||||||||
| std::optional<int> m_code; | ||||||||||||||
|
|
||||||||||||||
| bool IsShouldStopSignal() const { | ||||||||||||||
| ThreadSP thread_sp(m_thread_wp.lock()); | ||||||||||||||
| if (thread_sp) | ||||||||||||||
| return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value); | ||||||||||||||
|
||||||||||||||
| ThreadSP thread_sp(m_thread_wp.lock()); | |
| if (thread_sp) | |
| return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value); | |
| ThreadSP thread_sp(m_thread_wp.lock()); | |
| if (ThreadSP thread_sp = m_thread_wp.lock()) | |
| return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stopping -> viewing the thread with this stop info
This happens not just at stop.