aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/DynamicLoader
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-09-04 17:23:15 +0000
committerAdrian Prantl <aprantl@apple.com>2019-09-04 17:23:15 +0000
commit2461061168f4ac4ca8a1823768a00d1c63355b1b (patch)
tree4e38a76bbb1f43efde95d83428162d3cafeb3469 /lldb/source/Plugins/DynamicLoader
parent40fe351cf699eda8d7d9a72c7bbbb37cef7f3164 (diff)
downloadllvm-2461061168f4ac4ca8a1823768a00d1c63355b1b.tar.gz
llvm-2461061168f4ac4ca8a1823768a00d1c63355b1b.tar.bz2
llvm-2461061168f4ac4ca8a1823768a00d1c63355b1b.zip
Upstream macCatalyst support in debugserver and the macOS dynamic loader
plugin. Unfortunately the test is currently XFAILed because of missing changes to the clang driver. Differential Revision: https://reviews.llvm.org/D67124 llvm-svn: 370931
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader')
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp44
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h56
2 files changed, 76 insertions, 24 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 61afe51034ee..9ec4ae0d45e0 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -100,6 +100,18 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo(
const ModuleList &target_images = target.GetImages();
ModuleSpec module_spec(image_info.file_spec);
module_spec.GetUUID() = image_info.uuid;
+
+ // macCatalyst support: Request matching os/environment.
+ {
+ auto &target_triple = target.GetArchitecture().GetTriple();
+ if (target_triple.getOS() == llvm::Triple::IOS &&
+ target_triple.getEnvironment() == llvm::Triple::MacABI) {
+ // Request the macCatalyst variant of frameworks that have both
+ // a PLATFORM_MACOS and a PLATFORM_MACCATALYST load command.
+ module_spec.GetArchitecture() = ArchSpec(target_triple);
+ }
+ }
+
ModuleSP module_sp(target_images.FindFirstModule(module_spec));
if (module_sp && !module_spec.GetUUID().IsValid() &&
@@ -384,6 +396,10 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
image_infos[i].os_type = llvm::Triple::WatchOS;
// NEED_BRIDGEOS_TRIPLE else if (os_name == "bridgeos")
// NEED_BRIDGEOS_TRIPLE image_infos[i].os_type = llvm::Triple::BridgeOS;
+ else if (os_name == "maccatalyst") {
+ image_infos[i].os_type = llvm::Triple::IOS;
+ image_infos[i].os_env = llvm::Triple::MacABI;
+ }
}
if (image->HasKey("min_version_os_sdk")) {
image_infos[i].min_version_os_sdk =
@@ -654,6 +670,20 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos(
target_images.AppendIfNeeded(image_module_sp);
loaded_module_list.AppendIfNeeded(image_module_sp);
}
+
+ // macCataylst support:
+ // Update the module's platform with the DYLD info.
+ ArchSpec dyld_spec = image_infos[idx].GetArchitecture();
+ if (dyld_spec.GetTriple().getOS() == llvm::Triple::IOS &&
+ dyld_spec.GetTriple().getEnvironment() == llvm::Triple::MacABI) {
+ image_module_sp->MergeArchitecture(dyld_spec);
+ const auto &target_triple = target.GetArchitecture().GetTriple();
+ // If dyld reports the process as being loaded as MACCATALYST,
+ // force-update the target's architecture to MACCATALYST.
+ if (!(target_triple.getOS() == llvm::Triple::IOS &&
+ target_triple.getEnvironment() == llvm::Triple::MacABI))
+ target.SetArchitecture(dyld_spec);
+ }
}
}
@@ -711,6 +741,20 @@ void DynamicLoaderDarwin::Segment::PutToLog(Log *log,
}
}
+lldb_private::ArchSpec DynamicLoaderDarwin::ImageInfo::GetArchitecture() const {
+ // Update the module's platform with the DYLD info.
+ lldb_private::ArchSpec arch_spec(lldb_private::eArchTypeMachO, header.cputype,
+ header.cpusubtype);
+ if (os_type == llvm::Triple::IOS && os_env == llvm::Triple::MacABI) {
+ llvm::Triple triple(llvm::Twine("x86_64-apple-ios") + min_version_os_sdk +
+ "-macabi");
+ ArchSpec maccatalyst_spec(triple);
+ if (arch_spec.IsCompatibleMatch(maccatalyst_spec))
+ arch_spec.MergeFrom(maccatalyst_spec);
+ }
+ return arch_spec;
+}
+
const DynamicLoaderDarwin::Segment *
DynamicLoaderDarwin::ImageInfo::FindSegment(ConstString name) const {
const size_t num_segments = segments.size();
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index aac0a5dc26a0..f2c78d4278ed 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -95,25 +95,34 @@ protected:
};
struct ImageInfo {
- lldb::addr_t address; // Address of mach header for this dylib
- lldb::addr_t slide; // The amount to slide all segments by if there is a
- // global slide.
- lldb::addr_t mod_date; // Modification date for this dylib
- lldb_private::FileSpec file_spec; // Resolved path for this dylib
- lldb_private::UUID
- uuid; // UUID for this dylib if it has one, else all zeros
- llvm::MachO::mach_header header; // The mach header for this image
- std::vector<Segment> segments; // All segment vmaddr and vmsize pairs for
- // this executable (from memory of inferior)
- uint32_t load_stop_id; // The process stop ID that the sections for this
- // image were loaded
- llvm::Triple::OSType os_type; // LC_VERSION_MIN_... load command os type
- std::string min_version_os_sdk; // LC_VERSION_MIN_... sdk value
-
- ImageInfo()
- : address(LLDB_INVALID_ADDRESS), slide(0), mod_date(0), file_spec(),
- uuid(), header(), segments(), load_stop_id(0),
- os_type(llvm::Triple::OSType::UnknownOS), min_version_os_sdk() {}
+ /// Address of mach header for this dylib.
+ lldb::addr_t address = LLDB_INVALID_ADDRESS;
+ /// The amount to slide all segments by if there is a global
+ /// slide.
+ lldb::addr_t slide = 0;
+ /// Modification date for this dylib.
+ lldb::addr_t mod_date = 0;
+ /// Resolved path for this dylib.
+ lldb_private::FileSpec file_spec;
+ /// UUID for this dylib if it has one, else all zeros.
+ lldb_private::UUID uuid;
+ /// The mach header for this image.
+ llvm::MachO::mach_header header;
+ /// All segment vmaddr and vmsize pairs for this executable (from
+ /// memory of inferior).
+ std::vector<Segment> segments;
+ /// The process stop ID that the sections for this image were
+ /// loaded.
+ uint32_t load_stop_id = 0;
+ /// LC_VERSION_MIN_... load command os type.
+ llvm::Triple::OSType os_type = llvm::Triple::OSType::UnknownOS;
+ /// LC_VERSION_MIN_... load command os environment.
+ llvm::Triple::EnvironmentType os_env =
+ llvm::Triple::EnvironmentType::UnknownEnvironment;
+ /// LC_VERSION_MIN_... SDK.
+ std::string min_version_os_sdk;
+
+ ImageInfo() = default;
void Clear(bool load_cmd_data_only) {
if (!load_cmd_data_only) {
@@ -127,6 +136,7 @@ protected:
segments.clear();
load_stop_id = 0;
os_type = llvm::Triple::OSType::UnknownOS;
+ os_env = llvm::Triple::EnvironmentType::UnknownEnvironment;
min_version_os_sdk.clear();
}
@@ -135,7 +145,8 @@ protected:
mod_date == rhs.mod_date && file_spec == rhs.file_spec &&
uuid == rhs.uuid &&
memcmp(&header, &rhs.header, sizeof(header)) == 0 &&
- segments == rhs.segments && os_type == rhs.os_type;
+ segments == rhs.segments && os_type == rhs.os_type &&
+ os_env == rhs.os_env;
}
bool UUIDValid() const { return uuid.IsValid(); }
@@ -150,10 +161,7 @@ protected:
return 0;
}
- lldb_private::ArchSpec GetArchitecture() const {
- return lldb_private::ArchSpec(lldb_private::eArchTypeMachO,
- header.cputype, header.cpusubtype);
- }
+ lldb_private::ArchSpec GetArchitecture() const;
const Segment *FindSegment(lldb_private::ConstString name) const;