diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 015d363362f43..a6b48702e72fa 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -424,6 +424,8 @@ void ModuleList::FindFunctionSymbols(ConstString name, void ModuleList::FindFunctions(const RegularExpression &name, bool include_symbols, bool include_inlines, SymbolContextList &sc_list) { + const size_t initial_size = sc_list.GetSize(); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); collection dylinker_modules; @@ -504,6 +506,8 @@ void ModuleList::FindSymbolsWithNameAndType(ConstString name, SymbolType symbol_type, SymbolContextList &sc_list) const { std::lock_guard guard(m_modules_mutex); + const size_t initial_size = sc_list.GetSize(); + collection::const_iterator pos, end = m_modules.end(); collection dylinker_modules; for (pos = m_modules.begin(); pos != end; ++pos) { @@ -528,6 +532,8 @@ void ModuleList::FindSymbolsMatchingRegExAndType( const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const { std::lock_guard guard(m_modules_mutex); + const size_t initial_size = sc_list.GetSize(); + collection::const_iterator pos, end = m_modules.end(); collection dylinker_modules; for (pos = m_modules.begin(); pos != end; ++pos) { diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index c356cd5d0638a..e50b5c329d03b 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -334,10 +334,10 @@ static lldb_private::LineEntry FindEntryPoint(Module *exe_module) { SymbolContextList sc_list; bool symbols_okay = false; // Force it to be a debug symbol. bool inlines_okay = true; - bool append = false; - size_t num_matches = exe_module->FindFunctions( - entry_point_name, NULL, lldb::eFunctionNameTypeBase, inlines_okay, - symbols_okay, append, sc_list); + exe_module->FindFunctions(entry_point_name, NULL, + 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/Symbol/SwiftASTContext.cpp b/lldb/source/Symbol/SwiftASTContext.cpp index 990ceb0911985..d29479390e73e 100644 --- a/lldb/source/Symbol/SwiftASTContext.cpp +++ b/lldb/source/Symbol/SwiftASTContext.cpp @@ -3846,8 +3846,9 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module, module_spec.GetFileSpec().GetFilename() = library_cstr; lldb_private::ModuleList matching_module_list; bool module_already_loaded = false; - if (process.GetTarget().GetImages().FindModules(module_spec, - matching_module_list)) { + process.GetTarget().GetImages().FindModules(module_spec, + matching_module_list); + if (!matching_module_list.IsEmpty()) { matching_module_list.ForEach( [&module_already_loaded, &module_spec, &framework_name](const ModuleSP &module_sp) -> bool { @@ -4037,8 +4038,9 @@ bool SwiftASTContext::LoadLibraryUsingPaths( module_spec.GetFileSpec().GetFilename().SetCString(library_fullname.c_str()); lldb_private::ModuleList matching_module_list; - if (process.GetTarget().GetImages().FindModules(module_spec, - matching_module_list) > 0) { + process.GetTarget().GetImages().FindModules(module_spec, + matching_module_list); + if (!matching_module_list.IsEmpty()) { LOG_PRINTF(LIBLLDB_LOG_TYPES, "Skipping module %s as it is already loaded.", library_fullname.c_str()); return true; diff --git a/lldb/source/Target/SwiftLanguageRuntime.cpp b/lldb/source/Target/SwiftLanguageRuntime.cpp index f68afeebc24a8..d1f8b79371862 100644 --- a/lldb/source/Target/SwiftLanguageRuntime.cpp +++ b/lldb/source/Target/SwiftLanguageRuntime.cpp @@ -192,8 +192,8 @@ FindSymbolForSwiftObject(Target &target, ConstString object, llvm::Optional retval; SymbolContextList sc_list; - if (target.GetImages().FindSymbolsWithNameAndType(object, sym_type, - sc_list)) { + target.GetImages().FindSymbolsWithNameAndType(object, sym_type, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext SwiftObject_Class; if (sc_list.GetSize() == 1 && sc_list.GetContextAtIndex(0, SwiftObject_Class)) { @@ -965,8 +965,9 @@ class LLDBMemoryReader : public swift::remote::MemoryReader { ConstString name_cs(name.c_str(), name.size()); SymbolContextList sc_list; - if (!m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( - name_cs, lldb::eSymbolTypeAny, sc_list)) { + m_process->GetTarget().GetImages().FindSymbolsWithNameAndType( + name_cs, lldb::eSymbolTypeAny, sc_list); + if (sc_list.IsEmpty()) { LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES), "[MemoryReader] symbol resoution failed {0}", name); return swift::remote::RemoteAddress(nullptr); @@ -2516,8 +2517,10 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc, std::string apply_target = demangle_ctx.getThunkTarget(apply_name.GetStringRef()); if (!apply_target.empty()) { - size_t num_symbols = curr_sc.module_sp->FindFunctions( - ConstString(apply_target), NULL, eFunctionNameTypeFull, true, false, false, sc_list); + curr_sc.module_sp->FindFunctions(ConstString(apply_target), NULL, + eFunctionNameTypeFull, true, false, + sc_list); + size_t num_symbols = sc_list.GetSize(); if (num_symbols == 0) return false; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 106a9b91109e7..ed2b5b3ac5596 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3085,8 +3085,8 @@ lldb::addr_t Target::FindLoadAddrForNameInSymbolsAndPersistentVariables( lldb::addr_t symbol_addr = LLDB_INVALID_ADDRESS; SymbolContextList sc_list; - if (GetImages().FindSymbolsWithNameAndType(name_const_str, symbol_type, - sc_list)) { + GetImages().FindSymbolsWithNameAndType(name_const_str, symbol_type, sc_list); + if (!sc_list.IsEmpty()) { SymbolContext desired_symbol; if (sc_list.GetSize() == 1 &&