[Lldb-commits] [lldb] r154898 - in /lldb/branches/lldb-platform-work/source/Plugins/Platform: MacOSX/PlatformMacOSX.cpp POSIX/PlatformPOSIX.cpp

Enrico Granata egranata at apple.com
Mon Apr 16 18:58:06 PDT 2012


Author: enrico
Date: Mon Apr 16 20:58:06 2012
New Revision: 154898

URL: http://llvm.org/viewvc/llvm-project?rev=154898&view=rev
Log:
This commit fixes several issues to make remote debugging works and adds a basic caching mechanism where required files (the main executable at the moment) can be remote-to-local copied as required - This is not the final design of this feature, but enables basic remote debugging to truly work Mac-to-Mac

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

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=154898&r1=154897&r2=154898&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 16 20:58:06 2012
@@ -116,7 +116,7 @@
 //------------------------------------------------------------------
 PlatformMacOSX::PlatformMacOSX (bool is_host) :
     PlatformDarwin (is_host),
-    m_local_cache_directory()
+    m_local_cache_directory("/Volumes/work/egranata/myTextEdit")
 {
 }
 
@@ -189,9 +189,7 @@
     }
     // try to find the module in the cache
     std::string cache_path(GetLocalCacheDirectory());
-    if (cache_path[cache_path.size()-1] != '/')
-        cache_path.append(1,'/');
-    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);
@@ -199,10 +197,27 @@
     {
         ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
         module_sp.reset(new Module(local_spec));
+        module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
         return Error();
     }
     // bring in the remote module file
-    return Error("unimplemented");
+    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(module_spec.GetFileSpec(), module_cache_spec);
+    if (err.Fail())
+        return err;
+    if (module_cache_spec.Exists())
+    {
+        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");
 }
 
 lldb_private::Options *

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=154898&r1=154897&r2=154898&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Mon Apr 16 20:58:06 2012
@@ -385,11 +385,11 @@
             else
                 command.Printf("rsync %s %s:%s %s",
                                GetRSyncOpts(),
-                               GetHostname(),
+                               m_remote_platform_sp->GetHostname(),
                                src_path.c_str(),
                                dst_path.c_str());
             printf("Running command: %s\n", command.GetData());
-            if (RunShellCommand(command.GetData()) == 0)
+            if (Host::RunProgramAndGetExitCode(command.GetData()) == 0)
                 return Error();
             // If we are here, rsync has failed - let's try the slow way before giving up
         }





More information about the lldb-commits mailing list