@@ -940,77 +940,29 @@ bool Process::HandleProcessStateChangedEvent(
940940 std::lock_guard<std::recursive_mutex> guard (thread_list.GetMutex ());
941941
942942 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 ())
965945 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 ();
967948
968949 if (!prefer_curr_thread) {
969950 // Prefer a thread that has just completed its plan over another
970951 // thread as current thread.
971952 ThreadSP plan_thread;
972953 ThreadSP other_thread;
973954
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) {
1010961 if (!plan_thread)
1011962 plan_thread = thread;
1012- break ;
1013963 }
964+ else if (!other_thread)
965+ other_thread = thread;
1014966 }
1015967 if (plan_thread) {
1016968 thread_list.SetSelectedThreadByID (plan_thread->GetID ());
@@ -1019,6 +971,7 @@ bool Process::HandleProcessStateChangedEvent(
1019971 thread_list.SetSelectedThreadByID (other_thread->GetID ());
1020972 curr_thread = other_thread;
1021973 } else {
974+ ThreadSP thread;
1022975 if (curr_thread && curr_thread->IsValid ())
1023976 thread = curr_thread;
1024977 else {
@@ -1031,6 +984,9 @@ bool Process::HandleProcessStateChangedEvent(
1031984 }
1032985 }
1033986
987+ StopReason curr_thread_stop_reason =
988+ curr_thread_stop_info_sp ? curr_thread_stop_info_sp->GetStopReason ()
989+ : eStopReasonInvalid;
1034990 check_for_repl_breakpoint =
1035991 prefer_curr_thread ? IsDebuggerCausedStop (curr_thread_stop_reason)
1036992 : AnyDebuggerCausedStop (thread_list);
@@ -5940,7 +5896,7 @@ size_t Process::GetThreadStatus(Stream &strm,
59405896 if (thread_sp) {
59415897 if (only_threads_with_stop_reason) {
59425898 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 ())
59445900 continue ;
59455901 }
59465902 thread_sp->GetStatus (strm, start_frame, num_frames,
0 commit comments