Skip to content

Commit 800de3e

Browse files
jasonmolendaIcohedron
authored andcommitted
[lldb][Darwin] Change DynamicLoaderDarwin to default to new SPI (llvm#126171)
In Sep 2016 and newer Darwin releases, debugserver uses libdyld SPI to gather information about the binaries loaded in a process. Before Sep 2016, lldb would inspect the dyld internal data structures directly itself to find this information. DynamicLoaderDarwin::UseDYLDSPI currently defaults to the old inspect-dyld-internal-structures method for binaries (DynamicLoaderMacOSXDYLD). If it detects that the Process' host OS version is new enough, it enables the newer libdyld SPI methods in debugserver (DynamicLoaderMacOS). This patch changes the default to use the new libdyld SPI interfaces. If the Process has a HostOS and it is one of the four specific OSes that existed in 2015 (Mac OS X, iOS, tvOS, watchOS) with an old version number, then we will enable the old DynamicLoader plugin. If this debug session is a corefile, we will always use the old DynamicLoader plugin -- the libdyld SPI cannot run against a corefile, lldb must read metadata or the dyld internal data structures in the corefile to find the loaded binaries.
1 parent 15a85a8 commit 800de3e

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

+26-17
Original file line numberDiff line numberDiff line change
@@ -1208,35 +1208,44 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp,
12081208

12091209
bool DynamicLoaderDarwin::UseDYLDSPI(Process *process) {
12101210
Log *log = GetLog(LLDBLog::DynamicLoader);
1211-
bool use_new_spi_interface = false;
1211+
bool use_new_spi_interface = true;
12121212

12131213
llvm::VersionTuple version = process->GetHostOSVersion();
12141214
if (!version.empty()) {
12151215
const llvm::Triple::OSType os_type =
12161216
process->GetTarget().GetArchitecture().GetTriple().getOS();
12171217

1218-
// macOS 10.12 and newer
1219-
if (os_type == llvm::Triple::MacOSX &&
1220-
version >= llvm::VersionTuple(10, 12))
1221-
use_new_spi_interface = true;
1218+
// Older than macOS 10.12
1219+
if (os_type == llvm::Triple::MacOSX && version < llvm::VersionTuple(10, 12))
1220+
use_new_spi_interface = false;
12221221

1223-
// iOS 10 and newer
1224-
if (os_type == llvm::Triple::IOS && version >= llvm::VersionTuple(10))
1225-
use_new_spi_interface = true;
1222+
// Older than iOS 10
1223+
if (os_type == llvm::Triple::IOS && version < llvm::VersionTuple(10))
1224+
use_new_spi_interface = false;
12261225

1227-
// tvOS 10 and newer
1228-
if (os_type == llvm::Triple::TvOS && version >= llvm::VersionTuple(10))
1229-
use_new_spi_interface = true;
1226+
// Older than tvOS 10
1227+
if (os_type == llvm::Triple::TvOS && version < llvm::VersionTuple(10))
1228+
use_new_spi_interface = false;
12301229

1231-
// watchOS 3 and newer
1232-
if (os_type == llvm::Triple::WatchOS && version >= llvm::VersionTuple(3))
1233-
use_new_spi_interface = true;
1230+
// Older than watchOS 3
1231+
if (os_type == llvm::Triple::WatchOS && version < llvm::VersionTuple(3))
1232+
use_new_spi_interface = false;
12341233

1235-
// NEED_BRIDGEOS_TRIPLE // Any BridgeOS
1236-
// NEED_BRIDGEOS_TRIPLE if (os_type == llvm::Triple::BridgeOS)
1237-
// NEED_BRIDGEOS_TRIPLE use_new_spi_interface = true;
1234+
// llvm::Triple::BridgeOS and llvm::Triple::XROS always use the new
1235+
// libdyld SPI interface.
1236+
} else {
1237+
// We could not get an OS version string, we are likely not
1238+
// connected to debugserver and the packets to call the libdyld SPI
1239+
// will not exist.
1240+
use_new_spi_interface = false;
12381241
}
12391242

1243+
// Corefiles cannot use the libdyld SPI to get the inferior's
1244+
// binaries, we must find it through metadata or a scan
1245+
// of the corefile memory.
1246+
if (!process->IsLiveDebugSession())
1247+
use_new_spi_interface = false;
1248+
12401249
if (log) {
12411250
if (use_new_spi_interface)
12421251
LLDB_LOGF(

0 commit comments

Comments
 (0)