summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
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/Core
parente3905dee0044c8b6c5f3a9cf46b9b6fe45039da6 (diff)
downloadbcm5719-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/Core')
-rw-r--r--lldb/source/Core/AddressResolverName.cpp5
-rw-r--r--lldb/source/Core/Disassembler.cpp5
-rw-r--r--lldb/source/Core/Module.cpp76
-rw-r--r--lldb/source/Core/ModuleList.cpp107
-rw-r--r--lldb/source/Core/SourceManager.cpp8
5 files changed, 70 insertions, 131 deletions
diff --git a/lldb/source/Core/AddressResolverName.cpp b/lldb/source/Core/AddressResolverName.cpp
index 665d6aa68b4..6b9b7b2de72 100644
--- a/lldb/source/Core/AddressResolverName.cpp
+++ b/lldb/source/Core/AddressResolverName.cpp
@@ -86,7 +86,6 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
const bool include_symbols = false;
const bool include_inlines = true;
- const bool append = false;
switch (m_match_type) {
case AddressResolver::Exact:
if (context.module_sp) {
@@ -94,7 +93,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_func_name, nullptr,
eFunctionNameTypeAuto, include_symbols,
- include_inlines, append, func_list);
+ include_inlines, func_list);
}
break;
@@ -103,7 +102,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
context.module_sp->FindSymbolsMatchingRegExAndType(
m_regex, eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_regex, include_symbols,
- include_inlines, append, func_list);
+ include_inlines, func_list);
}
break;
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index fecdced6322..89ae25cbad6 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -174,11 +174,10 @@ bool Disassembler::Disassemble(
SymbolContextList sc_list;
if (module) {
module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, include_symbols,
- include_inlines, true, sc_list);
+ include_inlines, sc_list);
} else if (exe_ctx.GetTargetPtr()) {
exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
- name, eFunctionNameTypeAuto, include_symbols, include_inlines, false,
- sc_list);
+ name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);
}
// If no functions were found there's nothing to disassemble.
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index eb4119a3858..aef3f3e3b4b 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -594,31 +594,22 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
return sc_list.GetSize() - initial_count;
}
-size_t Module::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches,
- VariableList &variables) {
+void Module::FindGlobalVariables(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, VariableList &variables) {
if (SymbolFile *symbols = GetSymbolFile())
- return symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches,
- variables);
- return 0;
+ symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
}
-size_t Module::FindGlobalVariables(const RegularExpression &regex,
- size_t max_matches,
- VariableList &variables) {
+void Module::FindGlobalVariables(const RegularExpression &regex,
+ size_t max_matches, VariableList &variables) {
SymbolFile *symbols = GetSymbolFile();
if (symbols)
- return symbols->FindGlobalVariables(regex, max_matches, variables);
- return 0;
+ symbols->FindGlobalVariables(regex, max_matches, variables);
}
-size_t Module::FindCompileUnits(const FileSpec &path, bool append,
- SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
- const size_t start_size = sc_list.GetSize();
+void Module::FindCompileUnits(const FileSpec &path,
+ SymbolContextList &sc_list) {
const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
@@ -630,7 +621,6 @@ size_t Module::FindCompileUnits(const FileSpec &path, bool append,
sc_list.Append(sc);
}
}
- return sc_list.GetSize() - start_size;
}
Module::LookupInfo::LookupInfo(ConstString name,
@@ -793,14 +783,11 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
}
-size_t Module::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- FunctionNameType name_type_mask,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
+void Module::FindFunctions(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ FunctionNameType name_type_mask,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
// Find all the functions (not symbols, but debug information functions...
@@ -812,7 +799,7 @@ size_t Module::FindFunctions(ConstString name,
if (symbols) {
symbols->FindFunctions(lookup_info.GetLookupName(), parent_decl_ctx,
lookup_info.GetNameTypeMask(), include_inlines,
- append, sc_list);
+ sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -831,7 +818,7 @@ size_t Module::FindFunctions(ConstString name,
} else {
if (symbols) {
symbols->FindFunctions(name, parent_decl_ctx, name_type_mask,
- include_inlines, append, sc_list);
+ include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -842,20 +829,15 @@ size_t Module::FindFunctions(ConstString name,
}
}
}
-
- return sc_list.GetSize() - old_size;
}
-size_t Module::FindFunctions(const RegularExpression &regex,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
+void Module::FindFunctions(const RegularExpression &regex, bool include_symbols,
+ bool include_inlines,
+ SymbolContextList &sc_list) {
const size_t start_size = sc_list.GetSize();
if (SymbolFile *symbols = GetSymbolFile()) {
- symbols->FindFunctions(regex, include_inlines, append, sc_list);
+ symbols->FindFunctions(regex, include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -917,7 +899,6 @@ size_t Module::FindFunctions(const RegularExpression &regex,
}
}
}
- return sc_list.GetSize() - start_size;
}
void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
@@ -1326,7 +1307,7 @@ void Module::SymbolIndicesToSymbolContextList(
}
}
-size_t Module::FindFunctionSymbols(ConstString name,
+void Module::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@@ -1334,11 +1315,10 @@ size_t Module::FindFunctionSymbols(ConstString name,
"Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
name.AsCString(), name_type_mask);
if (Symtab *symtab = GetSymtab())
- return symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
- return 0;
+ symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
}
-size_t Module::FindSymbolsWithNameAndType(ConstString name,
+void Module::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
@@ -1348,18 +1328,16 @@ size_t Module::FindSymbolsWithNameAndType(ConstString name,
Timer scoped_timer(
func_cat, "Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
name.AsCString(), symbol_type);
- const size_t initial_size = sc_list.GetSize();
if (Symtab *symtab = GetSymtab()) {
std::vector<uint32_t> symbol_indexes;
symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
- return sc_list.GetSize() - initial_size;
}
-size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
- SymbolType symbol_type,
- SymbolContextList &sc_list) {
+void Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
+ SymbolType symbol_type,
+ SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
// already thread safe.
@@ -1368,7 +1346,6 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
func_cat,
"Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
regex.GetText().str().c_str(), symbol_type);
- const size_t initial_size = sc_list.GetSize();
if (Symtab *symtab = GetSymtab()) {
std::vector<uint32_t> symbol_indexes;
symtab->FindAllSymbolsMatchingRexExAndType(
@@ -1376,7 +1353,6 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
symbol_indexes);
SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
- return sc_list.GetSize() - initial_size;
}
void Module::PreloadSymbols() {
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 317a2e33196..b0567a902fd 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -326,14 +326,10 @@ ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const {
return module_sp;
}
-size_t ModuleList::FindFunctions(ConstString name,
- FunctionNameType name_type_mask,
- bool include_symbols, bool include_inlines,
- bool append,
- SymbolContextList &sc_list) const {
- if (!append)
- sc_list.Clear();
-
+void ModuleList::FindFunctions(ConstString name,
+ FunctionNameType name_type_mask,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) const {
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto) {
@@ -344,7 +340,7 @@ size_t ModuleList::FindFunctions(ConstString name,
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(lookup_info.GetLookupName(), nullptr,
lookup_info.GetNameTypeMask(), include_symbols,
- include_inlines, true, sc_list);
+ include_inlines, sc_list);
}
const size_t new_size = sc_list.GetSize();
@@ -356,15 +352,14 @@ size_t ModuleList::FindFunctions(ConstString name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols,
- include_inlines, true, sc_list);
+ include_inlines, sc_list);
}
}
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindFunctionSymbols(ConstString name,
- lldb::FunctionNameType name_type_mask,
- SymbolContextList &sc_list) {
+void ModuleList::FindFunctionSymbols(ConstString name,
+ lldb::FunctionNameType name_type_mask,
+ SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto) {
@@ -388,96 +383,66 @@ size_t ModuleList::FindFunctionSymbols(ConstString name,
(*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
}
}
-
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindFunctions(const RegularExpression &name,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- const size_t old_size = sc_list.GetSize();
-
+void ModuleList::FindFunctions(const RegularExpression &name,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(name, include_symbols, include_inlines, append,
- sc_list);
+ (*pos)->FindFunctions(name, include_symbols, include_inlines, sc_list);
}
-
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
- SymbolContextList &sc_list) const {
- if (!append)
- sc_list.Clear();
-
+void ModuleList::FindCompileUnits(const FileSpec &path,
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindCompileUnits(path, true, sc_list);
+ (*pos)->FindCompileUnits(path, sc_list);
}
-
- return sc_list.GetSize();
}
-size_t ModuleList::FindGlobalVariables(ConstString name,
- size_t max_matches,
- VariableList &variable_list) const {
- size_t initial_size = variable_list.GetSize();
+void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
+ VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
}
- return variable_list.GetSize() - initial_size;
}
-size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
- size_t max_matches,
- VariableList &variable_list) const {
- size_t initial_size = variable_list.GetSize();
+void ModuleList::FindGlobalVariables(const RegularExpression &regex,
+ size_t max_matches,
+ VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
}
- return variable_list.GetSize() - initial_size;
}
-size_t ModuleList::FindSymbolsWithNameAndType(ConstString name,
- SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append) const {
+void ModuleList::FindSymbolsWithNameAndType(ConstString name,
+ SymbolType symbol_type,
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- if (!append)
- sc_list.Clear();
- size_t initial_size = sc_list.GetSize();
-
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
- return sc_list.GetSize() - initial_size;
}
-size_t ModuleList::FindSymbolsMatchingRegExAndType(
+void ModuleList::FindSymbolsMatchingRegExAndType(
const RegularExpression &regex, lldb::SymbolType symbol_type,
- SymbolContextList &sc_list, bool append) const {
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- if (!append)
- sc_list.Clear();
- size_t initial_size = sc_list.GetSize();
-
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
- return sc_list.GetSize() - initial_size;
}
-size_t ModuleList::FindModules(const ModuleSpec &module_spec,
- ModuleList &matching_module_list) const {
- size_t existing_matches = matching_module_list.GetSize();
-
+void ModuleList::FindModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
@@ -485,7 +450,6 @@ size_t ModuleList::FindModules(const ModuleSpec &module_spec,
if (module_sp->MatchesModuleSpec(module_spec))
matching_module_list.Append(module_sp);
}
- return matching_module_list.GetSize() - existing_matches;
}
ModuleSP ModuleList::FindModule(const Module *module_ptr) const {
@@ -736,9 +700,9 @@ bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
return false;
}
-size_t ModuleList::FindSharedModules(const ModuleSpec &module_spec,
- ModuleList &matching_module_list) {
- return GetSharedModuleList().FindModules(module_spec, matching_module_list);
+void ModuleList::FindSharedModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) {
+ GetSharedModuleList().FindModules(module_spec, matching_module_list);
}
size_t ModuleList::RemoveOrphanSharedModules(bool mandatory) {
@@ -773,8 +737,9 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
// mutex list.
if (!always_create) {
ModuleList matching_module_list;
- const size_t num_matching_modules =
- shared_module_list.FindModules(module_spec, matching_module_list);
+ shared_module_list.FindModules(module_spec, matching_module_list);
+ const size_t num_matching_modules = matching_module_list.GetSize();
+
if (num_matching_modules > 0) {
for (size_t module_idx = 0; module_idx < num_matching_modules;
++module_idx) {
@@ -925,8 +890,8 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
platform_module_spec.GetSymbolFileSpec() =
located_binary_modulespec.GetSymbolFileSpec();
ModuleList matching_module_list;
- if (shared_module_list.FindModules(platform_module_spec,
- matching_module_list) > 0) {
+ shared_module_list.FindModules(platform_module_spec, matching_module_list);
+ if (!matching_module_list.IsEmpty()) {
module_sp = matching_module_list.GetModuleAtIndex(0);
// If we didn't have a UUID in mind when looking for the object file,
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index 87065ab6242..42741e4ba4f 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -324,10 +324,10 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
ConstString main_name("main");
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
- bool append = false;
- size_t num_matches = executable_ptr->FindFunctions(
- main_name, nullptr, lldb::eFunctionNameTypeBase, inlines_okay,
- symbols_okay, append, sc_list);
+ executable_ptr->FindFunctions(main_name, nullptr,
+ lldb::eFunctionNameTypeBase, inlines_okay,
+ symbols_okay, sc_list);
+ size_t num_matches = sc_list.GetSize();
for (size_t idx = 0; idx < num_matches; idx++) {
SymbolContext sc;
sc_list.GetContextAtIndex(idx, sc);
OpenPOWER on IntegriCloud