diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index b5cf0d62b976f..af873339e002e 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1208,35 +1208,44 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp, bool DynamicLoaderDarwin::UseDYLDSPI(Process *process) { Log *log = GetLog(LLDBLog::DynamicLoader); - bool use_new_spi_interface = false; + bool use_new_spi_interface = true; llvm::VersionTuple version = process->GetHostOSVersion(); if (!version.empty()) { const llvm::Triple::OSType os_type = process->GetTarget().GetArchitecture().GetTriple().getOS(); - // macOS 10.12 and newer - if (os_type == llvm::Triple::MacOSX && - version >= llvm::VersionTuple(10, 12)) - use_new_spi_interface = true; + // Older than macOS 10.12 + if (os_type == llvm::Triple::MacOSX && version < llvm::VersionTuple(10, 12)) + use_new_spi_interface = false; - // iOS 10 and newer - if (os_type == llvm::Triple::IOS && version >= llvm::VersionTuple(10)) - use_new_spi_interface = true; + // Older than iOS 10 + if (os_type == llvm::Triple::IOS && version < llvm::VersionTuple(10)) + use_new_spi_interface = false; - // tvOS 10 and newer - if (os_type == llvm::Triple::TvOS && version >= llvm::VersionTuple(10)) - use_new_spi_interface = true; + // Older than tvOS 10 + if (os_type == llvm::Triple::TvOS && version < llvm::VersionTuple(10)) + use_new_spi_interface = false; - // watchOS 3 and newer - if (os_type == llvm::Triple::WatchOS && version >= llvm::VersionTuple(3)) - use_new_spi_interface = true; + // Older than watchOS 3 + if (os_type == llvm::Triple::WatchOS && version < llvm::VersionTuple(3)) + use_new_spi_interface = false; - // NEED_BRIDGEOS_TRIPLE // Any BridgeOS - // NEED_BRIDGEOS_TRIPLE if (os_type == llvm::Triple::BridgeOS) - // NEED_BRIDGEOS_TRIPLE use_new_spi_interface = true; + // llvm::Triple::BridgeOS and llvm::Triple::XROS always use the new + // libdyld SPI interface. + } else { + // We could not get an OS version string, we are likely not + // connected to debugserver and the packets to call the libdyld SPI + // will not exist. + use_new_spi_interface = false; } + // Corefiles cannot use the libdyld SPI to get the inferior's + // binaries, we must find it through metadata or a scan + // of the corefile memory. + if (!process->IsLiveDebugSession()) + use_new_spi_interface = false; + if (log) { if (use_new_spi_interface) LLDB_LOGF(