Expose SBPlatform through the public API.

Example code:

remote_platform = lldb.SBPlatform("remote-macosx"); 
remote_platform.SetWorkingDirectory("/private/tmp")
debugger.SetSelectedPlatform(remote_platform)

connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); 
err = remote_platform.ConnectRemote(connect_options)
if err.Success():
    print >> result, 'Connected to remote platform:'
    print >> result, 'hostname: %s' % (remote_platform.GetHostname())
    src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False)
    dst = lldb.SBFileSpec()
    # copy src to platform working directory since "dst" is empty
    err = remote_platform.Install(src, dst);
    if err.Success():
        print >> result, '%s installed successfully' % (src)
    else:
        print >> result, 'error: failed to install "%s": %s' % (src, err)


Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories.

The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform.

The API in SBPlatform is subject to change and will be getting many new functions.

llvm-svn: 195273
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 530655b..7d4d9a2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -38,7 +38,6 @@
     //------------------------------------------------------------------
     GDBRemoteCommunicationClient(bool is_platform);
 
-    virtual
     ~GDBRemoteCommunicationClient();
 
     //------------------------------------------------------------------
@@ -65,7 +64,7 @@
                                           size_t packet_length,
                                           StringExtractorGDBRemote &response);
 
-    virtual bool
+    bool
     GetThreadSuffixSupported ();
 
     void
@@ -109,7 +108,7 @@
     ///     response was received.
     //------------------------------------------------------------------
     int
-    SendArgumentsPacket (char const *argv[]);
+    SendArgumentsPacket (const lldb_private::ProcessLaunchInfo &launch_info);
 
     //------------------------------------------------------------------
     /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
@@ -185,7 +184,10 @@
 
     //------------------------------------------------------------------
     /// Sets the working directory to \a path for a process that will 
-    /// be launched with the 'A' packet.
+    /// be launched with the 'A' packet for non platform based
+    /// connections. If this packet is sent to a GDB server that
+    /// implements the platform, it will change the current working
+    /// directory for the platform process.
     ///
     /// @param[in] path
     ///     The path to a directory to use when launching our processs
@@ -196,6 +198,19 @@
     int
     SetWorkingDir (char const *path);
 
+    //------------------------------------------------------------------
+    /// Gets the current working directory of a remote platform GDB
+    /// server.
+    ///
+    /// @param[out] cwd
+    ///     The current working directory on the remote platform.
+    ///
+    /// @return
+    ///     Boolean for success
+    //------------------------------------------------------------------
+    bool
+    GetWorkingDir (std::string &cwd);
+
     lldb::addr_t
     AllocateMemory (size_t size, uint32_t permissions);
 
@@ -356,45 +371,54 @@
         return m_interrupt_sent;
     }
     
-    virtual lldb::user_id_t
+    lldb::user_id_t
     OpenFile (const lldb_private::FileSpec& file_spec,
               uint32_t flags,
               mode_t mode,
               lldb_private::Error &error);
     
-    virtual bool
+    bool
     CloseFile (lldb::user_id_t fd,
                lldb_private::Error &error);
     
-    virtual lldb::user_id_t
+    lldb::user_id_t
     GetFileSize (const lldb_private::FileSpec& file_spec);
     
-    virtual uint32_t
-    GetFilePermissions(const lldb_private::FileSpec& file_spec,
-                       lldb_private::Error &error);
+    lldb_private::Error
+    GetFilePermissions(const char *path, uint32_t &file_permissions);
 
-    virtual uint64_t
+    lldb_private::Error
+    SetFilePermissions(const char *path, uint32_t file_permissions);
+
+    uint64_t
     ReadFile (lldb::user_id_t fd,
               uint64_t offset,
               void *dst,
               uint64_t dst_len,
               lldb_private::Error &error);
     
-    virtual uint64_t
+    uint64_t
     WriteFile (lldb::user_id_t fd,
                uint64_t offset,
                const void* src,
                uint64_t src_len,
                lldb_private::Error &error);
     
-    virtual uint32_t
-    MakeDirectory (const std::string &path,
-                   mode_t mode);
+    lldb_private::Error
+    CreateSymlink (const char *src,
+                   const char *dst);
     
-    virtual bool
+    lldb_private::Error
+    Unlink (const char *path);
+
+    lldb_private::Error
+    MakeDirectory (const char *path,
+                   uint32_t mode);
+    
+    bool
     GetFileExists (const lldb_private::FileSpec& file_spec);
     
-    virtual lldb_private::Error
+    lldb_private::Error
     RunShellCommand (const char *command,           // Shouldn't be NULL
                      const char *working_dir,       // Pass NULL to use the current working directory
                      int *status_ptr,               // Pass NULL if you don't want the process exit status
@@ -402,7 +426,7 @@
                      std::string *command_output,   // Pass NULL if you don't want the command output
                      uint32_t timeout_sec);         // Timeout in seconds to wait for shell program to finish
     
-    virtual bool
+    bool
     CalculateMD5 (const lldb_private::FileSpec& file_spec,
                   uint64_t &high,
                   uint64_t &low);