@@ -940,77 +940,29 @@ bool Process::HandleProcessStateChangedEvent(
940
940
std::lock_guard<std::recursive_mutex> guard (thread_list.GetMutex ());
941
941
942
942
curr_thread = thread_list.GetSelectedThread ();
943
- ThreadSP thread;
944
- StopReason curr_thread_stop_reason = eStopReasonInvalid;
945
- bool prefer_curr_thread = false ;
946
- if (curr_thread && curr_thread->IsValid ()) {
947
- curr_thread_stop_reason = curr_thread->GetStopReason ();
948
- switch (curr_thread_stop_reason) {
949
- case eStopReasonNone:
950
- case eStopReasonInvalid:
951
- // Don't prefer the current thread if it didn't stop for a reason.
952
- break ;
953
- case eStopReasonSignal: {
954
- // We need to do the same computation we do for other threads
955
- // below in case the current thread happens to be the one that
956
- // stopped for the no-stop signal.
957
- uint64_t signo = curr_thread->GetStopInfo ()->GetValue ();
958
- if (process_sp->GetUnixSignals ()->GetShouldStop (signo))
959
- prefer_curr_thread = true ;
960
- } break ;
961
- default :
962
- prefer_curr_thread = true ;
963
- break ;
964
- }
943
+
944
+ if (curr_thread && curr_thread->IsValid ())
965
945
curr_thread_stop_info_sp = curr_thread->GetStopInfo ();
966
- }
946
+ bool prefer_curr_thread = curr_thread_stop_info_sp &&
947
+ curr_thread_stop_info_sp->ShouldSelect ();
967
948
968
949
if (!prefer_curr_thread) {
969
950
// Prefer a thread that has just completed its plan over another
970
951
// thread as current thread.
971
952
ThreadSP plan_thread;
972
953
ThreadSP other_thread;
973
954
974
- const size_t num_threads = thread_list.GetSize ();
975
- size_t i;
976
- for (i = 0 ; i < num_threads; ++i) {
977
- thread = thread_list.GetThreadAtIndex (i);
978
- StopReason thread_stop_reason = thread->GetStopReason ();
979
- switch (thread_stop_reason) {
980
- case eStopReasonInvalid:
981
- case eStopReasonNone:
982
- break ;
983
-
984
- case eStopReasonSignal: {
985
- // Don't select a signal thread if we weren't going to stop at
986
- // that signal. We have to have had another reason for stopping
987
- // here, and the user doesn't want to see this thread.
988
- uint64_t signo = thread->GetStopInfo ()->GetValue ();
989
- if (process_sp->GetUnixSignals ()->GetShouldStop (signo)) {
990
- if (!other_thread)
991
- other_thread = thread;
992
- }
993
- break ;
994
- }
995
- case eStopReasonTrace:
996
- case eStopReasonBreakpoint:
997
- case eStopReasonWatchpoint:
998
- case eStopReasonException:
999
- case eStopReasonExec:
1000
- case eStopReasonFork:
1001
- case eStopReasonVFork:
1002
- case eStopReasonVForkDone:
1003
- case eStopReasonThreadExiting:
1004
- case eStopReasonInstrumentation:
1005
- case eStopReasonProcessorTrace:
1006
- if (!other_thread)
1007
- other_thread = thread;
1008
- break ;
1009
- case eStopReasonPlanComplete:
955
+ for (ThreadSP thread : thread_list.Threads ()) {
956
+ StopInfoSP stop_info = thread->GetStopInfo ();
957
+ if (!stop_info || !stop_info->ShouldSelect ())
958
+ continue ;
959
+ StopReason thread_stop_reason = stop_info->GetStopReason ();
960
+ if (thread_stop_reason == eStopReasonPlanComplete) {
1010
961
if (!plan_thread)
1011
962
plan_thread = thread;
1012
- break ;
1013
963
}
964
+ else if (!other_thread)
965
+ other_thread = thread;
1014
966
}
1015
967
if (plan_thread) {
1016
968
thread_list.SetSelectedThreadByID (plan_thread->GetID ());
@@ -1019,6 +971,7 @@ bool Process::HandleProcessStateChangedEvent(
1019
971
thread_list.SetSelectedThreadByID (other_thread->GetID ());
1020
972
curr_thread = other_thread;
1021
973
} else {
974
+ ThreadSP thread;
1022
975
if (curr_thread && curr_thread->IsValid ())
1023
976
thread = curr_thread;
1024
977
else {
@@ -1031,6 +984,9 @@ bool Process::HandleProcessStateChangedEvent(
1031
984
}
1032
985
}
1033
986
987
+ StopReason curr_thread_stop_reason =
988
+ curr_thread_stop_info_sp ? curr_thread_stop_info_sp->GetStopReason ()
989
+ : eStopReasonInvalid;
1034
990
check_for_repl_breakpoint =
1035
991
prefer_curr_thread ? IsDebuggerCausedStop (curr_thread_stop_reason)
1036
992
: AnyDebuggerCausedStop (thread_list);
@@ -5940,7 +5896,7 @@ size_t Process::GetThreadStatus(Stream &strm,
5940
5896
if (thread_sp) {
5941
5897
if (only_threads_with_stop_reason) {
5942
5898
StopInfoSP stop_info_sp = thread_sp->GetStopInfo ();
5943
- if (!stop_info_sp || !stop_info_sp->IsValid ())
5899
+ if (!stop_info_sp || !stop_info_sp->ShouldShow ())
5944
5900
continue ;
5945
5901
}
5946
5902
thread_sp->GetStatus (strm, start_frame, num_frames,
0 commit comments