Author: jingham
Date: Fri Sep 19 16:58:45 2014
New Revision: 218157

URL: http://llvm.org/viewvc/llvm-project?rev=218157&view=rev
Log:
Fix a thinko in how the RemoteiOS Platform looked up files in the SDK & other
platform locations.  We didn't always do an exhaustive search through all the 
platform locations, so we would have to read some files out of memory even 
though
they existed in the exploded shared cache or SDK.

<rdar://problem/18385947>

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

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=218157&r1=218156&r2=218157&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Fri Sep 19 
16:58:45 2014
@@ -688,84 +688,70 @@ PlatformRemoteiOS::GetSharedModule (cons
 
     FileSpec local_file;
     const UUID *module_uuid_ptr = module_spec.GetUUIDPtr();
-    Error error (GetSymbolFile (platform_file, module_uuid_ptr, local_file));
-    if (error.Success())
+    Error error;
+    char platform_file_path[PATH_MAX];
+    
+    if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
     {
-        error = ResolveExecutable (local_file, module_spec.GetArchitecture(), 
module_sp, NULL);
-        if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() 
== *module_uuid_ptr)))
-        {
-            //printf ("found in user specified SDK\n");
-            error.Clear();
-            return error;
-        }
-
-        char platform_file_path[PATH_MAX];
-        if (platform_file.GetPath(platform_file_path, 
sizeof(platform_file_path)))
+        FileSpec local_file;
+        const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+        // Try the last SDK index if it is set as most files from an SDK
+        // will tend to be valid in that same SDK.
+        if (m_last_module_sdk_idx < num_sdk_infos)
         {
-            FileSpec local_file;
-            const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
-            // Try the last SDK index if it is set as most files from an SDK
-            // will tend to be valid in that same SDK.
-            if (m_last_module_sdk_idx < num_sdk_infos)
+            if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, 
local_file))
             {
-                if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, 
local_file))
+                //printf ("sdk[%u] last: '%s'\n", m_last_module_sdk_idx, 
local_file.GetPath().c_str());
+                module_sp.reset();
+                error = ResolveExecutable (local_file,
+                                           module_spec.GetArchitecture(),
+                                           module_sp,
+                                           NULL);
+                if (module_sp && ((module_uuid_ptr == NULL) || 
(module_sp->GetUUID() == *module_uuid_ptr)))
                 {
-                    //printf ("sdk[%u] last: '%s'\n", m_last_module_sdk_idx, 
local_file.GetPath().c_str());
-                    module_sp.reset();
-                    error = ResolveExecutable (local_file,
-                                               module_spec.GetArchitecture(),
-                                               module_sp,
-                                               NULL);
-                    if (module_sp && ((module_uuid_ptr == NULL) || 
(module_sp->GetUUID() == *module_uuid_ptr)))
-                    {
-                        //printf ("sdk[%u] last found\n", 
m_last_module_sdk_idx);
-                        error.Clear();
-                        return error;
-                    }
+                    //printf ("sdk[%u] last found\n", m_last_module_sdk_idx);
+                    error.Clear();
+                    return error;
                 }
             }
-            
-            // First try for an exact match of major, minor and update
-            for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
+        }
+        
+        // First try for an exact match of major, minor and update
+        for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
+        {
+            if (m_last_module_sdk_idx == sdk_idx)
             {
-                if (m_last_module_sdk_idx == sdk_idx)
-                {
-                    // Skip the last module SDK index if we already searched
-                    // it above
-                    continue;
-                }
-                if (GetFileInSDK (platform_file_path, sdk_idx, local_file))
+                // Skip the last module SDK index if we already searched
+                // it above
+                continue;
+            }
+            if (GetFileInSDK (platform_file_path, sdk_idx, local_file))
+            {
+                //printf ("sdk[%u]: '%s'\n", sdk_idx, 
local_file.GetPath().c_str());
+                
+                error = ResolveExecutable (local_file,
+                                           module_spec.GetArchitecture(),
+                                           module_sp,
+                                           NULL);
+                if (module_sp && ((module_uuid_ptr == NULL) || 
(module_sp->GetUUID() == *module_uuid_ptr)))
                 {
-                    //printf ("sdk[%u]: '%s'\n", sdk_idx, 
local_file.GetPath().c_str());
-                    
-                    error = ResolveExecutable (local_file,
-                                               module_spec.GetArchitecture(),
-                                               module_sp,
-                                               NULL);
-                    if (module_sp && ((module_uuid_ptr == NULL) || 
(module_sp->GetUUID() == *module_uuid_ptr)))
-                    {
-                        // Remember the index of the last SDK that we found a 
file
-                        // in in case the wrong SDK was selected.
-                        m_last_module_sdk_idx = sdk_idx;
-                        //printf ("sdk[%u]: found (setting last to %u)\n", 
sdk_idx, m_last_module_sdk_idx);
-                        error.Clear();
-                        return error;
-                    }
+                    // Remember the index of the last SDK that we found a file
+                    // in in case the wrong SDK was selected.
+                    m_last_module_sdk_idx = sdk_idx;
+                    //printf ("sdk[%u]: found (setting last to %u)\n", 
sdk_idx, m_last_module_sdk_idx);
+                    error.Clear();
+                    return error;
                 }
             }
         }
-        // Not the module we are looking for... Nothing to see here...
-        module_sp.reset();
-    }
-    else
-    {
-        // This may not be an SDK-related module.  Try whether we can bring in 
the thing to our local cache.
-        error = GetSharedModuleWithLocalCache(module_spec, module_sp, 
module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
-        if (error.Success())
-            return error;
-        else
-            error.Clear(); // Clear the error and fall-through.
     }
+    // Not the module we are looking for... Nothing to see here...
+    module_sp.reset();
+
+    // This may not be an SDK-related module.  Try whether we can bring in the 
thing to our local cache.
+    error = GetSharedModuleWithLocalCache(module_spec, module_sp, 
module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
+    if (error.Success())
+        return error;
 
     const bool always_create = false;
     error = ModuleList::GetSharedModule (module_spec, 


_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to