[Lldb-commits] [lldb] r232017 - Fix SDK selection using "platform select" when --sysroot/--version/--build options were specified

Ilia K ki.stfu at gmail.com
Thu Mar 12 00:21:25 PDT 2015


Author: ki.stfu
Date: Thu Mar 12 02:21:25 2015
New Revision: 232017

URL: http://llvm.org/viewvc/llvm-project?rev=232017&view=rev
Log:
Fix SDK selection using "platform select" when --sysroot/--version/--build options were specified

Summary:
This patch fixes SDK selection in the following case:
```
platform select remote-ios --sysroot "/Users/IliaK/Library/Developer/Xcode/iOS DeviceSupport/8.1.2 (12B440)" --build 12B440 --version 8.1.2
target create --arch arm64 "~/Project1.app"
```

Currently the lldb selects a first SDK version (in name order) in directory and then updates it after the device is connected. This approach ignores user's arguments and actually "platform select" command doesn't make sense.

After this patch, lldb takes a SDK which matches to user's arguments.

Reviewers: jasonmolenda, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, jasonmolenda, aemerson

Differential Revision: http://reviews.llvm.org/D8249

Modified:
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=232017&r1=232016&r2=232017&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Thu Mar 12 02:21:25 2015
@@ -304,6 +304,14 @@ PlatformRemoteiOS::UpdateSDKDirectoryInf
 {
     if (m_sdk_directory_infos.empty())
     {
+        // A --sysroot option was supplied - add it to our list of SDKs to check
+        if (m_sdk_sysroot)
+        {
+            FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true);
+            const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec);
+            m_sdk_directory_infos.push_back(sdk_sysroot_directory_info);
+            return true;
+        }
         const char *device_support_dir = GetDeviceSupportDirectory();
         if (device_support_dir)
         {
@@ -745,7 +753,28 @@ PlatformRemoteiOS::GetSharedModule (cons
             }
         }
         
-        // First try for an exact match of major, minor and update
+        // First try for an exact match of major, minor and update:
+        // If a particalar SDK version was specified via --version or --build, look for a match on disk.
+        const SDKDirectoryInfo *current_sdk_info = GetSDKDirectoryForCurrentOSVersion();
+        const uint32_t current_sdk_idx = GetSDKIndexBySDKDirectoryInfo(current_sdk_info);
+        if (current_sdk_idx < num_sdk_infos && current_sdk_idx != m_last_module_sdk_idx)
+        {
+            if (GetFileInSDK (platform_file_path, current_sdk_idx, platform_module_spec.GetFileSpec()))
+            {
+                module_sp.reset();
+                error = ResolveExecutable (platform_module_spec,
+                                           module_sp,
+                                           NULL);
+                if (module_sp)
+                {
+                    m_last_module_sdk_idx = current_sdk_idx;
+                    error.Clear();
+                    return error;
+                }
+            }
+        }
+
+        // Second try all SDKs that were found.
         for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
         {
             if (m_last_module_sdk_idx == sdk_idx)
@@ -827,3 +856,13 @@ PlatformRemoteiOS::GetConnectedSDKIndex
     return m_connected_module_sdk_idx;
 }
 
+uint32_t
+PlatformRemoteiOS::GetSDKIndexBySDKDirectoryInfo (const SDKDirectoryInfo *sdk_info)
+{
+    if (sdk_info == NULL)
+    {
+        return UINT32_MAX;
+    }
+
+    return sdk_info - &m_sdk_directory_infos[0];
+}

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=232017&r1=232016&r2=232017&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Thu Mar 12 02:21:25 2015
@@ -163,6 +163,10 @@ protected:
     uint32_t
     GetConnectedSDKIndex ();
 
+    // Get index of SDK in SDKDirectoryInfoCollection by its pointer and return UINT32_MAX if that SDK not found.
+    uint32_t
+    GetSDKIndexBySDKDirectoryInfo (const SDKDirectoryInfo *sdk_info);
+
 private:
     DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
 





More information about the lldb-commits mailing list