augusto2112 created this revision. augusto2112 added reviewers: jingham, labath, aprantl. Herald added a project: All. augusto2112 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
It may be useful to search symbol table entries by mangled instead of demangled names. Add this optional functionality in the SymbolTable functions. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D130803 Files: lldb/include/lldb/Core/Module.h lldb/include/lldb/Symbol/Symtab.h lldb/source/Core/Module.cpp lldb/source/Symbol/Symtab.cpp
Index: lldb/source/Symbol/Symtab.cpp =================================================================== --- lldb/source/Symbol/Symtab.cpp +++ lldb/source/Symbol/Symtab.cpp @@ -744,7 +744,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType( const RegularExpression ®exp, SymbolType symbol_type, - std::vector<uint32_t> &indexes) { + std::vector<uint32_t> &indexes, bool match_against_demangled) { std::lock_guard<std::recursive_mutex> 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<uint32_t> &indexes) { + std::vector<uint32_t> &indexes, bool match_against_demangled) { std::lock_guard<std::recursive_mutex> 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<uint32_t> &symbol_indexes) { + std::vector<uint32_t> &symbol_indexes, bool match_against_demangled) { std::lock_guard<std::recursive_mutex> 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, Index: lldb/source/Core/Module.cpp =================================================================== --- lldb/source/Core/Module.cpp +++ 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<uint32_t> symbol_indexes; symtab->FindAllSymbolsMatchingRexExAndType( regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny, - symbol_indexes); + symbol_indexes, match_against_demangled); SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list); } } Index: lldb/include/lldb/Symbol/Symtab.h =================================================================== --- lldb/include/lldb/Symbol/Symtab.h +++ lldb/include/lldb/Symbol/Symtab.h @@ -89,14 +89,13 @@ Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &matches); - uint32_t - AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, - lldb::SymbolType symbol_type, - std::vector<uint32_t> &indexes); + uint32_t AppendSymbolIndexesMatchingRegExAndType( + const RegularExpression ®ex, lldb::SymbolType symbol_type, + std::vector<uint32_t> &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<uint32_t> &indexes); + std::vector<uint32_t> &indexes, bool match_against_demangled = false); void FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector<uint32_t> &symbol_indexes); @@ -105,10 +104,12 @@ Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes); - void FindAllSymbolsMatchingRexExAndType( - const RegularExpression ®ex, lldb::SymbolType symbol_type, - Debug symbol_debug_type, Visibility symbol_visibility, - std::vector<uint32_t> &symbol_indexes); + void FindAllSymbolsMatchingRexExAndType(const RegularExpression ®ex, + lldb::SymbolType symbol_type, + Debug symbol_debug_type, + Visibility symbol_visibility, + std::vector<uint32_t> &symbol_indexes, + bool match_against_demangled = false); Symbol *FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Index: lldb/include/lldb/Core/Module.h =================================================================== --- lldb/include/lldb/Core/Module.h +++ 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. ///
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits