Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -732,12 +732,14 @@ ModuleSpec module_spec(process_info.GetExecutableFile(), process_info.GetArchitecture()); + if (module_sp && module_sp->MatchesModuleSpec(module_spec)) return; + lldb::ModuleSP executable_module_sp; const auto executable_search_paths(Target::GetDefaultExecutableSearchPaths()); auto error = platform_sp->ResolveExecutable( - module_spec, module_sp, + module_spec, executable_module_sp, !executable_search_paths.IsEmpty() ? &executable_search_paths : nullptr); if (error.Fail()) { StreamString stream; @@ -750,7 +752,8 @@ return; } - target.SetExecutableModule(module_sp, eLoadDependentsNo); + if (!module_sp || module_sp.get() != executable_module_sp.get()) + target.SetExecutableModule(executable_module_sp, eLoadDependentsNo); } bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo( Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -107,9 +107,9 @@ } } else { if (m_remote_platform_sp) { - error = - GetCachedExecutable(resolved_module_spec, exe_module_sp, - module_search_paths_ptr, *m_remote_platform_sp); + return GetCachedExecutable(resolved_module_spec, exe_module_sp, + module_search_paths_ptr, + *m_remote_platform_sp); } else { // We may connect to a process and use the provided executable (Don't use // local $PATH). @@ -133,8 +133,8 @@ module_search_paths_ptr, nullptr, nullptr); if (error.Fail()) { // If we failed, it may be because the vendor and os aren't known. If - // that is the case, try setting them to the host architecture and give - // it another try. + // that is the case, try setting them to the host architecture and give + // it another try. llvm::Triple &module_triple = resolved_module_spec.GetArchitecture().GetTriple(); bool is_vendor_specified = Index: lldb/source/Target/TargetList.cpp =================================================================== --- lldb/source/Target/TargetList.cpp +++ lldb/source/Target/TargetList.cpp @@ -398,6 +398,8 @@ if (user_exe_path_is_bundle) exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path, sizeof(resolved_bundle_exe_path)); + if (target_sp->GetPreloadSymbols()) + exe_module_sp->PreloadSymbols(); } } else { // No file was specified, just create an empty target with any arch if a