Skip to content

Commit

Permalink
[LLDB] Fix symbol breakpoint lookups for non-C-like languages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
walter-erquinigo committed Sep 30, 2024
1 parent c4952e5 commit 9ac2f9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lldb/source/Breakpoint/BreakpointResolverName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Core/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ac2f9b

Please sign in to comment.