[Lldb-commits] [lldb] r155150 - in /lldb/branches/lldb-platform-work: include/lldb/ include/lldb/Interpreter/ include/lldb/Target/ source/Commands/ source/Interpreter/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/POSIX/ source/Target/

Enrico Granata egranata at apple.com
Thu Apr 19 13:02:24 PDT 2012


Author: enrico
Date: Thu Apr 19 15:02:24 2012
New Revision: 155150

URL: http://llvm.org/viewvc/llvm-project?rev=155150&view=rev
Log:
Massive change in the way options are implemented for platform connection - This should make options management more flexible and extensible than the previous model. No change to the actual options supported for remote connectivity is brought in with this patch.

Modified:
    lldb/branches/lldb-platform-work/include/lldb/Interpreter/Options.h
    lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
    lldb/branches/lldb-platform-work/include/lldb/lldb-forward.h
    lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
    lldb/branches/lldb-platform-work/source/Interpreter/Options.cpp
    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
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
    lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h
    lldb/branches/lldb-platform-work/source/Target/Platform.cpp

Modified: lldb/branches/lldb-platform-work/include/lldb/Interpreter/Options.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Interpreter/Options.h?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Interpreter/Options.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Interpreter/Options.h Thu Apr 19 15:02:24 2012
@@ -455,6 +455,10 @@
             assert (m_did_finalize);
             return &m_option_defs[0];
         }
+        
+        const OptionGroup*
+        GetGroupWithOption (char short_opt);
+        
         struct OptionInfo
         {
             OptionInfo (OptionGroup* g, uint32_t i) :

Modified: lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h Thu Apr 19 15:02:24 2012
@@ -22,6 +22,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Interpreter/Options.h"
 #include "lldb/Host/Mutex.h"
 
 namespace lldb_private {
@@ -573,7 +574,7 @@
             m_ignores_remote_hostname = flag;
         }
         
-        virtual Options *
+        virtual lldb_private::OptionGroupOptions *
         GetConnectionOptions (CommandInterpreter& interpreter)
         {
             return NULL;
@@ -586,6 +587,12 @@
                          int *signo_ptr,                // Pass NULL if you don't want the signal that caused the process to exit
                          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 void
+        SetLocalCacheDirectory (const char* local);
+        
+        virtual const char*
+        GetLocalCacheDirectory ();
                 
     protected:
         bool m_is_host;
@@ -616,6 +623,7 @@
         bool m_supports_ssh;
         std::string m_ssh_opts;
         bool m_ignores_remote_hostname;
+        std::string m_local_cache_directory;
 
         const char *
         GetCachedUserName (uint32_t uid)
@@ -797,6 +805,109 @@
     private:
         DISALLOW_COPY_AND_ASSIGN (PlatformList);
     };
+    
+    class OptionGroupPlatformRSync : public lldb_private::OptionGroup
+    {
+    public:
+        OptionGroupPlatformRSync ();
+        
+        virtual
+        ~OptionGroupPlatformRSync ();
+        
+        virtual lldb_private::Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value);
+        
+        void
+        OptionParsingStarting (CommandInterpreter &interpreter);
+        
+        const lldb_private::OptionDefinition*
+        GetDefinitions ();
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        // Options table: Required for subclasses of Options.
+        
+        static lldb_private::OptionDefinition g_option_table[];
+        
+        // Instance variables to hold the values for command options.
+        
+        bool m_rsync;
+        std::string m_rsync_opts;
+        bool m_ignores_remote_hostname;
+    private:
+        DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
+    };
+    
+    class OptionGroupPlatformSSH : public lldb_private::OptionGroup
+    {
+    public:
+        OptionGroupPlatformSSH ();
+        
+        virtual
+        ~OptionGroupPlatformSSH ();
+        
+        virtual lldb_private::Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value);
+        
+        void
+        OptionParsingStarting (CommandInterpreter &interpreter);
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        const lldb_private::OptionDefinition*
+        GetDefinitions ();
+        
+        // Options table: Required for subclasses of Options.
+        
+        static lldb_private::OptionDefinition g_option_table[];
+        
+        // Instance variables to hold the values for command options.
+        
+        bool m_ssh;
+        std::string m_ssh_opts;
+    private:
+        DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
+    };
+    
+    class OptionGroupPlatformCaching : public lldb_private::OptionGroup
+    {
+    public:
+        OptionGroupPlatformCaching ();
+        
+        virtual
+        ~OptionGroupPlatformCaching ();
+        
+        virtual lldb_private::Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value);
+        
+        void
+        OptionParsingStarting (CommandInterpreter &interpreter);
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        const lldb_private::OptionDefinition*
+        GetDefinitions ();
+        
+        // Options table: Required for subclasses of Options.
+        
+        static lldb_private::OptionDefinition g_option_table[];
+        
+        // Instance variables to hold the values for command options.
+        
+        std::string m_cache_dir;
+    private:
+        DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
+    };
+    
 } // namespace lldb_private
 
 #endif  // liblldb_Platform_h_

