[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 30 10:49:50 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)

<details>
<summary>Changes</summary>

I'm developing the Mojo language, and some symbol breakpoints don't work because of two reasons that this PR fixes:

- 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/110543.diff


3 Files Affected:

- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+7-7) 
- (modified) lldb/source/Core/Module.cpp (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (+2-1) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/110543


More information about the lldb-commits mailing list