From 1ad655e255090620705eb4ce85d869a54d971912 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 17 Oct 2019 19:56:40 +0000 Subject: [PATCH] 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 --- lldb/include/lldb/Core/Module.h | 68 ++++------- lldb/include/lldb/Core/ModuleList.h | 69 ++++------- lldb/include/lldb/Core/ModuleSpec.h | 5 +- lldb/include/lldb/Symbol/SymbolFile.h | 22 ++-- lldb/include/lldb/Symbol/Symtab.h | 22 ++-- lldb/include/lldb/Target/DynamicLoader.h | 10 +- lldb/source/API/SBModule.cpp | 17 ++- lldb/source/API/SBTarget.cpp | 45 ++++---- .../Breakpoint/BreakpointResolverName.cpp | 5 +- lldb/source/Commands/CommandCompletions.cpp | 3 +- lldb/source/Commands/CommandObjectSource.cpp | 53 +++++---- lldb/source/Commands/CommandObjectTarget.cpp | 64 +++++------ .../Commands/CommandObjectWatchpoint.cpp | 10 +- lldb/source/Core/AddressResolverName.cpp | 5 +- lldb/source/Core/Disassembler.cpp | 5 +- lldb/source/Core/Module.cpp | 76 +++++-------- lldb/source/Core/ModuleList.cpp | 107 ++++++------------ lldb/source/Core/SourceManager.cpp | 8 +- lldb/source/Expression/IRExecutionUnit.cpp | 2 - .../Hexagon-DYLD/HexagonDYLDRendezvous.cpp | 5 +- .../MacOSX-DYLD/DynamicLoaderDarwin.cpp | 14 +-- .../MacOSX-DYLD/DynamicLoaderDarwin.h | 2 +- .../POSIX-DYLD/DYLDRendezvous.cpp | 7 +- .../ExpressionParser/Clang/ClangASTSource.cpp | 9 +- .../Clang/ClangExpressionDeclMap.cpp | 8 +- .../Plugins/JITLoader/GDB/JITLoaderGDB.cpp | 4 +- .../CPlusPlus/CPPLanguageRuntime.cpp | 2 +- .../AppleObjCRuntime/AppleObjCRuntime.cpp | 23 ++-- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 5 +- .../ObjC/ObjCLanguageRuntime.cpp | 4 +- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 5 +- .../Platform/Android/PlatformAndroid.cpp | 6 +- .../Process/Utility/InferiorCallPOSIX.cpp | 12 +- .../GDBRemoteCommunicationClient.cpp | 5 +- .../Breakpad/SymbolFileBreakpad.cpp | 16 +-- .../SymbolFile/Breakpad/SymbolFileBreakpad.h | 23 ++-- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 74 +++++------- .../SymbolFile/DWARF/SymbolFileDWARF.h | 24 ++-- .../DWARF/SymbolFileDWARFDebugMap.cpp | 81 +++++-------- .../DWARF/SymbolFileDWARFDebugMap.h | 26 ++--- .../NativePDB/SymbolFileNativePDB.cpp | 19 ++-- .../NativePDB/SymbolFileNativePDB.h | 21 ++-- .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 56 ++++----- .../Plugins/SymbolFile/PDB/SymbolFilePDB.h | 24 ++-- .../MacOSX/SystemRuntimeMacOSX.cpp | 24 ++-- lldb/source/Symbol/Function.cpp | 4 +- lldb/source/Symbol/SymbolFile.cpp | 42 +++---- lldb/source/Symbol/Symtab.cpp | 18 +-- lldb/source/Target/Target.cpp | 14 +-- lldb/tools/lldb-test/lldb-test.cpp | 6 +- lldb/unittests/Core/MangledTest.cpp | 3 +- lldb/unittests/Target/ModuleCacheTest.cpp | 5 +- 52 files changed, 482 insertions(+), 705 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index f0b8a552a29f..89b731427e3f 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -246,13 +246,13 @@ public: ConstString name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); - size_t FindSymbolsWithNameAndType(ConstString name, - lldb::SymbolType symbol_type, - SymbolContextList &sc_list); + void FindSymbolsWithNameAndType(ConstString name, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list); - size_t FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, - lldb::SymbolType symbol_type, - SymbolContextList &sc_list); + void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list); /// Find a function symbols in the object file's symbol table. /// @@ -266,11 +266,8 @@ public: /// /// \param[out] sc_list /// A list to append any matching symbol contexts to. - /// - /// \return - /// The number of symbol contexts that were added to \a sc_list - size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask, - SymbolContextList &sc_list); + void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, + SymbolContextList &sc_list); /// Find compile units by partial or full path. /// @@ -280,19 +277,10 @@ public: /// \param[in] path /// The name of the function we are looking for. /// - /// \param[in] append - /// If \b true, then append any compile units that were found - /// to \a sc_list. If \b false, then the \a sc_list is cleared - /// and the contents of \a sc_list are replaced. - /// /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. - /// - /// \return - /// The number of matches added to \a sc_list. - size_t FindCompileUnits(const FileSpec &path, bool append, - SymbolContextList &sc_list); + void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list); /// Find functions by name. /// @@ -312,21 +300,13 @@ public: /// names, base names, C++ methods, or ObjC selectors. /// See FunctionNameType for more details. /// - /// \param[in] append - /// If \b true, any matches will be appended to \a sc_list, else - /// matches replace the contents of \a sc_list. - /// /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. - /// - /// \return - /// The number of matches added to \a sc_list. - size_t FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, bool symbols_ok, - bool inlines_ok, bool append, - SymbolContextList &sc_list); + void FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, bool symbols_ok, + bool inlines_ok, SymbolContextList &sc_list); /// Find functions by name. /// @@ -344,12 +324,8 @@ public: /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. - /// - /// \return - /// The number of matches added to \a sc_list. - size_t FindFunctions(const RegularExpression ®ex, bool symbols_ok, - bool inlines_ok, bool append, - SymbolContextList &sc_list); + void FindFunctions(const RegularExpression ®ex, bool symbols_ok, + bool inlines_ok, SymbolContextList &sc_list); /// Find addresses by file/line /// @@ -394,11 +370,9 @@ public: /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// \return - /// The number of matches added to \a variable_list. - size_t FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - size_t max_matches, VariableList &variable_list); + void FindGlobalVariables(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + size_t max_matches, VariableList &variable_list); /// Find global and static variables by regular expression. /// @@ -412,10 +386,8 @@ public: /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// \return - /// The number of matches added to \a variable_list. - size_t FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, - VariableList &variable_list); + void FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, + VariableList &variable_list); /// Find types by name. /// diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 898f4b14219f..e21655551b61 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -247,35 +247,24 @@ public: /// \param[in] path /// The name of the compile unit we are looking for. /// - /// \param[in] append - /// If \b true, then append any compile units that were found - /// to \a sc_list. If \b false, then the \a sc_list is cleared - /// and the contents of \a sc_list are replaced. - /// /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. - /// - /// \return - /// The number of matches added to \a sc_list. - size_t FindCompileUnits(const FileSpec &path, bool append, - SymbolContextList &sc_list) const; + void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list) const; /// \see Module::FindFunctions () - size_t FindFunctions(ConstString name, - lldb::FunctionNameType name_type_mask, - bool include_symbols, bool include_inlines, bool append, - SymbolContextList &sc_list) const; + void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, + bool include_symbols, bool include_inlines, + SymbolContextList &sc_list) const; /// \see Module::FindFunctionSymbols () - size_t FindFunctionSymbols(ConstString name, - lldb::FunctionNameType name_type_mask, - SymbolContextList &sc_list); + void FindFunctionSymbols(ConstString name, + lldb::FunctionNameType name_type_mask, + SymbolContextList &sc_list); /// \see Module::FindFunctions () - size_t FindFunctions(const RegularExpression &name, bool include_symbols, - bool include_inlines, bool append, - SymbolContextList &sc_list); + void FindFunctions(const RegularExpression &name, bool include_symbols, + bool include_inlines, SymbolContextList &sc_list); /// Find global and static variables by name. /// @@ -289,11 +278,8 @@ public: /// /// \param[in] variable_list /// A list of variables that gets the matches appended to. - /// - /// \return - /// The number of matches added to \a variable_list. - size_t FindGlobalVariables(ConstString name, size_t max_matches, - VariableList &variable_list) const; + void FindGlobalVariables(ConstString name, size_t max_matches, + VariableList &variable_list) const; /// Find global and static variables by regular expression. /// @@ -306,11 +292,8 @@ public: /// /// \param[in] variable_list /// A list of variables that gets the matches appended to. - /// - /// \return - /// The number of matches added to \a variable_list. - size_t FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, - VariableList &variable_list) const; + void FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, + VariableList &variable_list) const; /// Finds the first module whose file specification matches \a file_spec. /// @@ -337,11 +320,8 @@ public: /// \param[out] matching_module_list /// A module list that gets filled in with any modules that /// match the search criteria. - /// - /// \return - /// The number of matching modules found by the search. - size_t FindModules(const ModuleSpec &module_spec, - ModuleList &matching_module_list) const; + void FindModules(const ModuleSpec &module_spec, + ModuleList &matching_module_list) const; lldb::ModuleSP FindModule(const Module *module_ptr) const; @@ -354,15 +334,13 @@ public: lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const; - size_t FindSymbolsWithNameAndType(ConstString name, - lldb::SymbolType symbol_type, - SymbolContextList &sc_list, - bool append = false) const; + void FindSymbolsWithNameAndType(ConstString name, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list) const; - size_t FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, - lldb::SymbolType symbol_type, - SymbolContextList &sc_list, - bool append = false) const; + void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list) const; /// Find types by name. /// @@ -474,6 +452,7 @@ public: /// \return /// The number of modules in the module list. size_t GetSize() const; + bool IsEmpty() const { return !GetSize(); } bool LoadScriptingResourcesInTarget(Target *target, std::list &errors, Stream *feedback_stream = nullptr, @@ -492,8 +471,8 @@ public: static bool RemoveSharedModule(lldb::ModuleSP &module_sp); - static size_t FindSharedModules(const ModuleSpec &module_spec, - ModuleList &matching_module_list); + static void FindSharedModules(const ModuleSpec &module_spec, + ModuleList &matching_module_list); static size_t RemoveOrphanSharedModules(bool mandatory); diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index ab0f4e9912a8..651d0dc869bc 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -380,8 +380,8 @@ public: return false; } - size_t FindMatchingModuleSpecs(const ModuleSpec &module_spec, - ModuleSpecList &matching_list) const { + void FindMatchingModuleSpecs(const ModuleSpec &module_spec, + ModuleSpecList &matching_list) const { std::lock_guard guard(m_mutex); bool exact_arch_match = true; const size_t initial_match_count = matching_list.GetSize(); @@ -400,7 +400,6 @@ public: matching_list.Append(spec); } } - return matching_list.GetSize() - initial_match_count; } void Dump(Stream &strm) { diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index d246c6d80944..6724b425abf3 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -173,21 +173,19 @@ public: SymbolContextList &sc_list); virtual void DumpClangAST(Stream &s) {} - virtual uint32_t + virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables); - virtual uint32_t FindGlobalVariables(const RegularExpression ®ex, - uint32_t max_matches, - VariableList &variables); - virtual uint32_t FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, - bool include_inlines, bool append, - SymbolContextList &sc_list); - virtual uint32_t FindFunctions(const RegularExpression ®ex, - bool include_inlines, bool append, - SymbolContextList &sc_list); + virtual void FindGlobalVariables(const RegularExpression ®ex, + uint32_t max_matches, + VariableList &variables); + virtual void FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, SymbolContextList &sc_list); + virtual void FindFunctions(const RegularExpression ®ex, + bool include_inlines, SymbolContextList &sc_list); virtual void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h index 868edcdc9290..99d15771ccc5 100644 --- a/lldb/include/lldb/Symbol/Symtab.h +++ b/lldb/include/lldb/Symbol/Symtab.h @@ -92,15 +92,15 @@ public: const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector &indexes); - size_t FindAllSymbolsWithNameAndType(ConstString name, - lldb::SymbolType symbol_type, - std::vector &symbol_indexes); - size_t FindAllSymbolsWithNameAndType(ConstString name, - lldb::SymbolType symbol_type, - Debug symbol_debug_type, - Visibility symbol_visibility, - std::vector &symbol_indexes); - size_t FindAllSymbolsMatchingRexExAndType( + void FindAllSymbolsWithNameAndType(ConstString name, + lldb::SymbolType symbol_type, + std::vector &symbol_indexes); + void FindAllSymbolsWithNameAndType(ConstString name, + lldb::SymbolType symbol_type, + Debug symbol_debug_type, + Visibility symbol_visibility, + std::vector &symbol_indexes); + void FindAllSymbolsMatchingRexExAndType( const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector &symbol_indexes); @@ -112,8 +112,8 @@ public: Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr); void ForEachSymbolContainingFileAddress( lldb::addr_t file_addr, std::function const &callback); - size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask, - SymbolContextList &sc_list); + void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, + SymbolContextList &sc_list); void CalculateSymbolSizes(); void SortSymbolIndexesByValue(std::vector &indexes, diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h index 2bf3f32b5eef..ac72b98e5e1a 100644 --- a/lldb/include/lldb/Target/DynamicLoader.h +++ b/lldb/include/lldb/Target/DynamicLoader.h @@ -148,13 +148,9 @@ public: /// The equivalent symbol list - any equivalent symbols found are appended /// to this list. /// - /// \return - /// Number of equivalent symbols found. - virtual size_t FindEquivalentSymbols(Symbol *original_symbol, - ModuleList &module_list, - SymbolContextList &equivalent_symbols) { - return 0; - } + virtual void FindEquivalentSymbols(Symbol *original_symbol, + ModuleList &module_list, + SymbolContextList &equivalent_symbols) {} /// Ask if it is ok to try and load or unload an shared library (image). /// diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 5eb0f54bed62..6cc6d2628ace 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -282,8 +282,7 @@ SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) { SBSymbolContextList sb_sc_list; const ModuleSP module_sp(GetSP()); if (sb_file_spec.IsValid() && module_sp) { - const bool append = true; - module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list); + module_sp->FindCompileUnits(*sb_file_spec, *sb_sc_list); } return LLDB_RECORD_RESULT(sb_sc_list); } @@ -342,8 +341,9 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, Symtab *symtab = GetUnifiedSymbolTable(module_sp); if (symtab) { std::vector matching_symbol_indexes; - const size_t num_matches = symtab->FindAllSymbolsWithNameAndType( - ConstString(name), symbol_type, matching_symbol_indexes); + symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type, + matching_symbol_indexes); + const size_t num_matches = matching_symbol_indexes.size(); if (num_matches) { SymbolContext sc; sc.module_sp = module_sp; @@ -398,12 +398,11 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, lldb::SBSymbolContextList sb_sc_list; ModuleSP module_sp(GetSP()); if (name && module_sp) { - const bool append = true; const bool symbols_ok = true; const bool inlines_ok = true; FunctionNameType type = static_cast(name_type_mask); module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok, - inlines_ok, append, *sb_sc_list); + inlines_ok, *sb_sc_list); } return LLDB_RECORD_RESULT(sb_sc_list); } @@ -418,9 +417,9 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, ModuleSP module_sp(GetSP()); if (name && module_sp) { VariableList variable_list; - const uint32_t match_count = module_sp->FindGlobalVariables( - ConstString(name), nullptr, max_matches, variable_list); - + module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches, + variable_list); + const uint32_t match_count = variable_list.GetSize(); if (match_count > 0) { for (uint32_t i = 0; i < match_count; ++i) { lldb::ValueObjectSP valobj_sp; diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 0d0a470e202f..1d13087eef69 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1653,11 +1653,8 @@ SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { SBSymbolContextList sb_sc_list; const TargetSP target_sp(GetSP()); - if (target_sp && sb_file_spec.IsValid()) { - const bool append = true; - target_sp->GetImages().FindCompileUnits(*sb_file_spec, - append, *sb_sc_list); - } + if (target_sp && sb_file_spec.IsValid()) + target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list); return LLDB_RECORD_RESULT(sb_sc_list); } @@ -1783,10 +1780,9 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, const bool symbols_ok = true; const bool inlines_ok = true; - const bool append = true; FunctionNameType mask = static_cast(name_type_mask); target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, - inlines_ok, append, *sb_sc_list); + inlines_ok, *sb_sc_list); return LLDB_RECORD_RESULT(sb_sc_list); } @@ -1806,17 +1802,16 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, switch (matchtype) { case eMatchTypeRegex: target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true, - true, true, *sb_sc_list); + true, *sb_sc_list); break; case eMatchTypeStartsWith: regexstr = llvm::Regex::escape(name) + ".*"; target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true, - true, true, *sb_sc_list); + true, *sb_sc_list); break; default: - target_sp->GetImages().FindFunctions(ConstString(name), - eFunctionNameTypeAny, true, true, - true, *sb_sc_list); + target_sp->GetImages().FindFunctions( + ConstString(name), eFunctionNameTypeAny, true, true, *sb_sc_list); break; } } @@ -1933,9 +1928,9 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, TargetSP target_sp(GetSP()); if (name && target_sp) { VariableList variable_list; - const uint32_t match_count = target_sp->GetImages().FindGlobalVariables( - ConstString(name), max_matches, variable_list); - + target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches, + variable_list); + const uint32_t match_count = variable_list.GetSize(); if (match_count > 0) { ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); if (exe_scope == nullptr) @@ -1970,20 +1965,20 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, uint32_t match_count; switch (matchtype) { case eMatchTypeNormal: - match_count = target_sp->GetImages().FindGlobalVariables( - ConstString(name), max_matches, variable_list); + target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches, + variable_list); break; case eMatchTypeRegex: - match_count = target_sp->GetImages().FindGlobalVariables( - RegularExpression(name_ref), max_matches, variable_list); + target_sp->GetImages().FindGlobalVariables(RegularExpression(name_ref), + max_matches, variable_list); break; case eMatchTypeStartsWith: regexstr = llvm::Regex::escape(name) + ".*"; - match_count = target_sp->GetImages().FindGlobalVariables( - RegularExpression(regexstr), max_matches, variable_list); + target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr), + max_matches, variable_list); break; } - + match_count = variable_list.GetSize(); if (match_count > 0) { ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); if (exe_scope == nullptr) @@ -2287,11 +2282,9 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, SBSymbolContextList sb_sc_list; if (name && name[0]) { TargetSP target_sp(GetSP()); - if (target_sp) { - bool append = true; + if (target_sp) target_sp->GetImages().FindSymbolsWithNameAndType( - ConstString(name), symbol_type, *sb_sc_list, append); - } + ConstString(name), symbol_type, *sb_sc_list); } return LLDB_RECORD_RESULT(sb_sc_list); } diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 59b74dc29644..ba9c88c7eae8 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -271,7 +271,6 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter, bool filter_by_language = (m_language != eLanguageTypeUnknown); const bool include_symbols = !filter_by_cu; const bool include_inlines = true; - const bool append = true; switch (m_match_type) { case Breakpoint::Exact: @@ -280,7 +279,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter, const size_t start_func_idx = func_list.GetSize(); context.module_sp->FindFunctions( lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(), - include_symbols, include_inlines, append, func_list); + include_symbols, include_inlines, func_list); const size_t end_func_idx = func_list.GetSize(); @@ -294,7 +293,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter, context.module_sp->FindFunctions( m_regex, !filter_by_cu, // include symbols only if we aren't filtering by CU - include_inlines, append, func_list); + include_inlines, func_list); } break; case Breakpoint::Glob: diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 43354c7e35dd..469a6bbbadf6 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 3ac8e91c4888..78c8bc811926 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 8a768e513eb1..abf7895a7384 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(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 6e59a26c4735..44dfb29b19b5 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(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 { diff --git a/lldb/source/Core/AddressResolverName.cpp b/lldb/source/Core/AddressResolverName.cpp index 665d6aa68b4c..6b9b7b2de723 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 fecdced63224..89ae25cbad64 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 eb4119a38585..aef3f3e3b4b0 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 ®ex, - size_t max_matches, - VariableList &variables) { +void Module::FindGlobalVariables(const RegularExpression ®ex, + 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 ®ex, - bool include_symbols, bool include_inlines, - bool append, SymbolContextList &sc_list) { - if (!append) - sc_list.Clear(); - +void Module::FindFunctions(const RegularExpression ®ex, 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 ®ex, } } } - 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 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 ®ex, - SymbolType symbol_type, - SymbolContextList &sc_list) { +void Module::FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, + 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 ®ex, 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 symbol_indexes; symtab->FindAllSymbolsMatchingRexExAndType( @@ -1376,7 +1353,6 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, 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 317a2e331966..b0567a902fd7 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 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 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 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 ®ex, - size_t max_matches, - VariableList &variable_list) const { - size_t initial_size = variable_list.GetSize(); +void ModuleList::FindGlobalVariables(const RegularExpression ®ex, + size_t max_matches, + VariableList &variable_list) const { std::lock_guard 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 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 ®ex, lldb::SymbolType symbol_type, - SymbolContextList &sc_list, bool append) const { + SymbolContextList &sc_list) const { std::lock_guard 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 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 87065ab62425..42741e4ba4fe 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); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index bf5f1a6acc61..b10628e10cc5 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -854,7 +854,6 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask, true, // include_symbols false, // include_inlines - true, // append sc_list); } @@ -870,7 +869,6 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( sc.target_sp->GetImages().FindFunctions(spec.name, spec.mask, true, // include_symbols false, // include_inlines - true, // append sc_list); } diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp index a3f3c3d31682..f4788816d4ea 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp @@ -290,8 +290,9 @@ bool HexagonDYLDRendezvous::FindMetadata(const char *name, PThreadField field, Target &target = m_process->GetTarget(); SymbolContextList list; - if (!target.GetImages().FindSymbolsWithNameAndType(ConstString(name), - eSymbolTypeAny, list)) + target.GetImages().FindSymbolsWithNameAndType(ConstString(name), + eSymbolTypeAny, list); + if (list.IsEmpty()) return false; Address address = list[0].symbol->GetAddress(); diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 9ec4ae0d45e0..f8a7c9d34af8 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -977,15 +977,13 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread, return thread_plan_sp; } -size_t DynamicLoaderDarwin::FindEquivalentSymbols( +void DynamicLoaderDarwin::FindEquivalentSymbols( lldb_private::Symbol *original_symbol, lldb_private::ModuleList &images, lldb_private::SymbolContextList &equivalent_symbols) { ConstString trampoline_name = original_symbol->GetMangled().GetName( original_symbol->GetLanguage(), Mangled::ePreferMangled); if (!trampoline_name) - return 0; - - size_t initial_size = equivalent_symbols.GetSize(); + return; static const char *resolver_name_regex = "(_gc|_non_gc|\\$[A-Za-z0-9\\$]+)$"; std::string equivalent_regex_buf("^"); @@ -993,11 +991,9 @@ size_t DynamicLoaderDarwin::FindEquivalentSymbols( equivalent_regex_buf.append(resolver_name_regex); RegularExpression equivalent_name_regex(equivalent_regex_buf); - const bool append = true; images.FindSymbolsMatchingRegExAndType(equivalent_name_regex, eSymbolTypeCode, - equivalent_symbols, append); + equivalent_symbols); - return equivalent_symbols.GetSize() - initial_size; } lldb::ModuleSP DynamicLoaderDarwin::GetPThreadLibraryModule() { @@ -1008,8 +1004,8 @@ lldb::ModuleSP DynamicLoaderDarwin::GetPThreadLibraryModule() { module_spec.GetFileSpec().GetFilename().SetCString( "libsystem_pthread.dylib"); ModuleList module_list; - if (m_process->GetTarget().GetImages().FindModules(module_spec, - module_list)) { + m_process->GetTarget().GetImages().FindModules(module_spec, module_list); + if (!module_list.IsEmpty()) { if (module_list.GetSize() == 1) { module_sp = module_list.GetModuleAtIndex(0); if (module_sp) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h index f2c78d4278ed..ea7a900d39c5 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -41,7 +41,7 @@ public: lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override; - size_t FindEquivalentSymbols( + void FindEquivalentSymbols( lldb_private::Symbol *original_symbol, lldb_private::ModuleList &module_list, lldb_private::SymbolContextList &equivalent_symbols) override; diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp index 6baf1d5bdb55..737599303a60 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -558,9 +558,10 @@ bool DYLDRendezvous::FindMetadata(const char *name, PThreadField field, Target &target = m_process->GetTarget(); SymbolContextList list; - if (!target.GetImages().FindSymbolsWithNameAndType(ConstString(name), - eSymbolTypeAny, list)) - return false; + target.GetImages().FindSymbolsWithNameAndType(ConstString(name), + eSymbolTypeAny, list); + if (list.IsEmpty()) + return false; Address address = list[0].symbol->GetAddress(); addr_t addr = address.GetLoadAddress(&target); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index b8cab4fdc378..372c2439ebf0 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -1228,7 +1228,6 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { const bool include_symbols = false; const bool include_inlines = false; - const bool append = false; std::string interface_name = interface_decl->getNameAsString(); @@ -1238,9 +1237,10 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { ms.Flush(); ConstString instance_method_name(ms.GetString()); + sc_list.Clear(); m_target->GetImages().FindFunctions( instance_method_name, lldb::eFunctionNameTypeFull, include_symbols, - include_inlines, append, sc_list); + include_inlines, sc_list); if (sc_list.GetSize()) break; @@ -1250,9 +1250,10 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { ms.Flush(); ConstString class_method_name(ms.GetString()); + sc_list.Clear(); m_target->GetImages().FindFunctions( class_method_name, lldb::eFunctionNameTypeFull, include_symbols, - include_inlines, append, sc_list); + include_inlines, sc_list); if (sc_list.GetSize()) break; @@ -1265,7 +1266,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { m_target->GetImages().FindFunctions( selector_name, lldb::eFunctionNameTypeSelector, include_symbols, - include_inlines, append, candidate_sc_list); + include_inlines, candidate_sc_list); for (uint32_t ci = 0, ce = candidate_sc_list.GetSize(); ci != ce; ++ci) { SymbolContext candidate_sc; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index c17fb0f4a4e7..f4457fc1b740 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1216,14 +1216,12 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } const bool include_inlines = false; - const bool append = false; - + sc_list.Clear(); if (namespace_decl && module_sp) { const bool include_symbols = false; module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase, - include_symbols, include_inlines, append, - sc_list); + include_symbols, include_inlines, sc_list); } else if (target && !namespace_decl) { const bool include_symbols = true; @@ -1232,7 +1230,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( target->GetImages().FindFunctions(name, eFunctionNameTypeFull, include_symbols, include_inlines, - append, sc_list); + sc_list); } // If we found more than one function, see if we can use the frame's decl diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index acaf9913374b..fff44123539f 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -458,8 +458,8 @@ addr_t JITLoaderGDB::GetSymbolAddress(ModuleList &module_list, SymbolContextList target_symbols; Target &target = m_process->GetTarget(); - if (!module_list.FindSymbolsWithNameAndType(name, symbol_type, - target_symbols)) + module_list.FindSymbolsWithNameAndType(name, symbol_type, target_symbols); + if (target_symbols.IsEmpty()) return LLDB_INVALID_ADDRESS; SymbolContext sym_ctx; diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index b392282c3eb1..f38014505a8b 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -231,7 +231,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( SymbolContextList scl; target.GetImages().FindSymbolsMatchingRegExAndType( - RegularExpression{R"(^)" + func_to_match}, eSymbolTypeAny, scl, true); + RegularExpression{R"(^)" + func_to_match}, eSymbolTypeAny, scl); // Case 1,2 or 3 if (scl.GetSize() >= 1) { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 52ed3628520f..8ca9ad7b843a 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -223,11 +223,14 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() { SymbolContextList contexts; SymbolContext context; - if ((!modules.FindSymbolsWithNameAndType(ConstString("_NSPrintForDebugger"), - eSymbolTypeCode, contexts)) && - (!modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"), - eSymbolTypeCode, contexts))) - return nullptr; + modules.FindSymbolsWithNameAndType(ConstString("_NSPrintForDebugger"), + eSymbolTypeCode, contexts); + if (contexts.IsEmpty()) { + modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"), + eSymbolTypeCode, contexts); + if (contexts.IsEmpty()) + return nullptr; + } contexts.GetContextAtIndex(0, context); @@ -444,10 +447,12 @@ bool AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing() { SymbolContextList sc_list; - return target.GetImages().FindSymbolsWithNameAndType( - s_method_signature, eSymbolTypeCode, sc_list) || - target.GetImages().FindSymbolsWithNameAndType( - s_arclite_method_signature, eSymbolTypeCode, sc_list); + target.GetImages().FindSymbolsWithNameAndType(s_method_signature, + eSymbolTypeCode, sc_list); + if (sc_list.IsEmpty()) + target.GetImages().FindSymbolsWithNameAndType(s_arclite_method_signature, + eSymbolTypeCode, sc_list); + return !sc_list.IsEmpty(); } lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index d5a47d160861..9bdbef393e39 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -2640,8 +2640,9 @@ bool AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded() { std::function get_symbol = [this](ConstString sym) -> lldb::addr_t { SymbolContextList sc_list; - if (GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType( - sym, lldb::eSymbolTypeData, sc_list) == 1) { + GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType( + sym, lldb::eSymbolTypeData, sc_list); + if (sc_list.GetSize() == 1) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); if (sc.symbol) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index 31aac7284602..87ae4c2c6c48 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -103,8 +103,8 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) { const ModuleList &modules = m_process->GetTarget().GetImages(); SymbolContextList sc_list; - const size_t matching_symbols = - modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list); + modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list); + const size_t matching_symbols = sc_list.GetSize(); if (matching_symbols) { SymbolContext sc; diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index fa8064690b3a..70e0997e2d3b 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -5276,8 +5276,9 @@ lldb_private::Address ObjectFileMachO::GetEntryPointAddress() { if (module_sp) { SymbolContextList contexts; SymbolContext context; - if (module_sp->FindSymbolsWithNameAndType(ConstString("start"), - eSymbolTypeCode, contexts)) { + module_sp->FindSymbolsWithNameAndType(ConstString("start"), + eSymbolTypeCode, contexts); + if (contexts.GetSize()) { if (contexts.GetContextAtIndex(0, context)) m_entry_point_address = context.symbol->GetAddress(); } diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index 7076872dcafa..93fc87d6de03 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -364,9 +364,9 @@ PlatformAndroid::GetLibdlFunctionDeclarations(lldb_private::Process *process) { const char *dl_open_name = nullptr; Target &target = process->GetTarget(); for (auto name: dl_open_names) { - if (target.GetImages().FindFunctionSymbols(ConstString(name), - eFunctionNameTypeFull, - matching_symbols)) { + target.GetImages().FindFunctionSymbols( + ConstString(name), eFunctionNameTypeFull, matching_symbols); + if (matching_symbols.GetSize()) { dl_open_name = name; break; } diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp index a0188229cf8e..2ccbeacc4960 100644 --- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -41,13 +41,13 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr, if (thread == nullptr) return false; - const bool append = true; const bool include_symbols = true; const bool include_inlines = false; SymbolContextList sc_list; - const uint32_t count = process->GetTarget().GetImages().FindFunctions( + process->GetTarget().GetImages().FindFunctions( ConstString("mmap"), eFunctionNameTypeFull, include_symbols, - include_inlines, append, sc_list); + include_inlines, sc_list); + const uint32_t count = sc_list.GetSize(); if (count > 0) { SymbolContext sc; if (sc_list.GetContextAtIndex(0, sc)) { @@ -135,13 +135,13 @@ bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr, if (thread == nullptr) return false; - const bool append = true; const bool include_symbols = true; const bool include_inlines = false; SymbolContextList sc_list; - const uint32_t count = process->GetTarget().GetImages().FindFunctions( + process->GetTarget().GetImages().FindFunctions( ConstString("munmap"), eFunctionNameTypeFull, include_symbols, - include_inlines, append, sc_list); + include_inlines, sc_list); + const uint32_t count = sc_list.GetSize(); if (count > 0) { SymbolContext sc; if (sc_list.GetContextAtIndex(0, sc)) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 02ba400afe38..feb9f0589cee 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -3834,8 +3834,9 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups( addr_t symbol_load_addr = LLDB_INVALID_ADDRESS; lldb_private::SymbolContextList sc_list; - if (process->GetTarget().GetImages().FindSymbolsWithNameAndType( - ConstString(symbol_name), eSymbolTypeAny, sc_list)) { + process->GetTarget().GetImages().FindSymbolsWithNameAndType( + ConstString(symbol_name), eSymbolTypeAny, sc_list); + if (!sc_list.IsEmpty()) { const size_t num_scs = sc_list.GetSize(); for (size_t sc_idx = 0; sc_idx < num_scs && diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index bed066f31e2f..f84cf0c5368d 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -289,23 +289,17 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext( return sc_list.GetSize() - old_size; } -uint32_t SymbolFileBreakpad::FindFunctions( +void SymbolFileBreakpad::FindFunctions( ConstString name, const CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list) { // TODO - if (!append) - sc_list.Clear(); - return sc_list.GetSize(); } -uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression ®ex, - bool include_inlines, bool append, - SymbolContextList &sc_list) { +void SymbolFileBreakpad::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) { // TODO - if (!append) - sc_list.Clear(); - return sc_list.GetSize(); } void SymbolFileBreakpad::FindTypes( diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h index 8906e4bfa25b..a10138cdf92f 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -70,12 +70,10 @@ public: size_t ParseBlocksRecursive(Function &func) override { return 0; } - uint32_t FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - uint32_t max_matches, - VariableList &variables) override { - return 0; - } + void FindGlobalVariables(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + uint32_t max_matches, + VariableList &variables) override {} size_t ParseVariablesForContext(const SymbolContext &sc) override { return 0; @@ -100,14 +98,13 @@ public: void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override {} - uint32_t FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, - bool include_inlines, bool append, - SymbolContextList &sc_list) override; + void FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, SymbolContextList &sc_list) override; - uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, - bool append, SymbolContextList &sc_list) override; + void FindFunctions(const RegularExpression ®ex, bool include_inlines, + SymbolContextList &sc_list) override; void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7d96e324ff92..c982d59c2830 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2005,7 +2005,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile( return false; } -uint32_t SymbolFileDWARF::FindGlobalVariables( +void SymbolFileDWARF::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { std::lock_guard guard(GetModuleMutex()); @@ -2020,11 +2020,11 @@ uint32_t SymbolFileDWARF::FindGlobalVariables( max_matches); if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) - return 0; + return; DWARFDebugInfo *info = DebugInfo(); - if (info == nullptr) - return 0; + if (!info) + return; // Remember how many variables are in the list before we search. const uint32_t original_size = variables.GetSize(); @@ -2111,12 +2111,11 @@ uint32_t SymbolFileDWARF::FindGlobalVariables( name.GetCString(), static_cast(parent_decl_ctx), max_matches, num_matches); } - return num_matches; } -uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex, - uint32_t max_matches, - VariableList &variables) { +void SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex, + uint32_t max_matches, + VariableList &variables) { std::lock_guard guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -2129,8 +2128,8 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex, } DWARFDebugInfo *info = DebugInfo(); - if (info == nullptr) - return 0; + if (!info) + return; // Remember how many variables are in the list before we search. const uint32_t original_size = variables.GetSize(); @@ -2163,9 +2162,6 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex, m_index->ReportInvalidDIERef(die_ref, regex.GetText()); } } - - // Return the number of variable that were appended to the list - return variables.GetSize() - original_size; } bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die, @@ -2241,10 +2237,11 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx, return false; } -uint32_t SymbolFileDWARF::FindFunctions( - ConstString name, const CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, - SymbolContextList &sc_list) { +void SymbolFileDWARF::FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + FunctionNameType name_type_mask, + bool include_inlines, + SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::FindFunctions (name = '%s')", @@ -2259,21 +2256,16 @@ uint32_t SymbolFileDWARF::FindFunctions( if (log) { GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF::FindFunctions (name=\"%s\", " - "name_type_mask=0x%x, append=%u, sc_list)", - name.GetCString(), name_type_mask, append); + "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, sc_list)", + name.GetCString(), name_type_mask); } - // If we aren't appending the results to this list, then clear the list - if (!append) - sc_list.Clear(); - if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) - return 0; + return; // If name is empty then we won't find anything. if (name.IsEmpty()) - return 0; + return; // Remember how many sc_list are in the list before we search in case we are // appending the results to a variable list. @@ -2300,17 +2292,15 @@ uint32_t SymbolFileDWARF::FindFunctions( GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::FindFunctions (name=\"%s\", " - "name_type_mask=0x%x, include_inlines=%d, append=%u, sc_list) => " - "%u", - name.GetCString(), name_type_mask, include_inlines, append, + "name_type_mask=0x%x, include_inlines=%d, sc_list) => %u", + name.GetCString(), name_type_mask, include_inlines, num_matches); } - return num_matches; } -uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression ®ex, - bool include_inlines, bool append, - SymbolContextList &sc_list) { +void SymbolFileDWARF::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::FindFunctions (regex = '%s')", @@ -2320,22 +2310,13 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression ®ex, if (log) { GetObjectFile()->GetModule()->LogMessage( - log, - "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)", - regex.GetText().str().c_str(), append); + log, "SymbolFileDWARF::FindFunctions (regex=\"%s\", sc_list)", + regex.GetText().str().c_str()); } - // If we aren't appending the results to this list, then clear the list - if (!append) - sc_list.Clear(); - DWARFDebugInfo *info = DebugInfo(); if (!info) - return 0; - - // Remember how many sc_list are in the list before we search in case we are - // appending the results to a variable list. - uint32_t original_size = sc_list.GetSize(); + return; DIEArray offsets; m_index->GetFunctions(regex, offsets); @@ -2350,9 +2331,6 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression ®ex, if (resolved_dies.insert(die.GetDIE()).second) ResolveFunction(die, include_inlines, sc_list); } - - // Return the number of variable that were appended to the list - return sc_list.GetSize() - original_size; } void SymbolFileDWARF::GetMangledNamesForFunction( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 4f04d416eacc..04cb11d426be 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -157,25 +157,25 @@ public: lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; - uint32_t + void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override; - uint32_t FindGlobalVariables(const lldb_private::RegularExpression ®ex, - uint32_t max_matches, - lldb_private::VariableList &variables) override; + void FindGlobalVariables(const lldb_private::RegularExpression ®ex, + uint32_t max_matches, + lldb_private::VariableList &variables) override; - uint32_t - FindFunctions(lldb_private::ConstString name, - const lldb_private::CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, bool include_inlines, - bool append, lldb_private::SymbolContextList &sc_list) override; + void FindFunctions(lldb_private::ConstString name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; - uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, - bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + void FindFunctions(const lldb_private::RegularExpression ®ex, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; void GetMangledNamesForFunction( const std::string &scope_qualified_name, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index c286dc90e5d6..a50d4e460bae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -824,12 +824,11 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( return sc_list.GetSize() - initial; } -uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( +void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, const std::vector &indexes, // Indexes into the symbol table that match "name" uint32_t max_matches, VariableList &variables) { - const uint32_t original_size = variables.GetSize(); const size_t match_count = indexes.size(); for (size_t i = 0; i < match_count; ++i) { uint32_t oso_idx; @@ -838,29 +837,26 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( if (comp_unit_info) { SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); if (oso_dwarf) { - if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, - variables)) - if (variables.GetSize() > max_matches) - break; + oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, + variables); + if (variables.GetSize() > max_matches) + break; } } } - return variables.GetSize() - original_size; } -uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables( +void SymbolFileDWARFDebugMap::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { std::lock_guard guard(GetModuleMutex()); - - // Remember how many variables are in the list before we search. - const uint32_t original_size = variables.GetSize(); - uint32_t total_matches = 0; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - const uint32_t oso_matches = oso_dwarf->FindGlobalVariables( - name, parent_decl_ctx, max_matches, variables); + const uint32_t old_size = variables.GetSize(); + oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, + variables); + const uint32_t oso_matches = variables.GetSize() - old_size; if (oso_matches > 0) { total_matches += oso_matches; @@ -879,23 +875,18 @@ uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables( return false; }); - - // Return the number of variable that were appended to the list - return variables.GetSize() - original_size; } -uint32_t -SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression ®ex, - uint32_t max_matches, - VariableList &variables) { +void SymbolFileDWARFDebugMap::FindGlobalVariables( + const RegularExpression ®ex, uint32_t max_matches, + VariableList &variables) { std::lock_guard guard(GetModuleMutex()); - // Remember how many variables are in the list before we search. - const uint32_t original_size = variables.GetSize(); - uint32_t total_matches = 0; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - const uint32_t oso_matches = - oso_dwarf->FindGlobalVariables(regex, max_matches, variables); + const uint32_t old_size = variables.GetSize(); + oso_dwarf->FindGlobalVariables(regex, max_matches, variables); + + const uint32_t oso_matches = variables.GetSize() - old_size; if (oso_matches > 0) { total_matches += oso_matches; @@ -914,9 +905,6 @@ SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression ®ex, return false; }); - - // Return the number of variable that were appended to the list - return variables.GetSize() - original_size; } int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex( @@ -1012,9 +1000,9 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, } } -uint32_t SymbolFileDWARFDebugMap::FindFunctions( +void SymbolFileDWARFDebugMap::FindFunctions( ConstString name, const CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); @@ -1022,52 +1010,37 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions( "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", name.GetCString()); - uint32_t initial_size = 0; - if (append) - initial_size = sc_list.GetSize(); - else - sc_list.Clear(); - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { uint32_t sc_idx = sc_list.GetSize(); - if (oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, - include_inlines, true, sc_list)) { + oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, + include_inlines, sc_list); + if (!sc_list.IsEmpty()) { RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list, sc_idx); } return false; }); - - return sc_list.GetSize() - initial_size; } -uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, - bool include_inlines, - bool append, - SymbolContextList &sc_list) { +void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')", regex.GetText().str().c_str()); - uint32_t initial_size = 0; - if (append) - initial_size = sc_list.GetSize(); - else - sc_list.Clear(); - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { uint32_t sc_idx = sc_list.GetSize(); - if (oso_dwarf->FindFunctions(regex, include_inlines, true, sc_list)) { + oso_dwarf->FindFunctions(regex, include_inlines, sc_list); + if (!sc_list.IsEmpty()) { RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list, sc_idx); } return false; }); - - return sc_list.GetSize() - initial_size; } void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 0643e6d24e6a..7adee1b356ce 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -92,22 +92,22 @@ public: bool check_inlines, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; - uint32_t + void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override; - uint32_t FindGlobalVariables(const lldb_private::RegularExpression ®ex, - uint32_t max_matches, - lldb_private::VariableList &variables) override; - uint32_t - FindFunctions(lldb_private::ConstString name, - const lldb_private::CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, bool include_inlines, - bool append, lldb_private::SymbolContextList &sc_list) override; - uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, - bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + void FindGlobalVariables(const lldb_private::RegularExpression ®ex, + uint32_t max_matches, + lldb_private::VariableList &variables) override; + void FindFunctions(lldb_private::ConstString name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; + void FindFunctions(const lldb_private::RegularExpression ®ex, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, @@ -236,7 +236,7 @@ protected: static int SymbolContainsSymbolWithID(lldb::user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); - uint32_t PrivateFindGlobalVariables( + void PrivateFindGlobalVariables( lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, const std::vector &name_symbol_indexes, uint32_t max_matches, diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index bb2cfc2aa5e4..33b8da3b543b 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1179,7 +1179,7 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) { void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); } -uint32_t SymbolFileNativePDB::FindGlobalVariables( +void SymbolFileNativePDB::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { std::lock_guard guard(GetModuleMutex()); @@ -1204,17 +1204,16 @@ uint32_t SymbolFileNativePDB::FindGlobalVariables( continue; } } - return variables.GetSize(); } -uint32_t SymbolFileNativePDB::FindFunctions( +void SymbolFileNativePDB::FindFunctions( ConstString name, const CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); // For now we only support lookup by method name. if (!(name_type_mask & eFunctionNameTypeMethod)) - return 0; + return; using SymbolAndOffset = std::pair; @@ -1239,15 +1238,11 @@ uint32_t SymbolFileNativePDB::FindFunctions( sc_list.Append(sc); } - - return sc_list.GetSize(); } -uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression ®ex, - bool include_inlines, bool append, - SymbolContextList &sc_list) { - return 0; -} +void SymbolFileNativePDB::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) {} void SymbolFileNativePDB::FindTypes( ConstString name, const CompilerDeclContext *parent_decl_ctx, diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 79908a601275..ca7de0e7d1ed 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -88,10 +88,10 @@ public: size_t ParseBlocksRecursive(Function &func) override; - uint32_t FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - uint32_t max_matches, - VariableList &variables) override; + void FindGlobalVariables(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + uint32_t max_matches, + VariableList &variables) override; size_t ParseVariablesForContext(const SymbolContext &sc) override; @@ -117,14 +117,13 @@ public: void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override; - uint32_t FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, - bool include_inlines, bool append, - SymbolContextList &sc_list) override; + void FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, SymbolContextList &sc_list) override; - uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, - bool append, SymbolContextList &sc_list) override; + void FindFunctions(const RegularExpression ®ex, bool include_inlines, + SymbolContextList &sc_list) override; void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 5d74b2537e6c..0dac6fdb807a 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1097,19 +1097,19 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc, return num_added; } -uint32_t SymbolFilePDB::FindGlobalVariables( +void SymbolFilePDB::FindGlobalVariables( lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) { std::lock_guard guard(GetModuleMutex()); if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) - return 0; + return; if (name.IsEmpty()) - return 0; + return; auto results = m_global_scope_up->findAllChildren(); if (!results) - return 0; + return; uint32_t matches = 0; size_t old_size = variables.GetSize(); @@ -1138,20 +1138,17 @@ uint32_t SymbolFilePDB::FindGlobalVariables( ParseVariables(sc, *pdb_data, &variables); matches = variables.GetSize() - old_size; } - - return matches; } -uint32_t -SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression ®ex, - uint32_t max_matches, - lldb_private::VariableList &variables) { +void SymbolFilePDB::FindGlobalVariables( + const lldb_private::RegularExpression ®ex, uint32_t max_matches, + lldb_private::VariableList &variables) { std::lock_guard guard(GetModuleMutex()); if (!regex.IsValid()) - return 0; + return; auto results = m_global_scope_up->findAllChildren(); if (!results) - return 0; + return; uint32_t matches = 0; size_t old_size = variables.GetSize(); @@ -1176,8 +1173,6 @@ SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression ®ex, ParseVariables(sc, *pdb_data, &variables); matches = variables.GetSize() - old_size; } - - return matches; } bool SymbolFilePDB::ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func, @@ -1299,24 +1294,21 @@ void SymbolFilePDB::CacheFunctionNames() { m_func_base_names.SizeToFit(); } -uint32_t SymbolFilePDB::FindFunctions( +void SymbolFilePDB::FindFunctions( lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, lldb_private::SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); - if (!append) - sc_list.Clear(); lldbassert((name_type_mask & eFunctionNameTypeAuto) == 0); if (name_type_mask == eFunctionNameTypeNone) - return 0; + return; if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) - return 0; + return; if (name.IsEmpty()) - return 0; + return; - auto old_size = sc_list.GetSize(); if (name_type_mask & eFunctionNameTypeFull || name_type_mask & eFunctionNameTypeBase || name_type_mask & eFunctionNameTypeMethod) { @@ -1346,25 +1338,19 @@ uint32_t SymbolFilePDB::FindFunctions( ResolveFn(m_func_base_names); ResolveFn(m_func_method_names); } - if (name_type_mask & eFunctionNameTypeBase) { + if (name_type_mask & eFunctionNameTypeBase) ResolveFn(m_func_base_names); - } - if (name_type_mask & eFunctionNameTypeMethod) { + if (name_type_mask & eFunctionNameTypeMethod) ResolveFn(m_func_method_names); - } } - return sc_list.GetSize() - old_size; } -uint32_t -SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression ®ex, - bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) { +void SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression ®ex, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) { std::lock_guard guard(GetModuleMutex()); - if (!append) - sc_list.Clear(); if (!regex.IsValid()) - return 0; + return; auto old_size = sc_list.GetSize(); CacheFunctionNames(); @@ -1383,8 +1369,6 @@ SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression ®ex, }; ResolveFn(m_func_full_names); ResolveFn(m_func_base_names); - - return sc_list.GetSize() - old_size; } void SymbolFilePDB::GetMangledNamesForFunction( diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h index 1fdacf0c8257..df717bbbbdb0 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -99,25 +99,25 @@ public: lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; - uint32_t + void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override; - uint32_t FindGlobalVariables(const lldb_private::RegularExpression ®ex, - uint32_t max_matches, - lldb_private::VariableList &variables) override; + void FindGlobalVariables(const lldb_private::RegularExpression ®ex, + uint32_t max_matches, + lldb_private::VariableList &variables) override; - uint32_t - FindFunctions(lldb_private::ConstString name, - const lldb_private::CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, bool include_inlines, - bool append, lldb_private::SymbolContextList &sc_list) override; + void FindFunctions(lldb_private::ConstString name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; - uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, - bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + void FindFunctions(const lldb_private::RegularExpression ®ex, + bool include_inlines, + lldb_private::SymbolContextList &sc_list) override; void GetMangledNamesForFunction( const std::string &scope_qualified_name, diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 4e384bd6ae5e..69e59bc4f7ee 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -579,9 +579,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() { static ConstString introspection_dispatch_queue_info_version( "__introspection_dispatch_queue_info_version"); SymbolContextList sc_list; - if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( - introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list) > - 0) { + m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( + introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); AddressRange addr_range; @@ -593,9 +593,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() { static ConstString introspection_dispatch_queue_info_data_offset( "__introspection_dispatch_queue_info_data_offset"); - if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( - introspection_dispatch_queue_info_data_offset, eSymbolTypeData, - sc_list) > 0) { + m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( + introspection_dispatch_queue_info_data_offset, eSymbolTypeData, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); AddressRange addr_range; @@ -607,9 +607,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() { static ConstString introspection_dispatch_item_info_version( "__introspection_dispatch_item_info_version"); - if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( - introspection_dispatch_item_info_version, eSymbolTypeData, sc_list) > - 0) { + m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( + introspection_dispatch_item_info_version, eSymbolTypeData, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); AddressRange addr_range; @@ -621,9 +621,9 @@ bool SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized() { static ConstString introspection_dispatch_item_info_data_offset( "__introspection_dispatch_item_info_data_offset"); - if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( - introspection_dispatch_item_info_data_offset, eSymbolTypeData, - sc_list) > 0) { + m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( + introspection_dispatch_item_info_data_offset, eSymbolTypeData, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); AddressRange addr_range; diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 9c4f5bcd9820..a4c2d3b4b44a 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -149,8 +149,8 @@ void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) { auto resolve_lazy_callee = [&]() -> Function * { ConstString callee_name{lazy_callee.symbol_name}; SymbolContextList sc_list; - size_t num_matches = - images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list); + images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list); + size_t num_matches = sc_list.GetSize(); if (num_matches == 0 || !sc_list[0].symbol) { LLDB_LOG(log, "CallEdge: Found no symbols for {0}, cannot resolve it", callee_name); diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 6dcdfbc089ba..c4f3a9c1a8c8 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -102,36 +102,24 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec, return 0; } -uint32_t -SymbolFile::FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - uint32_t max_matches, VariableList &variables) { - return 0; -} +void SymbolFile::FindGlobalVariables(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + uint32_t max_matches, + VariableList &variables) {} -uint32_t SymbolFile::FindGlobalVariables(const RegularExpression ®ex, - uint32_t max_matches, - VariableList &variables) { - return 0; -} +void SymbolFile::FindGlobalVariables(const RegularExpression ®ex, + uint32_t max_matches, + VariableList &variables) {} -uint32_t SymbolFile::FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - lldb::FunctionNameType name_type_mask, - bool include_inlines, bool append, - SymbolContextList &sc_list) { - if (!append) - sc_list.Clear(); - return 0; -} +void SymbolFile::FindFunctions(ConstString name, + const CompilerDeclContext *parent_decl_ctx, + lldb::FunctionNameType name_type_mask, + bool include_inlines, + SymbolContextList &sc_list) {} -uint32_t SymbolFile::FindFunctions(const RegularExpression ®ex, - bool include_inlines, bool append, - SymbolContextList &sc_list) { - if (!append) - sc_list.Clear(); - return 0; -} +void SymbolFile::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) {} void SymbolFile::GetMangledNamesForFunction( const std::string &scope_qualified_name, diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 29c390e83878..c4e6c2ccfb09 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -738,7 +738,7 @@ Symbol *Symtab::FindSymbolWithType(SymbolType symbol_type, return nullptr; } -size_t +void Symtab::FindAllSymbolsWithNameAndType(ConstString name, SymbolType symbol_type, std::vector &symbol_indexes) { @@ -756,10 +756,9 @@ Symtab::FindAllSymbolsWithNameAndType(ConstString name, // the symbols and match the symbol_type if any was given. AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes); } - return symbol_indexes.size(); } -size_t Symtab::FindAllSymbolsWithNameAndType( +void Symtab::FindAllSymbolsWithNameAndType( ConstString name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector &symbol_indexes) { std::lock_guard guard(m_mutex); @@ -777,10 +776,9 @@ size_t Symtab::FindAllSymbolsWithNameAndType( AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); } - return symbol_indexes.size(); } -size_t Symtab::FindAllSymbolsMatchingRexExAndType( +void Symtab::FindAllSymbolsMatchingRexExAndType( const RegularExpression ®ex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector &symbol_indexes) { @@ -788,7 +786,6 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType( AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); - return symbol_indexes.size(); } Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name, @@ -1024,10 +1021,8 @@ void Symtab::SymbolIndicesToSymbolContextList( } } -size_t Symtab::FindFunctionSymbols(ConstString name, - uint32_t name_type_mask, - SymbolContextList &sc_list) { - size_t count = 0; +void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask, + SymbolContextList &sc_list) { std::vector symbol_indexes; // eFunctionNameTypeAuto should be pre-resolved by a call to @@ -1108,11 +1103,8 @@ size_t Symtab::FindFunctionSymbols(ConstString name, symbol_indexes.erase( std::unique(symbol_indexes.begin(), symbol_indexes.end()), symbol_indexes.end()); - count = symbol_indexes.size(); SymbolIndicesToSymbolContextList(symbol_indexes, sc_list); } - - return count; } const Symbol *Symtab::GetParent(Symbol *child_symbol) const { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index ca80e36a0222..4b9a1b77ad16 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1648,11 +1648,11 @@ bool Target::ModuleIsExcludedForUnconstrainedSearches( if (GetBreakpointsConsultPlatformAvoidList()) { ModuleList matchingModules; ModuleSpec module_spec(module_file_spec); - size_t num_modules = GetImages().FindModules(module_spec, matchingModules); + GetImages().FindModules(module_spec, matchingModules); + size_t num_modules = matchingModules.GetSize(); - // If there is more than one module for this file spec, only return true if - // ALL the modules are on the - // black list. + // If there is more than one module for this file spec, only + // return true if ALL the modules are on the black list. if (num_modules > 0) { for (size_t i = 0; i < num_modules; i++) { if (!ModuleIsExcludedForUnconstrainedSearches( @@ -2059,11 +2059,9 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify, module_spec_copy.GetUUID().Clear(); ModuleList found_modules; - size_t num_found = - m_images.FindModules(module_spec_copy, found_modules); - if (num_found == 1) { + m_images.FindModules(module_spec_copy, found_modules); + if (found_modules.GetSize() == 1) old_module_sp = found_modules.GetModuleAtIndex(0); - } } } diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp index 5c5d793466eb..504bbbe6dabf 100644 --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -436,7 +436,8 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) { } else if (Regex) { RegularExpression RE(Name); assert(RE.IsValid()); - Symfile.FindFunctions(RE, true, false, List); + List.Clear(); + Symfile.FindFunctions(RE, true, List); } else { Expected ContextOr = getDeclContext(Symfile); if (!ContextOr) @@ -444,8 +445,9 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) { CompilerDeclContext *ContextPtr = ContextOr->IsValid() ? &*ContextOr : nullptr; + List.Clear(); Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(), - true, false, List); + true, List); } outs() << formatv("Found {0} functions:\n", List.GetSize()); StreamString Stream; diff --git a/lldb/unittests/Core/MangledTest.cpp b/lldb/unittests/Core/MangledTest.cpp index 9108d83a77ed..f1ea6a04df97 100644 --- a/lldb/unittests/Core/MangledTest.cpp +++ b/lldb/unittests/Core/MangledTest.cpp @@ -163,7 +163,8 @@ Symbols: auto Count = [M](const char *Name, FunctionNameType Type) -> int { SymbolContextList SymList; - return M->FindFunctionSymbols(ConstString(Name), Type, SymList); + M->FindFunctionSymbols(ConstString(Name), Type, SymList); + return SymList.GetSize(); }; // Unmangled diff --git a/lldb/unittests/Target/ModuleCacheTest.cpp b/lldb/unittests/Target/ModuleCacheTest.cpp index b754d14b6f81..bc8c878a5987 100644 --- a/lldb/unittests/Target/ModuleCacheTest.cpp +++ b/lldb/unittests/Target/ModuleCacheTest.cpp @@ -129,8 +129,9 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir, ASSERT_TRUE(bool(module_sp)); SymbolContextList sc_list; - EXPECT_EQ(1u, module_sp->FindFunctionSymbols(ConstString("boom"), - eFunctionNameTypeFull, sc_list)); + module_sp->FindFunctionSymbols(ConstString("boom"), eFunctionNameTypeFull, + sc_list); + EXPECT_EQ(1u, sc_list.GetSize()); EXPECT_STREQ(GetDummyRemotePath().GetCString(), module_sp->GetPlatformFileSpec().GetCString()); EXPECT_STREQ(module_uuid, module_sp->GetUUID().GetAsString().c_str());