Modified: lldb/branches/lldb-platform-work/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/lldb-forward.h?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/lldb-forward.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/lldb-forward.h Thu Apr 19 15:02:24 2012
@@ -130,6 +130,7 @@
 class   ObjCLanguageRuntime;
 class   ObjectContainer;
 class   OptionGroup;
+class   OptionGroupOptions;
 class   OptionGroupPlatform;
 class   ObjectFile;
 class   OperatingSystem;

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp Thu Apr 19 15:02:24 2012
@@ -298,9 +298,14 @@
     GetOptions ()
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+        OptionGroupOptions* m_platform_options = NULL;
         if (platform_sp)
-            return platform_sp->GetConnectionOptions(m_interpreter);
-        return NULL;
+        {
+            m_platform_options = platform_sp->GetConnectionOptions(m_interpreter);
+            if (!m_platform_options->m_did_finalize)
+                m_platform_options->Finalize();
+        }
+        return m_platform_options;
     }
 
 };

Modified: lldb/branches/lldb-platform-work/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Interpreter/Options.cpp?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Interpreter/Options.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Interpreter/Options.cpp Thu Apr 19 15:02:24 2012
@@ -959,6 +959,18 @@
     }
 }
 
+const OptionGroup*
+OptionGroupOptions::GetGroupWithOption (char short_opt)
+{
+    for (uint32_t i = 0; i < m_option_defs.size(); i++)
+    {
+        OptionDefinition opt_def = m_option_defs[i];
+        if (opt_def.short_option == short_opt)
+            return m_option_infos[i].option_group;
+    }
+    return NULL;
+}
+
 void
 OptionGroupOptions::Append (OptionGroup* group, 
                             uint32_t src_mask, 

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=155150&r1=155149&r2=155150&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 Thu Apr 19 15:02:24 2012
@@ -400,19 +400,23 @@
     {
         if (m_options.get())
         {
-            PlatformPOSIX::POSIXPlatformConnectionOptions* posix_options = (PlatformPOSIX::POSIXPlatformConnectionOptions*)m_options.get();
-            if (posix_options->m_rsync)
+            OptionGroupOptions* options = (OptionGroupOptions*)m_options.get();
+            OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r');
+            OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s');
+            OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c');
+            
+            if (m_rsync_options->m_rsync)
             {
                 SetSupportsRSync(true);
-                SetRSyncOpts(posix_options->m_rsync_opts.c_str());
+                SetRSyncOpts(m_rsync_options->m_rsync_opts.c_str());
+                SetIgnoresRemoteHostname(m_rsync_options->m_ignores_remote_hostname);
             }
-            if (posix_options->m_ssh)
+            if (m_ssh_options->m_ssh)
             {
                 SetSupportsSSH(true);
-                SetSSHOpts(posix_options->m_ssh_opts.c_str());
+                SetSSHOpts(m_ssh_options->m_ssh_opts.c_str());
             }
-            SetIgnoresRemoteHostname(posix_options->m_ignores_remote_hostname);
-            SetLocalCacheDirectory(posix_options->m_cache_dir.c_str());
+            SetLocalCacheDirectory(m_cache_options->m_cache_dir.c_str());
         }
     }
 
@@ -789,15 +793,3 @@
         return m_developer_directory.c_str();
     return NULL;
 }
