https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/83908
Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. >From 32ed57079eec7d33a87883e192cd928caa2f5f6d Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan <fpiove...@apple.com> Date: Mon, 4 Mar 2024 09:56:18 -0800 Subject: [PATCH] [lldb] Allow languages to filter breakpoints set by line Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. --- lldb/include/lldb/Target/Language.h | 4 ++++ lldb/source/Breakpoint/BreakpointResolver.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0cbd8a32dccd54..957c40eb7c0772 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,6 +339,10 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } + virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { + return true; + } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index bc6348716ef418..876b30c6d76d55 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,6 +23,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -199,6 +200,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl<SymbolContext> &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { + if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); + return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional<uint16_t> column) { @@ -206,6 +216,8 @@ void BreakpointResolver::SetSCMatchesByLine( for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); + while (all_scs.size()) { uint32_t closest_line = UINT32_MAX; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits