Skip to content

Commit 2af45d3

Browse files
[lldb][NFC] Reduce scope of Swift customizations - pt 2
This commit builds on the previous one, this time reducing the scope of customizations checking whether the selected thread stopped at a REPL breakpoint.
1 parent 0b5e136 commit 2af45d3

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
@@ -820,6 +820,31 @@ static bool AnyDebuggerCausedStop(ThreadList &thread_list) {
820820
return false;
821821
}
822822

823+
/// Returns true if curr_thread is not null and it is stopped at a REPL
824+
/// breakpoint.
825+
static bool IsREPLBreakpoint(Thread *curr_thread) {
826+
if (!curr_thread)
827+
return false;
828+
829+
Process &process = *curr_thread->GetProcess();
830+
831+
if (StopInfoSP stop_info_sp = curr_thread->GetStopInfo())
832+
if (BreakpointSiteSP bp_site_sp =
833+
process.GetBreakpointSiteList().FindByID(stop_info_sp->GetValue()))
834+
return BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
835+
836+
// Only check the breakpoint site for the current PC if the stop reason didn't
837+
// have a valid breakpoint site.
838+
if (StackFrameSP frame_sp = curr_thread->GetStackFrameAtIndex(0)) {
839+
if (BreakpointSiteSP bp_site_sp =
840+
process.GetBreakpointSiteList().FindByAddress(
841+
frame_sp->GetStackID().GetPC()))
842+
return BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
843+
}
844+
845+
return false;
846+
}
847+
823848
bool Process::HandleProcessStateChangedEvent(
824849
const EventSP &event_sp, Stream *stream,
825850
SelectMostRelevant select_most_relevant,
@@ -906,7 +931,6 @@ bool Process::HandleProcessStateChangedEvent(
906931
}
907932
} else {
908933
bool check_for_repl_breakpoint = false;
909-
bool is_repl_breakpoint = false;
910934
ThreadSP curr_thread;
911935
StopInfoSP curr_thread_stop_info_sp;
912936
// Lock the thread list so it doesn't change on us, this is the scope for
@@ -1012,38 +1036,8 @@ bool Process::HandleProcessStateChangedEvent(
10121036
: AnyDebuggerCausedStop(thread_list);
10131037
}
10141038

1015-
BreakpointSiteSP bp_site_sp;
1016-
if (repl_is_enabled && check_for_repl_breakpoint) {
1017-
// Make sure this isn't the internal "REPL" breakpoint
1018-
if (curr_thread) {
1019-
StopInfoSP stop_info_sp = curr_thread->GetStopInfo();
1020-
if (stop_info_sp) {
1021-
bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(
1022-
stop_info_sp->GetValue());
1023-
if (bp_site_sp) {
1024-
is_repl_breakpoint =
1025-
BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
1026-
}
1027-
}
1028-
1029-
// Only check the breakpoint site for the current PC if the stop
1030-
// reason didn't have
1031-
// a valid breakpoint site
1032-
if (!bp_site_sp) {
1033-
// We might have stopped with a eStopReasonPlanComplete, see the PC
1034-
// is at
1035-
1036-
lldb::StackFrameSP frame_sp = curr_thread->GetStackFrameAtIndex(0);
1037-
if (frame_sp) {
1038-
bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(
1039-
frame_sp->GetStackID().GetPC());
1040-
if (bp_site_sp)
1041-
is_repl_breakpoint =
1042-
BreakpointSiteMatchesREPLBreakpoint(bp_site_sp);
1043-
}
1044-
}
1045-
}
1046-
}
1039+
bool is_repl_breakpoint = repl_is_enabled && check_for_repl_breakpoint &&
1040+
IsREPLBreakpoint(curr_thread.get());
10471041

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

0 commit comments

Comments
 (0)