-
-void
-PlatformDarwin::SetLocalCacheDirectory (const char* local)
-{
-    m_local_cache_directory.assign(local);
-}
-
-const char*
-PlatformDarwin::GetLocalCacheDirectory ()
-{
-    return m_local_cache_directory.c_str();
-}

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=155150&r1=155149&r2=155150&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 Thu Apr 19 15:02:24 2012
@@ -102,22 +102,12 @@
     bool 
     x86GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
 
-    virtual void
-    SetLocalCacheDirectory (const char* local);
-    
-    virtual const char*
-    GetLocalCacheDirectory ();
-    
 protected:
     std::string m_developer_directory;
     
     const char *
     GetDeveloperDirectory();
     
-    class CommandOptions
-    {
-    };
-
 private:
     DISALLOW_COPY_AND_ASSIGN (PlatformDarwin);
 

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=155150&r1=155149&r2=155150&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 Thu Apr 19 15:02:24 2012
@@ -269,9 +269,3 @@
     else
         return Error("unable to obtain valid module file");
 }
-
-lldb_private::Options *
-PlatformMacOSX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
-{
-    return PlatformDarwin::GetConnectionOptions(interpreter);
-}

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=155150&r1=155149&r2=155150&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 Thu Apr 19 15:02:24 2012
@@ -103,10 +103,6 @@
     virtual bool
     GetSupportedArchitectureAtIndex (uint32_t idx, 
                                      lldb_private::ArchSpec &arch);
-    
-    // must add --local-cache to the parent options
-    virtual lldb_private::Options *
-    GetConnectionOptions (lldb_private::CommandInterpreter& interpreter);
 
 private:
     DISALLOW_COPY_AND_ASSIGN (PlatformMacOSX);

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=155150&r1=155149&r2=155150&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 Thu Apr 19 15:02:24 2012
@@ -42,95 +42,16 @@
 {
 }
 
-PlatformPOSIX::POSIXPlatformConnectionOptions::POSIXPlatformConnectionOptions (CommandInterpreter &interpreter) :
-Options (interpreter),
-m_rsync (false),
-m_rsync_opts (),
-m_ssh (false),
-m_ssh_opts (),
-m_ignores_remote_hostname (false),
-m_cache_dir()
-{
-}
-
-PlatformPOSIX::POSIXPlatformConnectionOptions::~POSIXPlatformConnectionOptions ()
-{
-}
-
-Error
-PlatformPOSIX::POSIXPlatformConnectionOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
-    
-    switch (short_option)
-    {
-        case 'r':
-            m_rsync = true;
-            break;
-            
-        case 'R':
-            m_rsync_opts.assign(option_arg);
-            break;
-            
-        case 's':
-            m_ssh = true;
-            break;
-            
-        case 'S':
-            m_ssh_opts.assign(option_arg);
-            break;
-            
-        case 'i':
-            m_ignores_remote_hostname = true;
-            break;
-            
-        case 'c':
-            m_cache_dir.assign(option_arg);
-            break;
-            
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-    
-    return error;
-}
-
-void
-PlatformPOSIX::POSIXPlatformConnectionOptions::OptionParsingStarting ()
-{
-    m_rsync = false;
-    m_rsync_opts.clear();
-    m_ssh = false;
-    m_ssh_opts.clear();
-    m_ignores_remote_hostname = false;
-    m_cache_dir.clear();
-}
-
-const OptionDefinition*
-PlatformPOSIX::POSIXPlatformConnectionOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
-
-OptionDefinition
-PlatformPOSIX::POSIXPlatformConnectionOptions::g_option_table[] =
-{
-    {   LLDB_OPT_SET_ALL, false, "rsync"                  , 'r', no_argument,       NULL, 0, eArgTypeNone         , "Enable rsync." },
-    {   LLDB_OPT_SET_ALL, false, "rsync-opts"             , 'R', required_argument, NULL, 0, eArgTypeCommandName  , "Platform-specific options required for rsync to work." },
-    {   LLDB_OPT_SET_ALL, false, "ssh"                    , 's', no_argument,       NULL, 0, eArgTypeNone         , "Enable SSH." },
-    {   LLDB_OPT_SET_ALL, false, "ssh-opts"               , 'S', required_argument, NULL, 0, eArgTypeCommandName  , "Platform-specific options required for SSH to work." },
-    {   LLDB_OPT_SET_ALL, false, "ignore-remote-hostname" , 'i', no_argument,       NULL, 0, eArgTypeNone         , "Do not automatically fill in the remote hostname when composing the rsync command." },
-    {   LLDB_OPT_SET_ALL, false, "local-cache-dir"        , 'c', required_argument, NULL, 0, eArgTypePath         , "Path in which to store local copies of files." },
-    {   0,                false, NULL                     ,  0 , 0                , NULL, 0, eArgTypeNone         , NULL }
-};
-
-Options *
+lldb_private::OptionGroupOptions*
 PlatformPOSIX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
 {
     if (m_options.get() == NULL)
-        m_options.reset(new POSIXPlatformConnectionOptions(interpreter));
+    {
+        m_options.reset(new OptionGroupOptions(interpreter));
+        m_options->Append(new OptionGroupPlatformRSync());
+        m_options->Append(new OptionGroupPlatformSSH());
+        m_options->Append(new OptionGroupPlatformCaching());
+    }
     return m_options.get();
 }
 

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h Thu Apr 19 15:02:24 2012
@@ -31,7 +31,7 @@
     //------------------------------------------------------------
     // lldb_private::Platform functions
     //------------------------------------------------------------
