[Lldb-commits] [lldb] r155865 - in /lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX: PlatformDarwin.cpp PlatformDarwin.h PlatformMacOSX.cpp

Johnny Chen johnny.chen at apple.com
Mon Apr 30 17:11:46 PDT 2012


Author: johnny
Date: Mon Apr 30 19:11:45 2012
New Revision: 155865

URL: http://llvm.org/viewvc/llvm-project?rev=155865&view=rev
Log:
Move the PlatformMacOSX::GetSharedModule() impl up one level to PlatformDarwin() and rename it to
GetSharedModuleWithLocalCache() for PlatformRemoteiOS() to reuse.

Modified:
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.h
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=155865&r1=155864&r2=155865&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 30 19:11:45 2012
@@ -167,6 +167,134 @@
 }
 
 
+static lldb_private::Error
+MakeCacheFolderForFile (const FileSpec& module_cache_spec)
+{
+    FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
+    StreamString mkdir_folder_cmd;
+    mkdir_folder_cmd.Printf("mkdir -p %s/%s", module_cache_folder.GetDirectory().AsCString(), module_cache_folder.GetFilename().AsCString());
+    return Host::RunShellCommand(mkdir_folder_cmd.GetData(),
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          60);
+}
+
+static lldb_private::Error
+BringInRemoteFile (Platform* platform,
+                   const lldb_private::ModuleSpec &module_spec,
+                   const FileSpec& module_cache_spec)
+{
+    MakeCacheFolderForFile(module_cache_spec);
+    Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
+    return err;
+}
+
+lldb_private::Error
+PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &module_spec,
+                                               lldb::ModuleSP &module_sp,
+                                               const lldb_private::FileSpecList *module_search_paths_ptr,
+                                               lldb::ModuleSP *old_module_sp_ptr,
+                                               bool *did_create_ptr)
+{
+
+    printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n",
+           (IsHost() ? "host" : "remote"),
+           module_spec.GetFileSpec().GetDirectory().AsCString(),
+           module_spec.GetFileSpec().GetFilename().AsCString(),
+           module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
+           module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
+           module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
+           module_spec.GetSymbolFileSpec().GetFilename().AsCString());
+
+    std::string cache_path(GetLocalCacheDirectory());
+    std::string module_path;
+    module_spec.GetFileSpec().GetPath(module_path);
+    cache_path.append(module_path);
+    FileSpec module_cache_spec(cache_path.c_str(),false);
+    
+    // if rsync is supported, always bring in the file - rsync will be very efficient
+    // when files are the same on the local and remote end of the connection
+    if (this->GetSupportsRSync())
+    {
+        Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
+        if (err.Fail())
+            return err;
+        if (module_cache_spec.Exists())
+        {
+            printf("[%s] module %s/%s was rsynced and is now there\n",
+                   (IsHost() ? "host" : "remote"),
+                   module_spec.GetFileSpec().GetDirectory().AsCString(),
+                   module_spec.GetFileSpec().GetFilename().AsCString());
+            ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+            module_sp.reset(new Module(local_spec));
+            module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+            return Error();
+        }
+    }
+
+    if (module_spec.GetFileSpec().Exists() && !module_sp)
+    {
+        module_sp.reset(new Module(module_spec));
+        return Error();
+    }
+    
+    // try to find the module in the cache
+    if (module_cache_spec.Exists())
+    {
+        // get the local and remote MD5 and compare
+        {
+            // when going over the *slow* GDB remote transfer mechanism we first check
+            // the hashes of the files - and only do the actual transfer if they differ
+            uint64_t high_local,high_remote,low_local,low_remote;
+            Host::CalculateMD5 (module_cache_spec, low_local, high_local);
+            m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), low_remote, high_remote);
+            if (low_local != low_remote || high_local != high_remote)
+            {
+                // bring in the remote file
+                printf("[%s] module %s/%s needs to be replaced from remote copy\n",
+                       (IsHost() ? "host" : "remote"),
+                       module_spec.GetFileSpec().GetDirectory().AsCString(),
+                       module_spec.GetFileSpec().GetFilename().AsCString());
+                Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
+                if (err.Fail())
+                    return err;
+            }
+        }
+        
+        ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+        module_sp.reset(new Module(local_spec));
+        module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+        printf("[%s] module %s/%s was found in the cache\n",
+               (IsHost() ? "host" : "remote"),
+               module_spec.GetFileSpec().GetDirectory().AsCString(),
+               module_spec.GetFileSpec().GetFilename().AsCString());
+        return Error();
+    }
+    
+    // bring in the remote module file
+    printf("[%s] module %s/%s needs to come in remotely\n",
+           (IsHost() ? "host" : "remote"),
+           module_spec.GetFileSpec().GetDirectory().AsCString(),
+           module_spec.GetFileSpec().GetFilename().AsCString());
+    Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
+    if (err.Fail())
+        return err;
+    if (module_cache_spec.Exists())
+    {
+        printf("[%s] module %s/%s is now cached and fine\n",
+               (IsHost() ? "host" : "remote"),
+               module_spec.GetFileSpec().GetDirectory().AsCString(),
+               module_spec.GetFileSpec().GetFilename().AsCString());
+        ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+        module_sp.reset(new Module(local_spec));
+        module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+        return Error();
+    }
+    else
+        return Error("unable to obtain valid module file");
+}
 
 Error
 PlatformDarwin::GetSharedModule (const ModuleSpec &module_spec,

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=155865&r1=155864&r2=155865&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.h Mon Apr 30 19:11:45 2012
@@ -103,6 +103,13 @@
     x86GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
 
 protected:
+    virtual lldb_private::Error
+    GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &module_spec,
+                                   lldb::ModuleSP &module_sp,
+                                   const lldb_private::FileSpecList *module_search_paths_ptr,
+                                   lldb::ModuleSP *old_module_sp_ptr,
+                                   bool *did_create_ptr);
+
     std::string m_developer_directory;
     
     const char *

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=155865&r1=155864&r2=155865&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Mon Apr 30 19:11:45 2012
@@ -212,30 +212,6 @@
 #endif
 }
 
