aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectSource.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-10-17 19:56:40 +0000
committerAdrian Prantl <aprantl@apple.com>2019-10-17 19:56:40 +0000
commit1ad655e255090620705eb4ce85d869a54d971912 (patch)
tree0aea7b3e59e4569096a15f8ab9f661e4595983b7 /lldb/source/Commands/CommandObjectSource.cpp
parente3905dee0044c8b6c5f3a9cf46b9b6fe45039da6 (diff)
downloadllvm-1ad655e255090620705eb4ce85d869a54d971912.zip
llvm-1ad655e255090620705eb4ce85d869a54d971912.tar.gz
llvm-1ad655e255090620705eb4ce85d869a54d971912.tar.bz2
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/CommandObjectSource.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 3ac8e91..78c8bc8 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);