-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] [darwin] Upstream a few DriverKit cases #126604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] [darwin] Upstream a few DriverKit cases #126604
Conversation
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
|
@llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) ChangesA DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up. Full diff: https://github.com/llvm/llvm-project/pull/126604.diff 8 Files Affected:
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index ab013e79047ea30..b8941dae0107838 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -168,8 +168,9 @@ DynamicLoader *DynamicLoaderDarwinKernel::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
- case llvm::Triple::XROS:
case llvm::Triple::BridgeOS:
+ case llvm::Triple::DriverKit:
+ case llvm::Triple::XROS:
if (triple_ref.getVendor() != llvm::Triple::Apple) {
return nullptr;
}
@@ -243,6 +244,7 @@ DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) {
Status read_err;
addr_t kernel_addresses_64[] = {
0xfffffff000002010ULL,
+ 0xfffffe0000004010ULL, // newest arm64 devices, large memory support
0xfffffff000004010ULL, // newest arm64 devices
0xffffff8000004010ULL, // 2014-2015-ish arm64 devices
0xffffff8000002010ULL, // oldest arm64 devices
@@ -1092,7 +1094,7 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() {
static ConstString arm64_T1Sz_value("gT1Sz");
const Symbol *symbol =
m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
- kext_summary_symbol, eSymbolTypeData);
+ kext_summary_symbol, eSymbolTypeAny);
if (symbol) {
m_kext_summary_header_ptr_addr = symbol->GetAddress();
// Update all image infos
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 14d05a1a4494cfe..f9b49c50355d5a1 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -419,6 +419,8 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
image_infos[i].os_type = llvm::Triple::WatchOS;
else if (os_name == "bridgeos")
image_infos[i].os_type = llvm::Triple::BridgeOS;
+ else if (os_name == "driverkit")
+ image_infos[i].os_type = llvm::Triple::DriverKit;
else if (os_name == "xros")
image_infos[i].os_type = llvm::Triple::XROS;
else if (os_name == "maccatalyst") {
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 5b11059bcc50cbb..08bef4999eb9adc 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -55,8 +55,9 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
- case llvm::Triple::XROS:
case llvm::Triple::BridgeOS:
+ case llvm::Triple::DriverKit:
+ case llvm::Triple::XROS:
create = triple_ref.getVendor() == llvm::Triple::Apple;
break;
default:
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 8fc77cbe1170129..b05ed1ce2c8230b 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -75,8 +75,9 @@ DynamicLoader *DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
- case llvm::Triple::XROS:
case llvm::Triple::BridgeOS:
+ case llvm::Triple::DriverKit:
+ case llvm::Triple::XROS:
create = triple_ref.getVendor() == llvm::Triple::Apple;
break;
default:
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 605e3d570496914..4fbead97e9c1afd 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -129,6 +129,7 @@ PlatformSP PlatformDarwinKernel::CreateInstance(bool force,
case llvm::Triple::XROS:
case llvm::Triple::TvOS:
case llvm::Triple::BridgeOS:
+ case llvm::Triple::DriverKit:
break;
// Only accept "vendor" for vendor if the host is Apple and it "unknown"
// wasn't specified (it was just returned because it was NOT specified)
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index e4324f0a52a2b3e..b23f64210cc80cf 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -62,8 +62,9 @@ SystemRuntime *SystemRuntimeMacOSX::CreateInstance(Process *process) {
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
- case llvm::Triple::XROS:
case llvm::Triple::BridgeOS:
+ case llvm::Triple::DriverKit:
+ case llvm::Triple::XROS:
create = triple_ref.getVendor() == llvm::Triple::Apple;
break;
default:
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index b13e8ff1ec373de..495215459336a75 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1040,6 +1040,12 @@ bool ArchSpec::IsMatch(const ArchSpec &rhs, MatchType match) const {
rhs_triple_os == llvm::Triple::IOS &&
rhs_triple_env == llvm::Triple::MacABI))
return true;
+ // x86_64-apple-driverkit, x86_64-apple-macosx are compatible, no match.
+ if ((lhs_triple_os == llvm::Triple::DriverKit &&
+ rhs_triple_os == llvm::Triple::MacOSX) ||
+ (lhs_triple_os == llvm::Triple::MacOSX &&
+ rhs_triple_os == llvm::Triple::DriverKit))
+ return true;
}
// x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp
index 74a4b48456b0168..2c78629849c642d 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -400,6 +400,12 @@ TEST(ArchSpecTest, Compatibility) {
B.MergeFrom(A);
ASSERT_TRUE(B.IsExactMatch(C));
}
+ {
+ ArchSpec A("x86_64-apple-driverkit19.0");
+ ArchSpec B("x86_64-apple-macosx10.15.0");
+ ASSERT_FALSE(A.IsExactMatch(B));
+ ASSERT_TRUE(A.IsCompatibleMatch(B));
+ }
}
TEST(ArchSpecTest, OperatorBool) {
|
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.