diff options
| author | Adrian Prantl <aprantl@apple.com> | 2019-10-17 19:56:40 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2019-10-17 19:56:40 +0000 |
| commit | 1ad655e255090620705eb4ce85d869a54d971912 (patch) | |
| tree | 0aea7b3e59e4569096a15f8ab9f661e4595983b7 /lldb/source/Commands | |
| parent | e3905dee0044c8b6c5f3a9cf46b9b6fe45039da6 (diff) | |
| download | bcm5719-llvm-1ad655e255090620705eb4ce85d869a54d971912.tar.gz bcm5719-llvm-1ad655e255090620705eb4ce85d869a54d971912.zip | |
Modernize the rest of the Find.* API (NFC)
This patch removes the size_t return value and the append parameter
from the remainder of the Find.* functions in LLDB's internal API. As
in the previous patches, this is motivated by the fact that these
parameters aren't really used, and in the case of the append parameter
were frequently implemented incorrectly.
Differential Revision: https://reviews.llvm.org/D69119
llvm-svn: 375160
Diffstat (limited to 'lldb/source/Commands')
| -rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 53 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 64 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectWatchpoint.cpp | 10 |
4 files changed, 64 insertions, 66 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 43354c7e35d..469a6bbbadf 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -447,9 +447,8 @@ Searcher::CallbackReturn CommandCompletions::SymbolCompleter::SearchCallback( SymbolContextList sc_list; const bool include_symbols = true; const bool include_inlines = true; - const bool append = true; context.module_sp->FindFunctions(m_regex, include_symbols, include_inlines, - append, sc_list); + sc_list); SymbolContext sc; // Now add the functions & symbols to the list - only add if unique: diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 3ac8e91c488..78c8bc81192 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -392,17 +392,18 @@ protected: // const. ModuleList module_list = (m_module_list.GetSize() > 0) ? m_module_list : target->GetImages(); - size_t num_matches = - module_list.FindFunctions(name, eFunctionNameTypeAuto, - /*include_symbols=*/false, - /*include_inlines=*/true, - /*append=*/true, sc_list_funcs); + module_list.FindFunctions(name, eFunctionNameTypeAuto, + /*include_symbols=*/false, + /*include_inlines=*/true, sc_list_funcs); + size_t num_matches = sc_list_funcs.GetSize(); + if (!num_matches) { // If we didn't find any functions with that name, try searching for // symbols that line up exactly with function addresses. SymbolContextList sc_list_symbols; - size_t num_symbol_matches = module_list.FindFunctionSymbols( + module_list.FindFunctionSymbols( name, eFunctionNameTypeAuto, sc_list_symbols); + size_t num_symbol_matches = sc_list_symbols.GetSize(); for (size_t i = 0; i < num_symbol_matches; i++) { SymbolContext sc; sc_list_symbols.GetContextAtIndex(i, sc); @@ -580,7 +581,8 @@ protected: FileSpec module_file_spec(m_options.modules[i]); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); - if (target->GetImages().FindModules(module_spec, m_module_list) == 0) + target->GetImages().FindModules(module_spec, m_module_list); + if (m_module_list.IsEmpty()) result.AppendWarningWithFormat("No module found for '%s'.\n", m_options.modules[i].c_str()); } @@ -872,13 +874,11 @@ protected: // these somewhere, there should probably be a module-filter-list that can be // passed to the various ModuleList::Find* calls, which would either be a // vector of string names or a ModuleSpecList. - size_t FindMatchingFunctions(Target *target, ConstString name, + void FindMatchingFunctions(Target *target, ConstString name, SymbolContextList &sc_list) { // Displaying the source for a symbol: bool include_inlines = true; - bool append = true; bool include_symbols = false; - size_t num_matches = 0; if (m_options.num_lines == 0) m_options.num_lines = 10; @@ -892,22 +892,20 @@ protected: ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); target->GetImages().FindModules(module_spec, matching_modules); - num_matches += matching_modules.FindFunctions( + matching_modules.FindFunctions( name, eFunctionNameTypeAuto, include_symbols, include_inlines, - append, sc_list); + sc_list); } } } else { - num_matches = target->GetImages().FindFunctions( - name, eFunctionNameTypeAuto, include_symbols, include_inlines, append, - sc_list); + target->GetImages().FindFunctions(name, eFunctionNameTypeAuto, + include_symbols, include_inlines, + sc_list); } - return num_matches; } - size_t FindMatchingFunctionSymbols(Target *target, ConstString name, - SymbolContextList &sc_list) { - size_t num_matches = 0; + void FindMatchingFunctionSymbols(Target *target, ConstString name, + SymbolContextList &sc_list) { const size_t num_modules = m_options.modules.size(); if (num_modules > 0) { ModuleList matching_modules; @@ -917,15 +915,14 @@ protected: ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); target->GetImages().FindModules(module_spec, matching_modules); - num_matches += matching_modules.FindFunctionSymbols( - name, eFunctionNameTypeAuto, sc_list); + matching_modules.FindFunctionSymbols(name, eFunctionNameTypeAuto, + sc_list); } } } else { - num_matches = target->GetImages().FindFunctionSymbols( - name, eFunctionNameTypeAuto, sc_list); + target->GetImages().FindFunctionSymbols(name, eFunctionNameTypeAuto, + sc_list); } - return num_matches; } bool DoExecute(Args &command, CommandReturnObject &result) override { @@ -945,13 +942,15 @@ protected: ConstString name(m_options.symbol_name.c_str()); // Displaying the source for a symbol. Search for function named name. - size_t num_matches = FindMatchingFunctions(target, name, sc_list); + FindMatchingFunctions(target, name, sc_list); + size_t num_matches = sc_list.GetSize(); if (!num_matches) { // If we didn't find any functions with that name, try searching for // symbols that line up exactly with function addresses. SymbolContextList sc_list_symbols; - size_t num_symbol_matches = - FindMatchingFunctionSymbols(target, name, sc_list_symbols); + FindMatchingFunctionSymbols(target, name, sc_list_symbols); + size_t num_symbol_matches =sc_list_symbols.GetSize(); + for (size_t i = 0; i < num_symbol_matches; i++) { SymbolContext sc; sc_list_symbols.GetContextAtIndex(i, sc); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8a768e513eb..abf7895a738 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -798,12 +798,12 @@ public: static size_t GetVariableCallback(void *baton, const char *name, VariableList &variable_list) { + size_t old_size = variable_list.GetSize(); Target *target = static_cast<Target *>(baton); - if (target) { - return target->GetImages().FindGlobalVariables(ConstString(name), - UINT32_MAX, variable_list); - } - return 0; + if (target) + target->GetImages().FindGlobalVariables(ConstString(name), UINT32_MAX, + variable_list); + return variable_list.GetSize() - old_size; } Options *GetOptions() override { return &m_option_group; } @@ -866,8 +866,9 @@ protected: return false; } use_var_name = true; - matches = target->GetImages().FindGlobalVariables(regex, UINT32_MAX, - variable_list); + target->GetImages().FindGlobalVariables(regex, UINT32_MAX, + variable_list); + matches = variable_list.GetSize(); } else { Status error(Variable::GetValuesForVariableExpressionPath( arg, m_exe_ctx.GetBestExecutionContextScope(), @@ -942,7 +943,6 @@ protected: } } else { SymbolContextList sc_list; - const bool append = true; // We have one or more compile unit or shlib if (num_shlibs > 0) { for (size_t shlib_idx = 0; shlib_idx < num_shlibs; ++shlib_idx) { @@ -955,8 +955,7 @@ protected: if (num_compile_units > 0) { for (size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) module_sp->FindCompileUnits( - compile_units.GetFileSpecAtIndex(cu_idx), append, - sc_list); + compile_units.GetFileSpecAtIndex(cu_idx), sc_list); } else { SymbolContext sc; sc.module_sp = module_sp; @@ -974,7 +973,7 @@ protected: // units files that were specified for (size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) target->GetImages().FindCompileUnits( - compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list); + compile_units.GetFileSpecAtIndex(cu_idx), sc_list); } const uint32_t num_scs = sc_list.GetSize(); @@ -1598,19 +1597,17 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter, bool verbose) { if (module && name && name[0]) { SymbolContextList sc_list; - const bool append = true; size_t num_matches = 0; if (name_is_regex) { RegularExpression function_name_regex((llvm::StringRef(name))); - num_matches = module->FindFunctions(function_name_regex, include_symbols, - include_inlines, append, sc_list); + module->FindFunctions(function_name_regex, include_symbols, + include_inlines, sc_list); } else { ConstString function_name(name); - num_matches = module->FindFunctions( - function_name, nullptr, eFunctionNameTypeAuto, include_symbols, - include_inlines, append, sc_list); + module->FindFunctions(function_name, nullptr, eFunctionNameTypeAuto, + include_symbols, include_inlines, sc_list); } - + num_matches = sc_list.GetSize(); if (num_matches) { strm.Indent(); strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches, @@ -1770,8 +1767,8 @@ static size_t FindModulesByName(Target *target, const char *module_name, } } else { if (target) { - const size_t num_matches = - target->GetImages().FindModules(module_spec, module_list); + target->GetImages().FindModules(module_spec, module_list); + const size_t num_matches = module_list.GetSize(); // Not found in our module list for our target, check the main shared // module list in case it is a extra file used somewhere else @@ -2695,8 +2692,8 @@ protected: if (search_using_module_spec) { ModuleList matching_modules; - const size_t num_matches = - target->GetImages().FindModules(module_spec, matching_modules); + target->GetImages().FindModules(module_spec, matching_modules); + const size_t num_matches = matching_modules.GetSize(); char path[PATH_MAX]; if (num_matches == 1) { @@ -3352,7 +3349,7 @@ protected: if (m_options.m_type == eLookupTypeFunctionOrSymbol) { ConstString function_name(m_options.m_str.c_str()); target->GetImages().FindFunctions(function_name, eFunctionNameTypeAuto, - true, false, true, sc_list); + true, false, sc_list); } else if (m_options.m_type == eLookupTypeAddress && target) { Address addr; if (target->GetSectionLoadList().ResolveLoadAddress(m_options.m_addr, @@ -4067,8 +4064,9 @@ protected: // It has a UUID, look for this UUID in the target modules ModuleSpec symfile_uuid_module_spec; symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID(); - num_matches = target->GetImages().FindModules( - symfile_uuid_module_spec, matching_module_list); + target->GetImages().FindModules(symfile_uuid_module_spec, + matching_module_list); + num_matches = matching_module_list.GetSize(); } } @@ -4086,8 +4084,9 @@ protected: ModuleSpec symfile_uuid_module_spec; symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID(); - num_matches = target->GetImages().FindModules( - symfile_uuid_module_spec, matching_module_list); + target->GetImages().FindModules(symfile_uuid_module_spec, + matching_module_list); + num_matches = matching_module_list.GetSize(); } } } @@ -4096,9 +4095,10 @@ protected: // Just try to match up the file by basename if we have no matches at // this point - if (num_matches == 0) - num_matches = - target->GetImages().FindModules(module_spec, matching_module_list); + if (num_matches == 0) { + target->GetImages().FindModules(module_spec, matching_module_list); + num_matches = matching_module_list.GetSize(); + } while (num_matches == 0) { ConstString filename_no_extension( @@ -4115,8 +4115,8 @@ protected: // Replace basename with one less extension module_spec.GetFileSpec().GetFilename() = filename_no_extension; - num_matches = - target->GetImages().FindModules(module_spec, matching_module_list); + target->GetImages().FindModules(module_spec, matching_module_list); + num_matches = matching_module_list.GetSize(); } if (num_matches > 1) { diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 6e59a26c473..44dfb29b19b 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -785,12 +785,12 @@ corresponding to the byte size of the data type."); protected: static size_t GetVariableCallback(void *baton, const char *name, VariableList &variable_list) { + size_t old_size = variable_list.GetSize(); Target *target = static_cast<Target *>(baton); - if (target) { - return target->GetImages().FindGlobalVariables(ConstString(name), - UINT32_MAX, variable_list); - } - return 0; + if (target) + target->GetImages().FindGlobalVariables(ConstString(name), UINT32_MAX, + variable_list); + return variable_list.GetSize() - old_size; } bool DoExecute(Args &command, CommandReturnObject &result) override { |

