Index: source/Plugins/Platform/MacOSX/PlatformDarwin.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -85,6 +85,12 @@ static std::tuple ParseVersionBuildDir(llvm::StringRef str); + enum class SDKType { + MacOSX = 0, + iPhoneSimulator, + iPhoneOS, + }; + protected: void ReadLibdispatchOffsetsAddress(lldb_private::Process *process); @@ -95,12 +101,6 @@ 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, Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1402,14 +1402,11 @@ 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)) Index: unittests/Platform/PlatformDarwinTest.cpp =================================================================== --- unittests/Platform/PlatformDarwinTest.cpp +++ 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 @@ 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))); }