diff options
author | Pavel Labath <pavel@labath.sk> | 2019-08-05 09:21:47 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-08-05 09:21:47 +0000 |
commit | d5d47a3574823635fddef3bba3de37e2a5ea0d76 (patch) | |
tree | 1f0f9b4cde535e98639ac220cb6f45e80aab4dfd /lldb/source/Commands/CommandObjectTarget.cpp | |
parent | 8ed8353fc45e3906f7fd8dde1072bce7b54aca62 (diff) | |
download | llvm-d5d47a3574823635fddef3bba3de37e2a5ea0d76.zip llvm-d5d47a3574823635fddef3bba3de37e2a5ea0d76.tar.gz llvm-d5d47a3574823635fddef3bba3de37e2a5ea0d76.tar.bz2 |
Remove SymbolVendor::GetSymtab
Summary:
This patch removes the GetSymtab method from the SymbolVendor, which is
a no-op as it's implementation just forwards to the relevant SymbolFile.
Instead it creates a Module::GetSymtab, which calls the SymbolFile
method directly.
All callers have been updated to use the Module method directly instead
of a two phase GetSymbolVendor->GetSymtab search, which leads to reduced
intentation in a lot of deeply nested code.
Reviewers: clayborg, JDevlieghere, jingham
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D65569
llvm-svn: 367820
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 83 |
1 files changed, 38 insertions, 45 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1c75966..5535a50 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1447,15 +1447,11 @@ static size_t DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list) { static void DumpModuleSymtab(CommandInterpreter &interpreter, Stream &strm, Module *module, SortOrder sort_order) { - if (module) { - SymbolVendor *sym_vendor = module->GetSymbolVendor(); - if (sym_vendor) { - Symtab *symtab = sym_vendor->GetSymtab(); - if (symtab) - symtab->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), - sort_order); - } - } + if (!module) + return; + if (Symtab *symtab = module->GetSymtab()) + symtab->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), + sort_order); } static void DumpModuleSections(CommandInterpreter &interpreter, Stream &strm, @@ -1561,47 +1557,44 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, bool verbose) { - if (module) { - SymbolContext sc; + if (!module) + return 0; - SymbolVendor *sym_vendor = module->GetSymbolVendor(); - if (sym_vendor) { - Symtab *symtab = sym_vendor->GetSymtab(); - if (symtab) { - std::vector<uint32_t> match_indexes; - ConstString symbol_name(name); - uint32_t num_matches = 0; - if (name_is_regex) { - RegularExpression name_regexp(symbol_name.GetStringRef()); - num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType( - name_regexp, eSymbolTypeAny, match_indexes); - } else { - num_matches = - symtab->AppendSymbolIndexesWithName(symbol_name, match_indexes); - } + Symtab *symtab = module->GetSymtab(); + if (!symtab) + return 0; - if (num_matches > 0) { - strm.Indent(); - strm.Printf("%u symbols match %s'%s' in ", num_matches, - name_is_regex ? "the regular expression " : "", name); - DumpFullpath(strm, &module->GetFileSpec(), 0); - strm.PutCString(":\n"); - strm.IndentMore(); - for (uint32_t i = 0; i < num_matches; ++i) { - Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); - if (symbol && symbol->ValueIsAddress()) { - DumpAddress(interpreter.GetExecutionContext() - .GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, strm); - } - } - strm.IndentLess(); - return num_matches; - } + SymbolContext sc; + std::vector<uint32_t> match_indexes; + ConstString symbol_name(name); + uint32_t num_matches = 0; + if (name_is_regex) { + RegularExpression name_regexp(symbol_name.GetStringRef()); + num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType( + name_regexp, eSymbolTypeAny, match_indexes); + } else { + num_matches = + symtab->AppendSymbolIndexesWithName(symbol_name, match_indexes); + } + + if (num_matches > 0) { + strm.Indent(); + strm.Printf("%u symbols match %s'%s' in ", num_matches, + name_is_regex ? "the regular expression " : "", name); + DumpFullpath(strm, &module->GetFileSpec(), 0); + strm.PutCString(":\n"); + strm.IndentMore(); + for (uint32_t i = 0; i < num_matches; ++i) { + Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); + if (symbol && symbol->ValueIsAddress()) { + DumpAddress( + interpreter.GetExecutionContext().GetBestExecutionContextScope(), + symbol->GetAddressRef(), verbose, strm); } } + strm.IndentLess(); } - return 0; + return num_matches; } static void DumpSymbolContextList(ExecutionContextScope *exe_scope, |