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

Enrico Granata egranata at apple.com
Tue Apr 17 18:14:41 PDT 2012


Author: enrico
Date: Tue Apr 17 20:14:41 2012
New Revision: 154973

URL: http://llvm.org/viewvc/llvm-project?rev=154973&view=rev
Log:
Enabling the Platform to resolve required files across different OS versions - We check that the two ends of the link have the same or a different OS version and if it turns out that the OS version is different, we actually transfer the required binaries from the remote end of the link to our cache directory and fixup the paths to point to our locally-cached copies. This works to enable some simple cases of inter-OS debugging

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

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=154973&r1=154972&r2=154973&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 Tue Apr 17 20:14:41 2012
@@ -145,6 +145,58 @@
     return Error();
 }
 
+lldb_private::Error
+PlatformMacOSX::GetFile (const lldb_private::FileSpec &platform_file,
+                         const lldb_private::UUID *uuid_ptr,
+                         lldb_private::FileSpec &local_file)
+{
+    if (IsRemote() && m_remote_platform_sp)
+    {
+        std::string local_os_build;
+        Host::GetOSBuildString(local_os_build);
+        std::string remote_os_build;
+        m_remote_platform_sp->GetOSBuildString(remote_os_build);
+        if (local_os_build.compare(remote_os_build) == 0)
+        {
+            // same OS version: the local file is good enough
+            local_file = platform_file;
+            return Error();
+        }
+        else
+        {
+            // try to find the file in the cache
+            std::string cache_path(GetLocalCacheDirectory());
+            std::string module_path;
+            platform_file.GetPath(module_path);
+            cache_path.append(module_path);
+            FileSpec module_cache_spec(cache_path.c_str(),false);
+            if (module_cache_spec.Exists())
+            {
+                local_file = module_cache_spec;
+                return Error();
+            }
+            // bring in the remote module file
+            FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
+            StreamString mkdir_folder_cmd;
+            // try to make the local directory first
+            mkdir_folder_cmd.Printf("mkdir -p %s/%s", module_cache_folder.GetDirectory().AsCString(), module_cache_folder.GetFilename().AsCString());
+            Host::RunProgramAndGetExitCode(mkdir_folder_cmd.GetData());
+            Error err = GetFile(platform_file, module_cache_spec);
+            if (err.Fail())
+                return err;
+            if (module_cache_spec.Exists())
+            {
+                local_file = module_cache_spec;
+                return Error();
+            }
+            else
+                return Error("unable to obtain valid module file");
+        }
+    }
+    local_file = platform_file;
+    return Error();
+}
+
 bool
 PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
 {
@@ -177,7 +229,7 @@
     }
     // try to find the module in the cache
     std::string cache_path(GetLocalCacheDirectory());
-     std::string module_path;
+    std::string module_path;
     module_spec.GetFileSpec().GetPath(module_path);
     cache_path.append(module_path);
     FileSpec module_cache_spec(cache_path.c_str(),false);

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=154973&r1=154972&r2=154973&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Tue Apr 17 20:14:41 2012
@@ -88,6 +88,18 @@
                    const lldb_private::UUID *uuid_ptr,
                    lldb_private::FileSpec &local_file);
     
+    virtual lldb_private::Error
+    GetFile (const lldb_private::FileSpec& source,
+             const lldb_private::FileSpec& destination)
+    {
+        return PlatformDarwin::GetFile (source,destination);
+    }
+    
+    virtual lldb_private::Error
+    GetFile (const lldb_private::FileSpec &platform_file, 
+             const lldb_private::UUID *uuid_ptr,
+             lldb_private::FileSpec &local_file);
+    
     virtual bool
     GetSupportedArchitectureAtIndex (uint32_t idx, 
                                      lldb_private::ArchSpec &arch);





More information about the lldb-commits mailing list