Skip to content

Commit 5b3c536

Browse files
Merge pull request #10423 from felipepiovezan/felipe/reduce_customizations_p2
[lldb][NFC] Reduce scope of Swift customizations - pt 2
2 parents 53921ac + 30cc82f commit 5b3c536

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

lldb/source/Target/Process.cpp

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,31 @@ static bool AnyDebuggerCausedStop(ThreadList &thread_list) {
799799
return false;
800800
}
801801

802+
/// Returns true if curr_thread is not null and it is stopped at a REPL
803+
/// breakpoint.
804+
static bool IsREPLBreakpoint(Thread *curr_thread) {
805+
if (!curr_thread)
806+
return false;
807+
808+
Process &process = *curr_thread->GetProcess();
809+
810+
if (StopInfoSP stop_info_sp = curr_thread->GetStopInfo())
811+
if (BreakpointSiteSP bp_site_sp =
812+
process.GetBreakpointSiteList().FindByID(stop_info_sp->GetValue()))
813+
return BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
814+
815+
// Only check the breakpoint site for the current PC if the stop reason didn't
816+
// have a valid breakpoint site.
817+
if (StackFrameSP frame_sp = curr_thread->GetStackFrameAtIndex(0)) {
818+
if (BreakpointSiteSP bp_site_sp =
819+
process.GetBreakpointSiteList().FindByAddress(
820+
frame_sp->GetStackID().GetPC()))
821+
return BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
822+
}
823+
824+
return false;
825+
}
826+
802827
bool Process::HandleProcessStateChangedEvent(
803828
const EventSP &event_sp, Stream *stream,
804829
SelectMostRelevant select_most_relevant,
@@ -885,7 +910,6 @@ bool Process::HandleProcessStateChangedEvent(
885910
}
886911
} else {
887912
bool check_for_repl_breakpoint = false;
888-
bool is_repl_breakpoint = false;
889913
ThreadSP curr_thread;
890914
StopInfoSP curr_thread_stop_info_sp;
891915
// Lock the thread list so it doesn't change on us, this is the scope for
@@ -993,38 +1017,8 @@ bool Process::HandleProcessStateChangedEvent(
9931017
: AnyDebuggerCausedStop(thread_list);
9941018
}
9951019

996-
BreakpointSiteSP bp_site_sp;
997-
if (repl_is_enabled && check_for_repl_breakpoint) {
998-
// Make sure this isn't the internal "REPL" breakpoint
999-
if (curr_thread) {
1000-
StopInfoSP stop_info_sp = curr_thread->GetStopInfo();
1001-
if (stop_info_sp) {
1002-
bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(
1003-
stop_info_sp->GetValue());
1004-
if (bp_site_sp) {
1005-
is_repl_breakpoint =
1006-
BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
1007-
}
1008-
}
1009-
1010-
// Only check the breakpoint site for the current PC if the stop
1011-
// reason didn't have
1012-
// a valid breakpoint site
1013-
if (!bp_site_sp) {
1014-
// We might have stopped with a eStopReasonPlanComplete, see the PC
1015-
// is at
1016-
1017-
lldb::StackFrameSP frame_sp = curr_thread->GetStackFrameAtIndex(0);
1018-
if (frame_sp) {
1019-
bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(
1020-
frame_sp->GetStackID().GetPC());
1021-
if (bp_site_sp)
1022-
is_repl_breakpoint =
1023-
BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
1024-
}
1025-
}
1026-
}
1027-
}
1020+
bool is_repl_breakpoint = repl_is_enabled && check_for_repl_breakpoint &&
1021+
IsREPLBreakpoint(curr_thread.get());
10281022

10291023
// Drop the ThreadList mutex by here, since GetThreadStatus below might
10301024
// have to run code, e.g. for Data formatters, and if we hold the

0 commit comments

Comments
 (0)