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
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b00ecd7..40a88fb 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -931,6 +931,11 @@
return m_os_version;
}
+llvm::VersionTuple GDBRemoteCommunicationClient::GetMacCatalystVersion() {
+ GetHostInfo();
+ return m_maccatalyst_version;
+}
+
bool GDBRemoteCommunicationClient::GetOSBuildString(std::string &s) {
if (GetHostInfo()) {
if (!m_os_build.empty()) {
@@ -1133,6 +1138,7 @@
uint32_t sub = 0;
std::string arch_name;
std::string os_name;
+ std::string environment;
std::string vendor_name;
std::string triple;
std::string distribution_id;
@@ -1172,7 +1178,11 @@
extractor.GetHexByteString(m_os_kernel);
++num_keys_decoded;
} else if (name.equals("ostype")) {
- os_name = value;
+ if (value.equals("maccatalyst")) {
+ os_name = "ios";
+ environment = "macabi";
+ } else
+ os_name = value;
++num_keys_decoded;
} else if (name.equals("vendor")) {
vendor_name = value;
@@ -1196,6 +1206,9 @@
{
if (!m_os_version.tryParse(value))
++num_keys_decoded;
+ } else if (name.equals("maccatalyst_version")) {
+ if (!m_maccatalyst_version.tryParse(value))
+ ++num_keys_decoded;
} else if (name.equals("watchpoint_exceptions_received")) {
m_watchpoints_trigger_after_instruction =
llvm::StringSwitch<LazyBool>(value)
@@ -1233,6 +1246,8 @@
llvm::StringRef(vendor_name));
if (!os_name.empty())
m_host_arch.GetTriple().setOSName(llvm::StringRef(os_name));
+ if (!environment.empty())
+ m_host_arch.GetTriple().setEnvironmentName(environment);
}
} else {
std::string triple;
@@ -1985,6 +2000,7 @@
uint32_t sub = 0;
std::string arch_name;
std::string os_name;
+ std::string environment;
std::string vendor_name;
std::string triple;
std::string elf_abi;
@@ -2005,7 +2021,11 @@
extractor.GetHexByteString(triple);
++num_keys_decoded;
} else if (name.equals("ostype")) {
- os_name = value;
+ if (value.equals("maccatalyst")) {
+ os_name = "ios";
+ environment = "macabi";
+ } else
+ os_name = value;
++num_keys_decoded;
} else if (name.equals("vendor")) {
vendor_name = value;
@@ -2046,6 +2066,8 @@
} else if (cpu != LLDB_INVALID_CPUTYPE && !os_name.empty() &&
!vendor_name.empty()) {
llvm::Triple triple(llvm::Twine("-") + vendor_name + "-" + os_name);
+ if (!environment.empty())
+ triple.setEnvironmentName(environment);
assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat);
assert(triple.getObjectFormat() != llvm::Triple::Wasm);
@@ -2077,8 +2099,10 @@
}
m_process_arch.GetTriple().setVendorName(llvm::StringRef(vendor_name));
m_process_arch.GetTriple().setOSName(llvm::StringRef(os_name));
+ m_process_arch.GetTriple().setEnvironmentName(llvm::StringRef(environment));
m_host_arch.GetTriple().setVendorName(llvm::StringRef(vendor_name));
m_host_arch.GetTriple().setOSName(llvm::StringRef(os_name));
+ m_host_arch.GetTriple().setEnvironmentName(llvm::StringRef(environment));
}
return true;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index de85c9f..daee680 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -248,6 +248,8 @@
llvm::VersionTuple GetOSVersion();
+ llvm::VersionTuple GetMacCatalystVersion();
+
bool GetOSBuildString(std::string &s);
bool GetOSKernelDescription(std::string &s);
@@ -548,6 +550,7 @@
ArchSpec m_host_arch;
ArchSpec m_process_arch;
llvm::VersionTuple m_os_version;
+ llvm::VersionTuple m_maccatalyst_version;
std::string m_os_build;
std::string m_os_kernel;
std::string m_hostname;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 7c84bf4..d0ae519 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -260,6 +260,15 @@
response.PutChar(';');
}
+#if defined(__APPLE__)
+ llvm::VersionTuple maccatalyst_version = HostInfo::GetMacCatalystVersion();
+ if (!maccatalyst_version.empty()) {
+ response.Format("maccatalyst_version:{0}",
+ maccatalyst_version.getAsString());
+ response.PutChar(';');
+ }
+#endif
+
std::string s;
if (HostInfo::GetOSBuildString(s)) {
response.PutCString("os_build:");
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 69bcd8a..fee7b3f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4320,6 +4320,10 @@
return m_gdb_comm.GetOSVersion();
}
+llvm::VersionTuple ProcessGDBRemote::GetHostMacCatalystVersion() {
+ return m_gdb_comm.GetMacCatalystVersion();
+}
+
namespace {
typedef std::vector<std::string> stringVec;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 1411469..84004c1 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -199,6 +199,7 @@
const llvm::Triple &triple) override;
llvm::VersionTuple GetHostOSVersion() override;
+ llvm::VersionTuple GetHostMacCatalystVersion() override;
llvm::Error LoadModules() override;