diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -263,7 +263,8 @@ void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, - SymbolContextList &sc_list); + SymbolContextList &sc_list, + bool match_against_demangled = false); /// Find a function symbols in the object file's symbol table. /// diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h --- a/lldb/include/lldb/Symbol/Symtab.h +++ b/lldb/include/lldb/Symbol/Symtab.h @@ -89,14 +89,13 @@ Debug symbol_debug_type, Visibility symbol_visibility, std::vector &matches); - uint32_t - AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, - lldb::SymbolType symbol_type, - std::vector &indexes); + uint32_t AppendSymbolIndexesMatchingRegExAndType( + const RegularExpression ®ex, lldb::SymbolType symbol_type, + std::vector &indexes, bool match_against_demangled = false); uint32_t AppendSymbolIndexesMatchingRegExAndType( const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, - std::vector &indexes); + std::vector &indexes, bool match_against_demangled = false); void FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector &symbol_indexes); @@ -105,10 +104,12 @@ Debug symbol_debug_type, Visibility symbol_visibility, std::vector &symbol_indexes); - void FindAllSymbolsMatchingRexExAndType( - const RegularExpression ®ex, lldb::SymbolType symbol_type, - Debug symbol_debug_type, Visibility symbol_visibility, - std::vector &symbol_indexes); + void FindAllSymbolsMatchingRexExAndType(const RegularExpression ®ex, + lldb::SymbolType symbol_type, + Debug symbol_debug_type, + Visibility symbol_visibility, + std::vector &symbol_indexes, + bool match_against_demangled = false); Symbol *FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1369,7 +1369,8 @@ void Module::FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, SymbolType symbol_type, - SymbolContextList &sc_list) { + SymbolContextList &sc_list, + bool match_against_demangled) { // No need to protect this call using m_mutex all other method calls are // already thread safe. LLDB_SCOPED_TIMERF( @@ -1379,7 +1380,7 @@ std::vector symbol_indexes; symtab->FindAllSymbolsMatchingRexExAndType( regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny, - symbol_indexes); + symbol_indexes, match_against_demangled); SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list); } } diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -744,7 +744,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType( const RegularExpression ®exp, SymbolType symbol_type, - std::vector &indexes) { + std::vector &indexes, bool match_against_demangled) { std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); @@ -753,7 +753,10 @@ for (uint32_t i = 0; i < sym_end; i++) { if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type) { - const char *name = m_symbols[i].GetName().AsCString(); + const char *name = + match_against_demangled + ? m_symbols[i].GetMangled().GetMangledName().AsCString() + : m_symbols[i].GetName().AsCString(); if (name) { if (regexp.Execute(name)) indexes.push_back(i); @@ -766,7 +769,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType( const RegularExpression ®exp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, - std::vector &indexes) { + std::vector &indexes, bool match_against_demangled) { std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); @@ -778,7 +781,10 @@ if (!CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility)) continue; - const char *name = m_symbols[i].GetName().AsCString(); + const char *name = + match_against_demangled + ? m_symbols[i].GetMangled().GetMangledName().AsCString() + : m_symbols[i].GetName().AsCString(); if (name) { if (regexp.Execute(name)) indexes.push_back(i); @@ -847,11 +853,12 @@ void Symtab::FindAllSymbolsMatchingRexExAndType( const RegularExpression ®ex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, - std::vector &symbol_indexes) { + std::vector &symbol_indexes, bool match_against_demangled) { std::lock_guard guard(m_mutex); AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, - symbol_visibility, symbol_indexes); + symbol_visibility, symbol_indexes, + match_against_demangled); } Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name,