diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 11 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h | 12 | ||||
-rw-r--r-- | lldb/source/Utility/ArchSpec.cpp | 5 | ||||
-rw-r--r-- | lldb/unittests/Platform/PlatformDarwinTest.cpp | 26 |
4 files changed, 41 insertions, 13 deletions
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 886e3b6d9a0..1665448fc5b 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1402,14 +1402,11 @@ bool PlatformDarwin::SDKSupportsModules(SDKType desired_type, if (last_path_component) { const llvm::StringRef sdk_name = last_path_component.GetStringRef(); - llvm::StringRef version_part; - - if (sdk_name.startswith(sdk_strings[(int)desired_type])) { - version_part = - sdk_name.drop_front(strlen(sdk_strings[(int)desired_type])); - } else { + if (!sdk_name.startswith(sdk_strings[(int)desired_type])) return false; - } + auto version_part = + sdk_name.drop_front(strlen(sdk_strings[(int)desired_type])); + version_part.consume_back(".sdk"); llvm::VersionTuple version; if (version.tryParse(version_part)) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 3ad29ec1a0b..60603103a9e 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -85,6 +85,12 @@ public: static std::tuple<llvm::VersionTuple, llvm::StringRef> ParseVersionBuildDir(llvm::StringRef str); + enum class SDKType { + MacOSX = 0, + iPhoneSimulator, + iPhoneOS, + }; + protected: void ReadLibdispatchOffsetsAddress(lldb_private::Process *process); @@ -95,12 +101,6 @@ protected: const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr); - enum class SDKType { - MacOSX = 0, - iPhoneSimulator, - iPhoneOS, - }; - static bool SDKSupportsModules(SDKType sdk_type, llvm::VersionTuple version); static bool SDKSupportsModules(SDKType desired_type, diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index df1029e7c6d..26f1421f657 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -1029,6 +1029,11 @@ static bool isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, rhs == llvm::Triple::UnknownEnvironment) return true; + // If any of the environment is unknown then they are compatible + if (lhs == llvm::Triple::UnknownEnvironment || + rhs == llvm::Triple::UnknownEnvironment) + return true; + // If one of the environment is Android and the other one is EABI then they // are considered to be compatible. This is required as a workaround for // shared libraries compiled for Android without the NOTE section indicating diff --git a/lldb/unittests/Platform/PlatformDarwinTest.cpp b/lldb/unittests/Platform/PlatformDarwinTest.cpp index 18cd1b76997..c0a9aef99ef 100644 --- a/lldb/unittests/Platform/PlatformDarwinTest.cpp +++ b/lldb/unittests/Platform/PlatformDarwinTest.cpp @@ -18,6 +18,13 @@ using namespace lldb; using namespace lldb_private; +struct PlatformDarwinTester : public PlatformDarwin { + static bool SDKSupportsModules(SDKType desired_type, + const lldb_private::FileSpec &sdk_path) { + return PlatformDarwin::SDKSupportsModules(desired_type, sdk_path); + } +}; + TEST(PlatformDarwinTest, TestParseVersionBuildDir) { llvm::VersionTuple V; llvm::StringRef D; @@ -44,4 +51,23 @@ TEST(PlatformDarwinTest, TestParseVersionBuildDir) { std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5"); EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V); + + std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/"; + EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules( + PlatformDarwin::SDKType::iPhoneSimulator, + FileSpec(base + + "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk", + false))); + EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules( + PlatformDarwin::SDKType::iPhoneSimulator, + FileSpec(base + + "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk", + false))); + EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules( + PlatformDarwin::SDKType::MacOSX, + FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk", + false))); + EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules( + PlatformDarwin::SDKType::MacOSX, + FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk", false))); } |