-    virtual lldb_private::Options *
+    virtual lldb_private::OptionGroupOptions*
     GetConnectionOptions (lldb_private::CommandInterpreter& interpreter);
     
     virtual lldb_private::Error
@@ -74,40 +74,8 @@
     GetFileExists (const lldb_private::FileSpec& file_spec);
 
 protected:
-    std::auto_ptr<lldb_private::Options> m_options;
-    std::string m_local_cache_directory;
-    
-    class POSIXPlatformConnectionOptions : public lldb_private::Options
-    {
-    public:
-        POSIXPlatformConnectionOptions (lldb_private::CommandInterpreter &interpreter);
-        
-        virtual
-        ~POSIXPlatformConnectionOptions ();
-        
-        virtual lldb_private::Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-        
-        void
-        OptionParsingStarting ();
-        
-        const lldb_private::OptionDefinition*
-        GetDefinitions ();
+    std::auto_ptr<lldb_private::OptionGroupOptions> m_options;
         
-        // Options table: Required for subclasses of Options.
-        
-        static lldb_private::OptionDefinition g_option_table[];
-        
-        // Instance variables to hold the values for command options.
-        
-        bool m_rsync;
-        std::string m_rsync_opts;
-        bool m_ssh;
-        std::string m_ssh_opts;
-        bool m_ignores_remote_hostname;
-        std::string m_cache_dir;
-    };
-    
     lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote POSIX-compliant OS
     
 private:

Modified: lldb/branches/lldb-platform-work/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Target/Platform.cpp?rev=155150&r1=155149&r2=155150&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Target/Platform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Target/Platform.cpp Thu Apr 19 15:02:24 2012
@@ -20,6 +20,7 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/Utils.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -736,3 +737,193 @@
     else
         return Error("unimplemented");
 }
