@@ -782,6 +782,44 @@ BreakpointSiteMatchesREPLBreakpoint(const BreakpointSiteSP &bp_site_sp) {
782
782
return false ;
783
783
}
784
784
785
+ // / Returns true if reason is Trace/Breakpoint/Watchpoint/PlanComplete.
786
+ static bool IsDebuggerCausedStop (StopReason reason) {
787
+ switch (reason) {
788
+ case eStopReasonInvalid:
789
+ case eStopReasonNone:
790
+ case eStopReasonSignal:
791
+ case eStopReasonException:
792
+ case eStopReasonExec:
793
+ case eStopReasonFork:
794
+ case eStopReasonVFork:
795
+ case eStopReasonVForkDone:
796
+ case eStopReasonThreadExiting:
797
+ case eStopReasonInstrumentation:
798
+ case eStopReasonProcessorTrace:
799
+ return false ;
800
+
801
+ case eStopReasonTrace:
802
+ case eStopReasonBreakpoint:
803
+ case eStopReasonWatchpoint:
804
+ case eStopReasonPlanComplete:
805
+ return true ;
806
+ }
807
+ return false ;
808
+ }
809
+
810
+ // / Returns true if any thread in thread_list has a stop reason of
811
+ // / Trace/Breakpoint/Watchpoint/PlanComplete.
812
+ static bool AnyDebuggerCausedStop (ThreadList &thread_list) {
813
+ for (const auto &thread_sp : thread_list.Threads ()) {
814
+ if (!thread_sp)
815
+ continue ;
816
+ StopReason stop_reason = thread_sp->GetStopReason ();
817
+ if (IsDebuggerCausedStop (stop_reason))
818
+ return true ;
819
+ }
820
+ return false ;
821
+ }
822
+
785
823
bool Process::HandleProcessStateChangedEvent (
786
824
const EventSP &event_sp, Stream *stream,
787
825
SelectMostRelevant select_most_relevant,
@@ -933,8 +971,6 @@ bool Process::HandleProcessStateChangedEvent(
933
971
case eStopReasonTrace:
934
972
case eStopReasonBreakpoint:
935
973
case eStopReasonWatchpoint:
936
- check_for_repl_breakpoint = repl_is_enabled;
937
- LLVM_FALLTHROUGH;
938
974
case eStopReasonException:
939
975
case eStopReasonExec:
940
976
case eStopReasonFork:
@@ -947,7 +983,6 @@ bool Process::HandleProcessStateChangedEvent(
947
983
other_thread = thread;
948
984
break ;
949
985
case eStopReasonPlanComplete:
950
- check_for_repl_breakpoint = repl_is_enabled;
951
986
if (!plan_thread)
952
987
plan_thread = thread;
953
988
break ;
@@ -970,26 +1005,15 @@ bool Process::HandleProcessStateChangedEvent(
970
1005
if (thread)
971
1006
thread_list.SetSelectedThreadByID (thread->GetID ());
972
1007
}
973
- } else {
974
- switch (curr_thread_stop_reason) {
975
- case eStopReasonBreakpoint:
976
- case eStopReasonWatchpoint:
977
- check_for_repl_breakpoint = repl_is_enabled;
978
- break ;
979
- case eStopReasonPlanComplete:
980
- // We might have hit a breakpoint during our REPL evaluation and be
981
- // stopped
982
- // at the REPL breakpoint
983
- check_for_repl_breakpoint = repl_is_enabled;
984
- break ;
985
- default :
986
- break ;
987
- }
988
1008
}
1009
+
1010
+ check_for_repl_breakpoint =
1011
+ prefer_curr_thread ? IsDebuggerCausedStop (curr_thread_stop_reason)
1012
+ : AnyDebuggerCausedStop (thread_list);
989
1013
}
990
1014
991
1015
BreakpointSiteSP bp_site_sp;
992
- if (check_for_repl_breakpoint) {
1016
+ if (repl_is_enabled && check_for_repl_breakpoint) {
993
1017
// Make sure this isn't the internal "REPL" breakpoint
994
1018
if (curr_thread) {
995
1019
StopInfoSP stop_info_sp = curr_thread->GetStopInfo ();
0 commit comments