[Lldb-commits] [lldb] r345274 - Fix a bug PlatformDarwin::SDKSupportsModule.
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 25 08:30:43 PDT 2018
Author: adrian
Date: Thu Oct 25 08:30:43 2018
New Revision: 345274
URL: http://llvm.org/viewvc/llvm-project?rev=345274&view=rev
Log:
Fix a bug PlatformDarwin::SDKSupportsModule.
This fixes a bug PlatformDarwin::SDKSupportsModule introduced by
https://reviews.llvm.org/D47889. VersionTuple::tryParse() can deal
with an optional third (micro) component, but the parse will fail when
there are extra characters after the version number (e.g.: trying to
parse the substring "12.0.sdk" out of "iPhoneSimulator12.0.sdk" fails
after that patch). Fixed here by stripping the ".sdk" suffix first.
(Part of) rdar://problem/45041492
Differential Revision https://reviews.llvm.org/D53677
Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/trunk/source/Utility/ArchSpec.cpp
lldb/trunk/unittests/Platform/PlatformDarwinTest.cpp
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=345274&r1=345273&r2=345274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Thu Oct 25 08:30:43 2018
@@ -1402,14 +1402,11 @@ bool PlatformDarwin::SDKSupportsModules(
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))
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=345274&r1=345273&r2=345274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Thu Oct 25 08:30:43 2018
@@ -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,
Modified: lldb/trunk/source/Utility/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchSpec.cpp?rev=345274&r1=345273&r2=345274&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ArchSpec.cpp (original)
+++ lldb/trunk/source/Utility/ArchSpec.cpp Thu Oct 25 08:30:43 2018
@@ -1029,6 +1029,11 @@ static bool isCompatibleEnvironment(llvm
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
Modified: lldb/trunk/unittests/Platform/PlatformDarwinTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Platform/PlatformDarwinTest.cpp?rev=345274&r1=345273&r2=345274&view=diff
==============================================================================
--- lldb/trunk/unittests/Platform/PlatformDarwinTest.cpp (original)
+++ lldb/trunk/unittests/Platform/PlatformDarwinTest.cpp Thu Oct 25 08:30:43 2018
@@ -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, TestParseVersio
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)));
}
More information about the lldb-commits
mailing list