Skip to content

Commit 8ae58cd

Browse files
Merge pull request #10238 from felipepiovezan/felipe/update_filter_bp_line
[lldb][nfc] Adjust language plugin to changes in FilterForLineBreakpoints
2 parents 8181ec4 + 01b70ba commit 8ae58cd

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

lldb/include/lldb/Target/Language.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,13 @@ class Language : public PluginInterface {
356356

357357
virtual llvm::StringRef GetInstanceVariableName() { return {}; }
358358

359-
/// Returns true if this SymbolContext should be ignored when setting
360-
/// breakpoints by line (number or regex). Helpful for languages that create
361-
/// artificial functions without meaningful user code associated with them
362-
/// (e.g. code that gets expanded in late compilation stages, like by
363-
/// CoroSplitter).
364-
virtual bool IgnoreForLineBreakpoints(const SymbolContext &) const {
365-
return false;
366-
}
359+
/// Given a symbol context list of matches which supposedly represent the
360+
/// same file and line number in a CU, erases those that should be ignored
361+
/// when setting breakpoints by line (number or regex). Helpful for languages
362+
/// that create split a single source-line into many functions (e.g. call
363+
/// sites transformed by CoroSplitter).
364+
virtual void
365+
FilterForLineBreakpoints(llvm::SmallVectorImpl<SymbolContext> &) const {}
367366

368367
/// Returns a boolean indicating whether two symbol contexts are equal for the
369368
/// purposes of frame comparison. If the plugin has no opinion, it should

lldb/source/Breakpoint/BreakpointResolver.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) {
207207
void BreakpointResolver::SetSCMatchesByLine(
208208
SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue,
209209
llvm::StringRef log_ident, uint32_t line, std::optional<uint16_t> column) {
210-
llvm::SmallVector<SymbolContext, 16> all_scs;
211-
212-
for (const auto &sc : sc_list) {
213-
if (Language::GetGlobalLanguageProperties()
214-
.GetEnableFilterForLineBreakpoints())
215-
if (Language *lang = Language::FindPlugin(sc.GetLanguage());
216-
lang && lang->IgnoreForLineBreakpoints(sc))
217-
continue;
218-
all_scs.push_back(sc);
219-
}
210+
llvm::SmallVector<SymbolContext, 16> all_scs(sc_list.begin(), sc_list.end());
211+
212+
// Let the language plugin filter `sc_list`. Because all symbol contexts in
213+
// sc_list are assumed to belong to the same File, Line and CU, the code below
214+
// assumes they have the same language.
215+
if (!sc_list.IsEmpty() && Language::GetGlobalLanguageProperties()
216+
.GetEnableFilterForLineBreakpoints())
217+
if (Language *lang = Language::FindPlugin(sc_list[0].GetLanguage()))
218+
lang->FilterForLineBreakpoints(all_scs);
220219

221220
while (all_scs.size()) {
222221
uint32_t closest_line = UINT32_MAX;

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,16 +1832,20 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
18321832
return mangled_name;
18331833
}
18341834

1835-
bool SwiftLanguage::IgnoreForLineBreakpoints(const SymbolContext &sc) const {
1836-
// If we don't have a function, conservatively return false.
1837-
if (!sc.function)
1838-
return false;
1839-
llvm::StringRef name =
1840-
sc.function->GetMangled().GetMangledName().GetStringRef();
1841-
// In async functions, ignore await resume ("Q") funclets, these only
1842-
// deallocate the async context and task_switch back to user code.
1843-
return SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
1844-
name);
1835+
void SwiftLanguage::FilterForLineBreakpoints(
1836+
llvm::SmallVectorImpl<SymbolContext> &sc_list) const {
1837+
llvm::erase_if(sc_list, [](const SymbolContext &sc) {
1838+
// If we don't have a function, conservatively keep this sc.
1839+
if (!sc.function)
1840+
return false;
1841+
1842+
// In async functions, ignore await resume ("Q") funclets, these only
1843+
// deallocate the async context and task_switch back to user code.
1844+
llvm::StringRef name =
1845+
sc.function->GetMangled().GetMangledName().GetStringRef();
1846+
return SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
1847+
name);
1848+
});
18451849
}
18461850

18471851
std::optional<bool>

lldb/source/Plugins/Language/Swift/SwiftLanguage.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class SwiftLanguage : public Language {
9797
llvm::StringRef GetInstanceVariableName() override { return "self"; }
9898

9999
/// Override that skips breakpoints inside await resume ("Q") async funclets.
100-
bool IgnoreForLineBreakpoints(const SymbolContext &sc) const override;
100+
void FilterForLineBreakpoints(
101+
llvm::SmallVectorImpl<SymbolContext> &) const override;
101102

102103
//------------------------------------------------------------------
103104
// PluginInterface protocol

0 commit comments

Comments
 (0)