-static lldb_private::Error
-MakeCacheFolderForFile (const FileSpec& module_cache_spec)
-{
-    FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
-    StreamString mkdir_folder_cmd;
-    mkdir_folder_cmd.Printf("mkdir -p %s/%s", module_cache_folder.GetDirectory().AsCString(), module_cache_folder.GetFilename().AsCString());
-    return Host::RunShellCommand(mkdir_folder_cmd.GetData(),
-                          NULL,
-                          NULL,
-                          NULL,
-                          NULL,
-                          60);
-}
-
-static lldb_private::Error
-BringInRemoteFile (Platform* platform,
-                   const lldb_private::ModuleSpec &module_spec,
-                   const FileSpec& module_cache_spec)
-{
-    MakeCacheFolderForFile(module_cache_spec);
-    Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
-    return err;
-}
-
 lldb_private::Error
 PlatformMacOSX::GetSharedModule (const lldb_private::ModuleSpec &module_spec,
                                  lldb::ModuleSP &module_sp,
@@ -243,100 +219,5 @@
                                  lldb::ModuleSP *old_module_sp_ptr,
                                  bool *did_create_ptr)
 {
-
-    /*printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n",
-           (IsHost() ? "host" : "remote"),
-           module_spec.GetFileSpec().GetDirectory().AsCString(),
-           module_spec.GetFileSpec().GetFilename().AsCString(),
-           module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
-           module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
-           module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
-           module_spec.GetSymbolFileSpec().GetFilename().AsCString());*/
-
-    std::string cache_path(GetLocalCacheDirectory());
-    std::string module_path;
-    module_spec.GetFileSpec().GetPath(module_path);
-    cache_path.append(module_path);
-    FileSpec module_cache_spec(cache_path.c_str(),false);
-    
-    // if rsync is supported, always bring in the file - rsync will be very efficient
-    // when files are the same on the local and remote end of the connection
-    if (this->GetSupportsRSync())
-    {
-        Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
-        if (err.Fail())
-            return err;
-        if (module_cache_spec.Exists())
-        {
-            /*printf("[%s] module %s/%s was rsynced and is now there\n",
-                   (IsHost() ? "host" : "remote"),
-                   module_spec.GetFileSpec().GetDirectory().AsCString(),
-                   module_spec.GetFileSpec().GetFilename().AsCString());*/
-            ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
-            module_sp.reset(new Module(local_spec));
-            module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
-            return Error();
-        }
-    }
-
-    if (module_spec.GetFileSpec().Exists() && !module_sp)
-    {
-        module_sp.reset(new Module(module_spec));
-        return Error();
-    }
-    
-    // try to find the module in the cache
-    if (module_cache_spec.Exists())
-    {
-        // get the local and remote MD5 and compare
-        {
-            // when going over the *slow* GDB remote transfer mechanism we first check
-            // the hashes of the files - and only do the actual transfer if they differ
-            uint64_t high_local,high_remote,low_local,low_remote;
-            Host::CalculateMD5 (module_cache_spec, low_local, high_local);
-            m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), low_remote, high_remote);
-            if (low_local != low_remote || high_local != high_remote)
-            {
-                // bring in the remote file
-                /*printf("[%s] module %s/%s needs to be replaced from remote copy\n",
-                       (IsHost() ? "host" : "remote"),
-                       module_spec.GetFileSpec().GetDirectory().AsCString(),
-                       module_spec.GetFileSpec().GetFilename().AsCString());*/
-                Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
-                if (err.Fail())
-                    return err;
-            }
-        }
-        
-        ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
-        module_sp.reset(new Module(local_spec));
-        module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
-        /*printf("[%s] module %s/%s was found in the cache\n",
-               (IsHost() ? "host" : "remote"),
-               module_spec.GetFileSpec().GetDirectory().AsCString(),
-               module_spec.GetFileSpec().GetFilename().AsCString());*/
-        return Error();
-    }
-    
-    // bring in the remote module file
-    /*printf("[%s] module %s/%s needs to come in remotely\n",
-           (IsHost() ? "host" : "remote"),
-           module_spec.GetFileSpec().GetDirectory().AsCString(),
-           module_spec.GetFileSpec().GetFilename().AsCString());*/
-    Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
-    if (err.Fail())
-        return err;
-    if (module_cache_spec.Exists())
-    {
-        /*printf("[%s] module %s/%s is now cached and fine\n",
-               (IsHost() ? "host" : "remote"),
-               module_spec.GetFileSpec().GetDirectory().AsCString(),
-               module_spec.GetFileSpec().GetFilename().AsCString());*/
-        ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
-        module_sp.reset(new Module(local_spec));
-        module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
-        return Error();
-    }
-    else
-        return Error("unable to obtain valid module file");
+    return GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
 }





More information about the lldb-commits mailing list