From 9ac2f9b2eb34e7495e60500ce9b90cc9370e8709 Mon Sep 17 00:00:00 2001 From: walter erquinigo Date: Mon, 30 Sep 2024 13:33:35 -0400 Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages I'm developing the Mojo language, and some symbol breakpoints don't work because of two reasons that got fixed1: - There's a prune step that operates on the assuption that the symbol is C-like. That was discarding lots of the Mojo breakpoints - When finding functions for symbol breakpoints with eFunctionNameTypeFull, LLDB was only matching die.getMangledName() and not die.GetName(). The latter is the one useful for Mojo, because the former has some unreadable format in Mojo that is not exposed to the user. This shouldn't cause any regression for C-like languages, as the prune step would sanitize them anyway, but it's useful for languages like Mojo. --- lldb/source/Breakpoint/BreakpointResolverName.cpp | 14 +++++++------- lldb/source/Core/Module.cpp | 4 ++++ .../source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 264638eb836dc6..77ddd86302cd1d 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -24,10 +24,10 @@ using namespace lldb; using namespace lldb_private; -BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt, - const char *name_cstr, FunctionNameType name_type_mask, - LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, - bool skip_prologue) +BreakpointResolverName::BreakpointResolverName( + const BreakpointSP &bkpt, const char *name_cstr, + FunctionNameType name_type_mask, LanguageType language, + Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue) : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset), m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) { if (m_match_type == Breakpoint::Regexp) { @@ -237,9 +237,9 @@ void BreakpointResolverName::AddNameLookup(ConstString name, if (Language *lang = Language::FindPlugin(m_language)) { add_variant_funcs(lang); } else { - // Most likely m_language is eLanguageTypeUnknown. We check each language for - // possible variants or more qualified names and create lookups for those as - // well. + // Most likely m_language is eLanguageTypeUnknown. We check each language + // for possible variants or more qualified names and create lookups for + // those as well. Language::ForEach(add_variant_funcs); } } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 88cc957e91fac4..29b419e9969743 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list, while (i < sc_list.GetSize()) { if (!sc_list.GetContextAtIndex(i, sc)) break; + if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) { + ++i; + continue; + } // Make sure the mangled and demangled names don't match before we try to // pull anything out ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled)); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index eafddbad03f57b..7bf53dce1b1b07 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -59,7 +59,8 @@ bool DWARFIndex::ProcessFunctionDIE( return true; // In case of a full match, we just insert everything we find. - if (name_type_mask & eFunctionNameTypeFull && die.GetMangledName() == name) + if (name_type_mask & eFunctionNameTypeFull && + (die.GetMangledName() == name || die.GetName() == name)) return callback(die); // If looking for ObjC selectors, we need to also check if the name is a