[Lldb-commits] [lldb] r155683 - /lldb/trunk/source/Target/Target.cpp

Greg Clayton gclayton at apple.com
Thu Apr 26 17:58:27 PDT 2012


Author: gclayton
Date: Thu Apr 26 19:58:27 2012
New Revision: 155683

URL: http://llvm.org/viewvc/llvm-project?rev=155683&view=rev
Log:
Clean up the way modules are looked for when calling Target::GetSharedModule(...). We were ignoring remapped files, even if they were valid. Also if we have a  UUID, we should check our global module list first.


Modified:
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=155683&r1=155682&r2=155683&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Apr 26 19:58:27 2012
@@ -1318,21 +1318,45 @@
                                                  &did_create_module);
         }
     }
-
-    // The platform is responsible for finding and caching an appropriate
-    // module in the shared module cache.
-    if (m_platform_sp)
-    {
-        FileSpec platform_file_spec;        
-        error = m_platform_sp->GetSharedModule (module_spec, 
-                                                module_sp, 
-                                                &GetExecutableSearchPaths(),
-                                                &old_module_sp, 
-                                                &did_create_module);
-    }
-    else
+    
+    if (!module_sp)
     {
-        error.SetErrorString("no platform is currently set");
+        // If we have a UUID, we can check our global shared module list in case
+        // we already have it. If we don't have a valid UUID, then we can't since
+        // the path in "module_spec" will be a platform path, and we will need to
+        // let the platform find that file. For example, we could be asking for
+        // "/usr/lib/dyld" and if we do not have a UUID, we don't want to pick
+        // the local copy of "/usr/lib/dyld" since our platform could be a remote
+        // platform that has its own "/usr/lib/dyld" in an SDK or in a local file
+        // cache.
+        if (module_spec.GetUUID().IsValid())
+        {
+            // We have a UUID, it is OK to check the global module list...
+            error = ModuleList::GetSharedModule (module_spec,
+                                                 module_sp, 
+                                                 &GetExecutableSearchPaths(),
+                                                 &old_module_sp, 
+                                                 &did_create_module);
+        }
+
+        if (!module_sp)
+        {
+            // The platform is responsible for finding and caching an appropriate
+            // module in the shared module cache.
+            if (m_platform_sp)
+            {
+                FileSpec platform_file_spec;        
+                error = m_platform_sp->GetSharedModule (module_spec, 
+                                                        module_sp, 
+                                                        &GetExecutableSearchPaths(),
+                                                        &old_module_sp, 
+                                                        &did_create_module);
+            }
+            else
+            {
+                error.SetErrorString("no platform is currently set");
+            }
+        }
     }
 
     // If a module hasn't been found yet, use the unmodified path.





More information about the lldb-commits mailing list