+
+
+void
+Platform::SetLocalCacheDirectory (const char* local)
+{
+    m_local_cache_directory.assign(local);
+}
+
+const char*
+Platform::GetLocalCacheDirectory ()
+{
+    return m_local_cache_directory.c_str();
+}
+
+static OptionDefinition
+g_rsync_option_table[] =
+{
+    {   LLDB_OPT_SET_ALL, false, "rsync"                  , 'r', no_argument,       NULL, 0, eArgTypeNone         , "Enable rsync." },
+    {   LLDB_OPT_SET_ALL, false, "rsync-opts"             , 'R', required_argument, NULL, 0, eArgTypeCommandName  , "Platform-specific options required for rsync to work." },
+    {   LLDB_OPT_SET_ALL, false, "ignore-remote-hostname" , 'i', no_argument,       NULL, 0, eArgTypeNone         , "Do not automatically fill in the remote hostname when composing the rsync command." },
+};
+
+static OptionDefinition
+g_ssh_option_table[] =
+{
+    {   LLDB_OPT_SET_ALL, false, "ssh"                    , 's', no_argument,       NULL, 0, eArgTypeNone         , "Enable SSH." },
+    {   LLDB_OPT_SET_ALL, false, "ssh-opts"               , 'S', required_argument, NULL, 0, eArgTypeCommandName  , "Platform-specific options required for SSH to work." },
+};
+
+static OptionDefinition
+g_caching_option_table[] =
+{
+    {   LLDB_OPT_SET_ALL, false, "local-cache-dir"        , 'c', required_argument, NULL, 0, eArgTypePath         , "Path in which to store local copies of files." },
+};
+
+OptionGroupPlatformRSync::OptionGroupPlatformRSync ()
+{
+}
+
+OptionGroupPlatformRSync::~OptionGroupPlatformRSync ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformRSync::GetDefinitions ()
+{
+    return g_rsync_option_table;
+}
+
+void
+OptionGroupPlatformRSync::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+    m_rsync = false;
+    m_rsync_opts.clear();
+    m_ignores_remote_hostname = false;
+}
+
+lldb_private::Error
+OptionGroupPlatformRSync::SetOptionValue (CommandInterpreter &interpreter,
+                uint32_t option_idx,
+                const char *option_arg)
+{
+    Error error;
+    char short_option = (char) GetDefinitions()[option_idx].short_option;
+    switch (short_option)
+    {
+        case 'r':
+            m_rsync = true;
+            break;
+            
+        case 'R':
+            m_rsync_opts.assign(option_arg);
+            break;
+            
+        case 'i':
+            m_ignores_remote_hostname = true;
+            break;
+            
+        default:
+            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+            break;
+    }
+    
+    return error;
+}
+
+uint32_t
+OptionGroupPlatformRSync::GetNumDefinitions ()
+{
+    return arraysize(g_rsync_option_table);
+}
+
+OptionGroupPlatformSSH::OptionGroupPlatformSSH ()
+{
+}
+
+OptionGroupPlatformSSH::~OptionGroupPlatformSSH ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformSSH::GetDefinitions ()
+{
+    return g_ssh_option_table;
+}
+
+void
+OptionGroupPlatformSSH::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+    m_ssh = false;
+    m_ssh_opts.clear();
+}
+
+lldb_private::Error
+OptionGroupPlatformSSH::SetOptionValue (CommandInterpreter &interpreter,
+                                          uint32_t option_idx,
+                                          const char *option_arg)
+{
+    Error error;
+    char short_option = (char) GetDefinitions()[option_idx].short_option;
+    switch (short_option)
+    {
+        case 's':
+            m_ssh = true;
+            break;
+            
+        case 'S':
+            m_ssh_opts.assign(option_arg);
+            break;
+            
+        default:
+            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+            break;
+    }
+    
+    return error;
+}
+
+uint32_t
+OptionGroupPlatformSSH::GetNumDefinitions ()
+{
+    return arraysize(g_ssh_option_table);
+}
+
+OptionGroupPlatformCaching::OptionGroupPlatformCaching ()
+{
+}
+
+OptionGroupPlatformCaching::~OptionGroupPlatformCaching ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformCaching::GetDefinitions ()
+{
+    return g_caching_option_table;
+}
+
+void
+OptionGroupPlatformCaching::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+    m_cache_dir.clear();
+}
+
+lldb_private::Error
+OptionGroupPlatformCaching::SetOptionValue (CommandInterpreter &interpreter,
+                                        uint32_t option_idx,
+                                        const char *option_arg)
+{
+    Error error;
+    char short_option = (char) GetDefinitions()[option_idx].short_option;
+    switch (short_option)
+    {
+        case 'c':
+            m_cache_dir.assign(option_arg);
+            break;
+            
+        default:
+            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+            break;
+    }
+    
+    return error;
+}
+
+uint32_t
+OptionGroupPlatformCaching::GetNumDefinitions ()
+{
+    return arraysize(g_caching_option_table);
+}





More information about the lldb-commits mailing list