[Lldb-commits] [lldb] r129415 - in /lldb/trunk: include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/xcshareddata/xcschemes/ source/Commands/ source/Interpreter/ source/Target/

Greg Clayton gclayton at apple.com
Tue Apr 12 17:18:08 PDT 2011


Author: gclayton
Date: Tue Apr 12 19:18:08 2011
New Revision: 129415

URL: http://llvm.org/viewvc/llvm-project?rev=129415&view=rev
Log:
Added two new classes for command options:

    lldb_private::OptionGroup
    lldb_private::OptionGroupOptions

OptionGroup lets you define a class that encapsulates settings that you want
to reuse in multiple commands. It contains only the option definitions and the
ability to set the option values, but it doesn't directly interface with the
lldb_private::Options class that is the front end to all of the CommandObject
option parsing. For that the OptionGroupOptions class can be used. It aggregates
one or more OptionGroup objects and directs the option setting to the 
appropriate OptionGroup class. For an example of this, take a look at the 
CommandObjectFile and how it uses its "m_option_group" object shown below
to be able to set values in both the FileOptionGroup and PlatformOptionGroup
classes. The members used in CommandObjectFile are:

    OptionGroupOptions m_option_group;
    FileOptionGroup m_file_options;
    PlatformOptionGroup m_platform_options;

Then in the constructor for CommandObjectFile you can combine the option
settings. The code below shows a simplified version of the constructor:

CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) :
    CommandObject (...),
    m_option_group (interpreter),
    m_file_options (),
    m_platform_options(true)
{
    m_option_group.Append (&m_file_options);
    m_option_group.Append (&m_platform_options);
    m_option_group.Finalize();
}

We append the m_file_options and then the m_platform_options and then tell
the option group the finalize the results. This allows the m_option_group to
become the organizer of our prefs and after option parsing we end up with
valid preference settings in both the m_file_options and m_platform_options
objects. This also allows any other commands to use the FileOptionGroup and
PlatformOptionGroup classes to implement options for their commands.

Renamed:
    virtual void Options::ResetOptionValues();
to:
    virtual void Options::OptionParsingStarting();

And implemented a new callback named:

    virtual Error Options::OptionParsingFinished();
    
This allows Options subclasses to verify that the options all go together
after all of the options have been specified and gives the chance for the
command object to return an error. It also gives a chance to take all of the
option values and produce or initialize objects after all options have
completed parsing.

Modfied:

    virtual Error
    SetOptionValue (int option_idx, const char *option_arg) = 0;
    
to be:

    virtual Error
    SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;

(option_idx is now unsigned).



Modified:
    lldb/trunk/include/lldb/Interpreter/Options.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
    lldb/trunk/source/Commands/CommandObjectArgs.cpp
    lldb/trunk/source/Commands/CommandObjectArgs.h
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.h
    lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h
    lldb/trunk/source/Commands/CommandObjectCommands.cpp
    lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
    lldb/trunk/source/Commands/CommandObjectDisassemble.h
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Commands/CommandObjectExpression.h
    lldb/trunk/source/Commands/CommandObjectFile.cpp
    lldb/trunk/source/Commands/CommandObjectFile.h
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Commands/CommandObjectLog.cpp
    lldb/trunk/source/Commands/CommandObjectMemory.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.h
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectRegister.cpp
    lldb/trunk/source/Commands/CommandObjectSettings.cpp
    lldb/trunk/source/Commands/CommandObjectSettings.h
    lldb/trunk/source/Commands/CommandObjectSource.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp
    lldb/trunk/source/Interpreter/Options.cpp
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Interpreter/Options.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Options.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Options.h Tue Apr 12 19:18:08 2011
@@ -56,7 +56,7 @@
 ///         }
 ///
 ///         virtual Error
-///         SetOptionValue (int option_idx, int option_val, const char *option_arg)
+///         SetOptionValue (uint32_t option_idx, int option_val, const char *option_arg)
 ///         {
 ///             Error error;
 ///             switch (option_val)
@@ -142,15 +142,13 @@
     bool
     VerifyOptions (CommandReturnObject &result);
 
-    // Verify that the options given are in the options table and can be used together, but there may be
-    // some required options that are missing (used to verify options that get folded into command aliases).
+    // Verify that the options given are in the options table and can 
+    // be used together, but there may be some required options that are
+    // missing (used to verify options that get folded into command aliases).
 
     bool
     VerifyPartialOptions (CommandReturnObject &result);
 
-//    void
-//    BuildAliasOptions (OptionArgVector *option_arg_vector, Args args);
-
     void
     OutputFormattedUsageText (Stream &strm,
                               const char *text,
@@ -160,19 +158,22 @@
     GenerateOptionUsage (Stream &strm,
                          CommandObject *cmd);
 
-    // The following two pure virtual functions must be defined by every class that inherits from
-    // this class.
+    // The following two pure virtual functions must be defined by every 
+    // class that inherits from this class.
 
     virtual const OptionDefinition*
     GetDefinitions () { return NULL; }
 
     // Call this prior to parsing any options. This call will call the
-    // subclass ResetOptionValues() and will avoid the need for all
-    // ResetOptionValues() function instances from having to call the
-    // Option::ResetOptionValues() like they did before. This was error
+    // subclass OptionParsingStarting() and will avoid the need for all
+    // OptionParsingStarting() function instances from having to call the
+    // Option::OptionParsingStarting() like they did before. This was error
     // prone and subclasses shouldn't have to do it.
     void
-    Reset ();
+    NotifyOptionParsingStarting ();
+    
+    Error
+    NotifyOptionParsingFinished ();
 
     //------------------------------------------------------------------
     /// Set the value of an option.
@@ -190,11 +191,11 @@
     /// @see man getopt_long
     //------------------------------------------------------------------
     virtual Error
-    SetOptionValue (int option_idx, const char *option_arg) = 0;
+    SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;
 
     //------------------------------------------------------------------
-    ///  Handles the generic bits of figuring out whether we are in an option, and if so completing
-    /// it.
+    /// Handles the generic bits of figuring out whether we are in an 
+    /// option, and if so completing it.
     ///
     /// @param[in] input
     ///    The command line parsed into words
@@ -207,20 +208,22 @@
     ///
     /// @param[in] match_start_point
     /// @param[in] match_return_elements
-    ///     See CommandObject::HandleCompletions for a description of how these work.
+    ///     See CommandObject::HandleCompletions for a description of 
+    ///     how these work.
     ///
     /// @param[in] interpreter
     ///     The interpreter that's doing the completing.
     ///
     /// @param[out] word_complete
-    ///     \btrue if this is a complete option value (a space will be inserted after the
-    ///     completion.)  \bfalse otherwise.
+    ///     \btrue if this is a complete option value (a space will be 
+    ///     inserted after the completion.) \b false otherwise.
     ///
     /// @param[out] matches
     ///     The array of matches returned.
     ///
-    /// FIXME: This is the wrong return value, since we also need to make a distinction between
-    /// total number of matches, and the window the user wants returned.
+    /// FIXME: This is the wrong return value, since we also need to 
+    /// make a distinction between total number of matches, and the 
+    /// window the user wants returned.
     ///
     /// @return
     ///     \btrue if we were in an option, \bfalse otherwise.
@@ -236,8 +239,8 @@
                             lldb_private::StringList &matches);
 
     //------------------------------------------------------------------
-    ///  Handles the generic bits of figuring out whether we are in an option, and if so completing
-    /// it.
+    /// Handles the generic bits of figuring out whether we are in an 
+    /// option, and if so completing it.
     ///
     /// @param[in] interpreter
     ///    The command interpreter doing the completion.
@@ -255,21 +258,24 @@
     ///     The results of the options parse of \a input.
     ///
     /// @param[in] opt_element_index
-    ///     The position in \a opt_element_vector of the word in \a input containing the cursor.
+    ///     The position in \a opt_element_vector of the word in \a 
+    ///     input containing the cursor.
     ///
     /// @param[in] match_start_point
     /// @param[in] match_return_elements
-    ///     See CommandObject::HandleCompletions for a description of how these work.
+    ///     See CommandObject::HandleCompletions for a description of 
+    ///     how these work.
     ///
     /// @param[out] word_complete
-    ///     \btrue if this is a complete option value (a space will be inserted after the
-    ///     completion.)  \bfalse otherwise.
+    ///     \btrue if this is a complete option value (a space will 
+    ///     be inserted after the completion.) \bfalse otherwise.
     ///
     /// @param[out] matches
     ///     The array of matches returned.
     ///
-    /// FIXME: This is the wrong return value, since we also need to make a distinction between
-    /// total number of matches, and the window the user wants returned.
+    /// FIXME: This is the wrong return value, since we also need to
+    /// make a distinction between total number of matches, and the 
+    /// window the user wants returned.
     ///
     /// @return
     ///     \btrue if we were in an option, \bfalse otherwise.
@@ -321,9 +327,104 @@
     // option parse. Each subclass must override this function and revert
     // all option settings to default values.
     virtual void
-    ResetOptionValues () = 0;
+    OptionParsingStarting () = 0;
+
+    virtual Error
+    OptionParsingFinished ()
+    {
+        // If subclasses need to know when the options are done being parsed
+        // they can implement this function to do extra checking
+        Error error;
+        return error;
+    }
 };
 
+    class OptionGroup
+    {
+    public:
+        OptionGroup () 
+        {
+        }
+        
+        virtual 
+        ~OptionGroup () 
+        {
+        }
+        
+        virtual uint32_t
+        GetNumDefinitions () = 0;
+
+        virtual const OptionDefinition*
+        GetDefinitions () = 0;
+        
+        virtual Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value) = 0;
+
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter) = 0;
+        
+        virtual Error
+        OptionParsingFinished (CommandInterpreter &interpreter)
+        {
+            // If subclasses need to know when the options are done being parsed
+            // they can implement this function to do extra checking
+            Error error;
+            return error;
+        }
+    };
+
+    class OptionGroupOptions : public Options
+    {
+    public:
+        
+        OptionGroupOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_option_defs (),
+            m_option_groups (),
+            m_did_finalize (false)
+        {
+        }
+        
+        virtual
+        ~OptionGroupOptions ()
+        {
+        }
+        
+        void
+        Append (OptionGroup* group);
+
+        void
+        Append (OptionGroup* group, uint32_t usage_mask);        
+
+        void
+        Finalize ();
+        
+        virtual Error
+        SetOptionValue (uint32_t option_idx, 
+                        const char *option_arg);
+        
+        virtual void
+        OptionParsingStarting ();
+        
+        virtual Error
+        OptionParsingFinished ();
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            assert (m_did_finalize);
+            return &m_option_defs[0];
+        }
+        typedef std::vector<OptionGroup*> OptionGroupsType;
+        
+        std::vector<OptionDefinition> m_option_defs;
+        OptionGroupsType m_option_groups;
+        bool m_did_finalize;
+    };
+    
+
 } // namespace lldb_private
 
 #endif  // liblldb_Options_h_

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Apr 12 19:18:08 2011
@@ -725,8 +725,8 @@
     ProcessLaunchCommandOptions (CommandInterpreter &interpreter) :
         Options(interpreter)
     {
-        // Keep default values of all options in one place: ResetOptionValues ()
-        ResetOptionValues ();
+        // Keep default values of all options in one place: OptionParsingStarting ()
+        OptionParsingStarting ();
     }
     
     ~ProcessLaunchCommandOptions ()
@@ -734,10 +734,10 @@
     }
     
     Error
-    SetOptionValue (int option_idx, const char *option_arg);
+    SetOptionValue (uint32_t option_idx, const char *option_arg);
     
     void
-    ResetOptionValues ()
+    OptionParsingStarting ()
     {
         launch_info.Clear();
     }

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Apr 12 19:18:08 2011
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   version = "1.3">
+   version = "1.5">
    <BuildAction
       parallelizeBuildables = "NO"
       buildImplicitDependencies = "YES">
@@ -196,4 +196,7 @@
       buildConfiguration = "Release"
       revealArchiveInOrganizer = "YES">
    </ArchiveAction>
+   <InstallAction
+      buildConfiguration = "Debug">
+   </InstallAction>
 </Scheme>

Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Tue Apr 12 19:18:08 2011
@@ -40,7 +40,7 @@
     Options(interpreter)
 {
     // Keep only one place to reset the values to their defaults
-    ResetOptionValues();
+    OptionParsingStarting();
 }
 
 
@@ -49,7 +49,7 @@
 }
 
 Error
-CommandObjectArgs::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     
@@ -66,7 +66,7 @@
 }
 
 void
-CommandObjectArgs::CommandOptions::ResetOptionValues ()
+CommandObjectArgs::CommandOptions::OptionParsingStarting ()
 {
 }
 

Modified: lldb/trunk/source/Commands/CommandObjectArgs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.h (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.h Tue Apr 12 19:18:08 2011
@@ -34,10 +34,10 @@
             ~CommandOptions ();
             
             virtual Error
-            SetOptionValue (int option_idx, const char *option_arg);
+            SetOptionValue (uint32_t option_idx, const char *option_arg);
             
             void
-            ResetOptionValues ();
+            OptionParsingStarting ();
             
             const OptionDefinition*
             GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Apr 12 19:18:08 2011
@@ -134,7 +134,7 @@
 }
 
 Error
-CommandObjectBreakpointSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;
@@ -233,7 +233,7 @@
 }
 
 void
-CommandObjectBreakpointSet::CommandOptions::ResetOptionValues ()
+CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
 {
     m_filename.clear();
     m_line_num = 0;
@@ -675,7 +675,7 @@
 }
 
 Error
-CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;
@@ -703,7 +703,7 @@
 }
 
 void
-CommandObjectBreakpointList::CommandOptions::ResetOptionValues ()
+CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
 {
     m_level = lldb::eDescriptionLevelBrief;
     m_internal = false;
@@ -1077,7 +1077,7 @@
 }
 
 Error
-CommandObjectBreakpointClear::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;
@@ -1101,7 +1101,7 @@
 }
 
 void
-CommandObjectBreakpointClear::CommandOptions::ResetOptionValues ()
+CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
 {
     m_filename.clear();
     m_line_num = 0;
@@ -1394,7 +1394,7 @@
 }
 
 Error
-CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;
@@ -1480,7 +1480,7 @@
 }
 
 void
-CommandObjectBreakpointModify::CommandOptions::ResetOptionValues ()
+CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
 {
     m_ignore_count = 0;
     m_thread_id = LLDB_INVALID_THREAD_ID;

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Tue Apr 12 19:18:08 2011
@@ -82,10 +82,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();
@@ -148,10 +148,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();
@@ -249,10 +249,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition *
         GetDefinitions ();
@@ -309,10 +309,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Apr 12 19:18:08 2011
@@ -82,7 +82,7 @@
 Error
 CommandObjectBreakpointCommandAdd::CommandOptions::SetOptionValue 
 (
-    int option_idx, 
+    uint32_t option_idx, 
     const char *option_arg
 )
 {
@@ -133,7 +133,7 @@
 }
 
 void
-CommandObjectBreakpointCommandAdd::CommandOptions::ResetOptionValues ()
+CommandObjectBreakpointCommandAdd::CommandOptions::OptionParsingStarting ()
 {
     m_use_commands = true;
     m_use_script_language = false;

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Tue Apr 12 19:18:08 2011
@@ -101,10 +101,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Apr 12 19:18:08 2011
@@ -43,7 +43,7 @@
         ~CommandOptions (){}
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -70,7 +70,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_stop_on_error = true;
             m_stop_on_continue = true;
@@ -360,7 +360,7 @@
                 if (options)
                 {
                     // See if any options were specified as part of the alias; if so, handle them appropriately
-                    options->Reset ();
+                    options->NotifyOptionParsingStarting ();
                     Args tmp_args (raw_command_string.c_str());
                     args.Unshift ("dummy_arg");
                     args.ParseAliasOptions (*options, result, option_arg_vector, raw_command_string);
@@ -491,7 +491,7 @@
                              options = sub_cmd_obj->GetOptions();
                          else
                              options = cmd_obj->GetOptions();
-                         options->Reset ();
+                         options->NotifyOptionParsingStarting ();
                          std::string empty_string;
                          args.Unshift ("dummy_arg");
                          args.ParseAliasOptions (*options, result, option_arg_vector, empty_string);

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Apr 12 19:18:08 2011
@@ -44,7 +44,7 @@
     plugin_name (),
     arch() 
 {
-    ResetOptionValues();
+    OptionParsingStarting();
 }
 
 CommandObjectDisassemble::CommandOptions::~CommandOptions ()
@@ -52,7 +52,7 @@
 }
 
 Error
-CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
 
@@ -140,7 +140,7 @@
 }
 
 void
-CommandObjectDisassemble::CommandOptions::ResetOptionValues ()
+CommandObjectDisassemble::CommandOptions::OptionParsingStarting ()
 {
     show_mixed = false;
     show_bytes = false;

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Tue Apr 12 19:18:08 2011
@@ -36,10 +36,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Apr 12 19:18:08 2011
@@ -41,7 +41,7 @@
     Options(interpreter)
 {
     // Keep only one place to reset the values to their defaults
-    ResetOptionValues();
+    OptionParsingStarting();
 }
 
 
@@ -50,7 +50,7 @@
 }
 
 Error
-CommandObjectExpression::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
 
@@ -93,7 +93,7 @@
 }
 
 void
-CommandObjectExpression::CommandOptions::ResetOptionValues ()
+CommandObjectExpression::CommandOptions::OptionParsingStarting ()
 {
     //language.Clear();
     debug = false;
@@ -297,7 +297,7 @@
 {
     m_exe_ctx = m_interpreter.GetExecutionContext();
 
-    m_options.Reset();
+    m_options.NotifyOptionParsingStarting();
 
     const char * expr = NULL;
 
@@ -361,6 +361,14 @@
             Args args (command, end_options - command);
             if (!ParseOptions (args, result))
                 return false;
+            
+            Error error (m_options.NotifyOptionParsingFinished());
+            if (error.Fail())
+            {
+                result.AppendError (error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
         }
     }
 

Modified: lldb/trunk/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.h (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.h Tue Apr 12 19:18:08 2011
@@ -35,10 +35,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFile.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFile.cpp Tue Apr 12 19:18:08 2011
@@ -25,41 +25,51 @@
 using namespace lldb;
 using namespace lldb_private;
 
-CommandObjectFile::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_arch ()  // Breakpoint info defaults to brief descriptions
+FileOptionGroup::FileOptionGroup() :
+    m_arch (),
+    m_arch_str ()
 {
 }
 
-CommandObjectFile::CommandOptions::~CommandOptions ()
+FileOptionGroup::~FileOptionGroup ()
 {
 }
 
-OptionDefinition
-CommandObjectFile::CommandOptions::g_option_table[] =
+OptionDefinition g_file_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Specify the architecture to be used when the process is launched."},
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+    { LLDB_OPT_SET_1 , false, "arch"    , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
 };
+const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition);
+
+uint32_t
+FileOptionGroup::GetNumDefinitions ()
+{
+    return k_num_file_options;
+}
 
 const OptionDefinition *
-CommandObjectFile::CommandOptions::GetDefinitions ()
+FileOptionGroup::GetDefinitions ()
 {
-    return g_option_table;
+    return g_file_option_table;
 }
 
 Error
-CommandObjectFile::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
+                                 uint32_t option_idx,
+                                 const char *option_arg)
 {
     Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+    char short_option = (char) g_file_option_table[option_idx].short_option;
 
     switch (short_option)
     {
         case 'a':
             {
-                PlatformSP platform_sp (m_interpreter.GetPlatform (false));
-                ArchSpec option_arch (option_arg, platform_sp.get());
+                // Save the arch value in case we specify a platform after specifying the arch
+                m_arch_str.assign (option_arg);
+                // Check to see if we already have a platform?
+                m_arch_platform_sp = interpreter.GetPlatform (false);
+                ArchSpec option_arch (option_arg, m_arch_platform_sp.get());
                 if (option_arch.IsValid())
                     m_arch = option_arch;
                 else
@@ -76,11 +86,30 @@
 }
 
 void
-CommandObjectFile::CommandOptions::ResetOptionValues ()
+FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
 {
     m_arch.Clear();
 }
 
+Error
+FileOptionGroup::OptionParsingFinished (CommandInterpreter &interpreter)
+{
+    Error error;
+    if (m_arch.IsValid())
+    {
+        PlatformSP curr_platform_sp (interpreter.GetPlatform (false));
+        if (curr_platform_sp.get() != m_arch_platform_sp.get())
+        {
+            ArchSpec option_arch (m_arch_str.c_str(), curr_platform_sp.get());
+            if (option_arch.IsValid())
+                m_arch = option_arch;
+            else
+                error.SetErrorStringWithFormat ("invalid arch '%s' for platform '%s'", m_arch_str.c_str(), curr_platform_sp->GetName());
+        }
+    }
+    return error;
+}
+
 //-------------------------------------------------------------------------
 // CommandObjectFile
 //-------------------------------------------------------------------------
@@ -90,7 +119,9 @@
                    "file",
                    "Set the file to be used as the main executable by the debugger.",
                    NULL),
-    m_options (interpreter)
+    m_option_group (interpreter),
+    m_file_options (),
+    m_platform_options(true) // Do include the "--platform" option in the platform settings by passing true
 {
     CommandArgumentEntry arg;
     CommandArgumentData file_arg;
@@ -104,6 +135,10 @@
 
     // Push the data for the first argument into the m_arguments vector.
     m_arguments.push_back (arg);
+    
+    m_option_group.Append (&m_file_options);
+    m_option_group.Append (&m_platform_options);
+    m_option_group.Finalize();
 }
 
 CommandObjectFile::~CommandObjectFile ()
@@ -113,7 +148,7 @@
 Options *
 CommandObjectFile::GetOptions ()
 {
-    return &m_options;
+    return &m_option_group;
 }
 
 bool
@@ -140,7 +175,7 @@
         TargetSP target_sp;
 
         Debugger &debugger = m_interpreter.GetDebugger();
-        Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_options.m_arch, true, target_sp);
+        Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_file_options.m_arch, true, target_sp);
 
         if (target_sp)
         {

Modified: lldb/trunk/source/Commands/CommandObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFile.h (original)
+++ lldb/trunk/source/Commands/CommandObjectFile.h Tue Apr 12 19:18:08 2011
@@ -12,11 +12,13 @@
 
 // C Includes
 // C++ Includes
+#include <vector>
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/Options.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Interpreter/CommandObject.h"
+#include "CommandObjectPlatform.h"
 
 namespace lldb_private {
 
@@ -24,6 +26,38 @@
 // CommandObjectFile
 //-------------------------------------------------------------------------
 
+    class FileOptionGroup : public OptionGroup
+    {
+    public:
+        
+        FileOptionGroup ();
+        
+        virtual
+        ~FileOptionGroup ();
+
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        virtual const OptionDefinition*
+        GetDefinitions ();
+        
+        virtual Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value);
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter);
+        
+        virtual Error
+        OptionParsingFinished (CommandInterpreter &interpreter);
+        
+        ArchSpec m_arch;
+        lldb::PlatformSP m_arch_platform_sp; // The platform that was used to resolve m_arch
+        std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
+    };
+
 class CommandObjectFile : public CommandObject
 {
 public:
@@ -40,32 +74,6 @@
     virtual Options *
     GetOptions ();
 
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
-
-        void
-        ResetOptionValues ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        ArchSpec m_arch;
-    };
     
     virtual int
     HandleArgumentCompletion (Args &input,
@@ -79,8 +87,9 @@
     
 
 private:
-    CommandOptions m_options;
-
+    OptionGroupOptions m_option_group;
+    FileOptionGroup m_file_options;
+    PlatformOptionGroup m_platform_options;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Apr 12 19:18:08 2011
@@ -102,7 +102,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues ();
+            OptionParsingStarting ();
         }
 
         virtual
@@ -111,7 +111,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             bool success = false;
@@ -133,7 +133,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             relative_frame_offset = INT32_MIN;
         }
@@ -293,7 +293,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues ();
+            OptionParsingStarting ();
         }
 
         virtual
@@ -302,7 +302,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             bool success;
@@ -350,7 +350,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             use_objc      = false;
             use_regex     = false;

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Apr 12 19:18:08 2011
@@ -734,7 +734,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -764,7 +764,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_sort_order = eSortOrderNone;
         }
@@ -1155,7 +1155,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             char short_option = (char) m_getopt_table[option_idx].val;
             uint32_t width = 0;
@@ -1167,7 +1167,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_format_array.clear();
         }
@@ -1365,7 +1365,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues();
+            OptionParsingStarting();
         }
 
         virtual
@@ -1374,7 +1374,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
 
@@ -1441,7 +1441,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_type = eLookupTypeInvalid;
             m_str.clear();

Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Tue Apr 12 19:18:08 2011
@@ -183,7 +183,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -207,7 +207,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             log_file.clear();
             log_options = 0;

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Apr 12 19:18:08 2011
@@ -39,7 +39,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues();
+            OptionParsingStarting();
         }
 
         virtual
@@ -48,7 +48,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -162,7 +162,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_format = eFormatBytesWithASCII;
             m_byte_size = 0;
@@ -438,7 +438,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues();
+            OptionParsingStarting();
         }
 
         virtual
@@ -447,7 +447,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -491,7 +491,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_format = eFormatBytes;
             m_byte_size = 1;

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Tue Apr 12 19:18:08 2011
@@ -27,24 +27,134 @@
 using namespace lldb;
 using namespace lldb_private;
 
+
+PlatformSP 
+PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter,
+                                                const char *platform_name, 
+                                                bool select, 
+                                                Error& error)
+{
+    if (platform_name && platform_name[0])
+    {
+        if (platform_sp)
+        {
+            error.SetErrorString ("platform can't be set more than once in a command");
+            return PlatformSP();
+        }
+
+        platform_sp = Platform::Create (platform_name, error);
+
+        if (platform_sp)
+        {
+                interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select);
+                if (os_version_major != UINT32_MAX)
+                {
+                    platform_sp->SetOSVersion (os_version_major,
+                                               os_version_minor,
+                                               os_version_update);
+                }
+        }
+    }
+    else
+    {
+        error.SetErrorString ("invalid platform name");
+        platform_sp.reset();
+    }
+    return platform_sp;
+}
+
+void
+PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+    platform_sp.reset();
+    os_version_major = UINT32_MAX;
+    os_version_minor = UINT32_MAX;
+    os_version_update = UINT32_MAX;
+}
+
+static OptionDefinition
+g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "platform"   , 'p', required_argument, NULL, 0, eArgTypeNone, "Specify name of the platform to use for this target, creating the platform if necessary."},
+    { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }
+};
+
+static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition);
+
+const OptionDefinition*
+PlatformOptionGroup::GetDefinitions ()
+{
+    if (m_include_platform_option)
+        return g_option_table;
+    return g_option_table + 1;
+}
+
+uint32_t
+PlatformOptionGroup::GetNumDefinitions ()
+{
+    if (m_include_platform_option)
+        return k_option_table_size;
+    return k_option_table_size - 1;
+}
+
+
+Error
+PlatformOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
+                                     uint32_t option_idx,
+                                     const char *option_arg)
+{
+    Error error;
+    if (!m_include_platform_option)
+        --option_idx;
+        
+    char short_option = (char) g_option_table[option_idx].short_option;
+    
+    switch (short_option)
+    {
+    case 'p':
+        CreatePlatformWithOptions (interpreter, option_arg, true, error);
+        break;
+
+    case 'v':
+        if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg)
+        {
+            error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
+        }
+        else
+        {
+            if (platform_sp)
+                platform_sp->SetOSVersion (os_version_major, os_version_minor, os_version_update);
+        }
+        break;
+        
+    default:
+        error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+        break;
+    }
+    return error;
+}
+
 //----------------------------------------------------------------------
 // "platform create <platform-name>"
 //----------------------------------------------------------------------
-class CommandObjectPlatformCreate : public CommandObject
+class CommandObjectPlatformSelect : public CommandObject
 {
 public:
-    CommandObjectPlatformCreate (CommandInterpreter &interpreter) :
+    CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
         CommandObject (interpreter, 
-                       "platform create",
-                       "Create a platform instance by name and select it as the current platform.",
-                       "platform create <platform-name>",
+                       "platform select",
+                       "Create a platform if needed and select it as the current platform.",
+                       "platform select <platform-name>",
                        0),
-        m_options (interpreter)
+        m_option_group (interpreter),
+        m_platform_options (false) // Don't include the "--platform" option by passing false
     {
+        m_option_group.Append (&m_platform_options);
+        m_option_group.Finalize();
     }
 
     virtual
-    ~CommandObjectPlatformCreate ()
+    ~CommandObjectPlatformSelect ()
     {
     }
 
@@ -54,20 +164,13 @@
         Error error;
         if (args.GetArgumentCount() == 1)
         {
-            PlatformSP platform_sp (Platform::Create (args.GetArgumentAtIndex (0), error));
-            
+            const bool select = true;
+            PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter,
+                                                                                  args.GetArgumentAtIndex (0), 
+                                                                                  select, 
+                                                                                  error));
             if (platform_sp)
-            {
-                m_interpreter.GetDebugger().GetPlatformList().Append (platform_sp, true);
-                if (m_options.os_version_major != UINT32_MAX)
-                {
-                    platform_sp->SetOSVersion (m_options.os_version_major,
-                                               m_options.os_version_minor,
-                                               m_options.os_version_update);
-                }
-                
                 platform_sp->GetStatus (result.GetOutputStream());
-            }
         }
         else
         {
@@ -80,86 +183,12 @@
     virtual Options *
     GetOptions ()
     {
-        return &m_options;
+        return &m_option_group;
     }
 
 protected:
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter) :
-            Options (interpreter),
-            os_version_major (UINT32_MAX),
-            os_version_minor (UINT32_MAX),
-            os_version_update (UINT32_MAX)
-        {
-        }
-
-        virtual
-        ~CommandOptions ()
-        {
-        }
-
-        virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
-        {
-            Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
-
-            switch (short_option)
-            {
-            case 'v':
-                if (Args::StringToVersion (option_arg, 
-                                           os_version_major,
-                                           os_version_minor,
-                                           os_version_update) == option_arg)
-                {
-                    error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
-                }
-                break;
-
-            default:
-                error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
-                break;
-            }
-
-            return error;
-        }
-
-        void
-        ResetOptionValues ()
-        {
-            os_version_major = UINT32_MAX;
-            os_version_minor = UINT32_MAX;
-            os_version_update = UINT32_MAX;
-        }
-
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        uint32_t os_version_major;
-        uint32_t os_version_minor;
-        uint32_t os_version_update;
-    };
-    CommandOptions m_options;
-};
-
-OptionDefinition
-CommandObjectPlatformCreate::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+    OptionGroupOptions m_option_group;
+    PlatformOptionGroup m_platform_options;
 };
 
 //----------------------------------------------------------------------
@@ -256,37 +285,6 @@
     }
 };
 
-
-//----------------------------------------------------------------------
-// "platform select <platform-name>"
-//----------------------------------------------------------------------
-class CommandObjectPlatformSelect : public CommandObject
-{
-public:
-    CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform select",
-                       "Select a platform by name to be the currently selected platform.",
-                       "platform select <platform-name>",
-                       0)
-    {
-    }
-
-    virtual
-    ~CommandObjectPlatformSelect ()
-    {
-    }
-
-    virtual bool
-    Execute (Args& args, CommandReturnObject &result)
-    {
-        result.AppendError ("command not implemented\n");
-        result.SetStatus (eReturnStatusFailed);
-        return result.Succeeded();
-    }
-};
-
-
 //----------------------------------------------------------------------
 // "platform connect <connect-url>"
 //----------------------------------------------------------------------
@@ -683,7 +681,7 @@
         }
         
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -773,7 +771,7 @@
         }
         
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             match_info.Clear();
             show_args = false;
@@ -956,11 +954,10 @@
     CommandObjectMultiword (interpreter,
                             "platform",
                             "A set of commands to manage and create platforms.",
-                            "platform [connect|create|disconnect|info|list|status|select] ...")
+                            "platform [connect|disconnect|info|list|status|select] ...")
 {
-    LoadSubCommand ("create", CommandObjectSP (new CommandObjectPlatformCreate  (interpreter)));
-    LoadSubCommand ("list"  , CommandObjectSP (new CommandObjectPlatformList    (interpreter)));
     LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect  (interpreter)));
+    LoadSubCommand ("list"  , CommandObjectSP (new CommandObjectPlatformList    (interpreter)));
     LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus  (interpreter)));
     LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect  (interpreter)));
     LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect  (interpreter)));

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.h (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.h Tue Apr 12 19:18:08 2011
@@ -15,6 +15,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/CommandObjectMultiword.h"
+#include "lldb/Interpreter/Options.h"
 
 namespace lldb_private {
 
@@ -25,21 +26,74 @@
 class CommandObjectPlatform : public CommandObjectMultiword
 {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
     CommandObjectPlatform(CommandInterpreter &interpreter);
 
     virtual
     ~CommandObjectPlatform();
 
-private:
-    //------------------------------------------------------------------
-    // For CommandObjectPlatform only
-    //------------------------------------------------------------------
+    private:
     DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform);
 };
 
+    
+//-------------------------------------------------------------------------
+// PlatformOptionGroup
+//
+// Make platform options available to to any other command in case they 
+// need them. The "file" command needs them, and by exposing them we can
+// reuse the platform command options for any command, we can keep things
+// consistent.
+//-------------------------------------------------------------------------
+class PlatformOptionGroup : public OptionGroup
+{
+public:
+    
+    PlatformOptionGroup (bool include_platform_option) :
+        m_include_platform_option (include_platform_option),
+        platform_sp (),
+        os_version_major (UINT32_MAX),
+        os_version_minor (UINT32_MAX),
+        os_version_update (UINT32_MAX)
+    {
+    }
+    
+    virtual
+    ~PlatformOptionGroup ()
+    {
+    }
+    
+    virtual uint32_t
+    GetNumDefinitions ();
+    
+    virtual const OptionDefinition*
+    GetDefinitions ();
+    
+    virtual Error
+    SetOptionValue (CommandInterpreter &interpreter,
+                    uint32_t option_idx,
+                    const char *option_value);
+    
+    lldb::PlatformSP 
+    CreatePlatformWithOptions (CommandInterpreter &interpreter,
+                               const char *platform_name, 
+                               bool select, 
+                               Error& error);
+
+    virtual void
+    OptionParsingStarting (CommandInterpreter &interpreter);
+        
+    // Instance variables to hold the values for command options.
+    
+    lldb::PlatformSP platform_sp;
+    uint32_t os_version_major;
+    uint32_t os_version_minor;
+    uint32_t os_version_update;
+protected:
+    bool m_include_platform_option;
+};
+
+    
+    
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectPlatform_h_

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Apr 12 19:18:08 2011
@@ -43,8 +43,8 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
 
         ~CommandOptions ()
@@ -52,7 +52,7 @@
         }
 
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -80,7 +80,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             stop_at_entry = false;
             in_new_tty = false;
@@ -423,8 +423,8 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
 
         ~CommandOptions ()
@@ -432,7 +432,7 @@
         }
 
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -467,7 +467,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             pid = LLDB_INVALID_PROCESS_ID;
             name.clear();
@@ -973,8 +973,8 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
         
         ~CommandOptions ()
@@ -982,7 +982,7 @@
         }
         
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -1001,7 +1001,7 @@
         }
         
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             plugin_name.clear();
         }
@@ -1559,7 +1559,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options (interpreter)
         {
-            ResetOptionValues ();
+            OptionParsingStarting ();
         }
 
         ~CommandOptions ()
@@ -1567,7 +1567,7 @@
         }
 
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -1591,7 +1591,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             stop.clear();
             notify.clear();

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Apr 12 19:18:08 2011
@@ -159,7 +159,7 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            ResetOptionValues();
+            OptionParsingStarting();
         }
         
         virtual
@@ -168,7 +168,7 @@
         }
         
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -186,7 +186,7 @@
         }
         
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_format = eFormatBytes;
         }

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Tue Apr 12 19:18:08 2011
@@ -263,7 +263,7 @@
 }
 
 Error
-CommandObjectSettingsSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+CommandObjectSettingsSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;
@@ -285,7 +285,7 @@
 }
 
 void
-CommandObjectSettingsSet::CommandOptions::ResetOptionValues ()
+CommandObjectSettingsSet::CommandOptions::OptionParsingStarting ()
 {
     m_override = true;
     m_reset = false;

Modified: lldb/trunk/source/Commands/CommandObjectSettings.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.h Tue Apr 12 19:18:08 2011
@@ -65,10 +65,10 @@
         ~CommandOptions ();
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg);
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
 
         void
-        ResetOptionValues ();
+        OptionParsingStarting ();
 
         const OptionDefinition*
         GetDefinitions ();

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Apr 12 19:18:08 2011
@@ -47,7 +47,7 @@
         }
 
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             const char short_option = g_option_table[option_idx].short_option;
@@ -72,7 +72,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             file_spec.Clear();
             file_name.clear();
@@ -159,7 +159,7 @@
         }
 
         Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             const char short_option = g_option_table[option_idx].short_option;
@@ -197,7 +197,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             file_spec.Clear();
             file_name.clear();

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Apr 12 19:18:08 2011
@@ -508,7 +508,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -587,7 +587,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_class_name.clear();
             m_function_name.clear();

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Apr 12 19:18:08 2011
@@ -252,8 +252,8 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options(interpreter)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
 
         virtual
@@ -262,7 +262,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -298,7 +298,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_count = -1;
             m_start = 0;
@@ -490,8 +490,8 @@
         CommandOptions (CommandInterpreter &interpreter) :
             Options (interpreter)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
 
         virtual
@@ -500,7 +500,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -542,7 +542,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_avoid_no_debug = true;
             m_run_mode = eOnlyDuringStepping;
@@ -981,8 +981,8 @@
             m_thread_idx(LLDB_INVALID_THREAD_ID),
             m_frame_idx(LLDB_INVALID_FRAME_ID)
         {
-            // Keep default values of all options in one place: ResetOptionValues ()
-            ResetOptionValues ();
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
 
         virtual
@@ -991,7 +991,7 @@
         }
 
         virtual Error
-        SetOptionValue (int option_idx, const char *option_arg)
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
             char short_option = (char) m_getopt_table[option_idx].val;
@@ -1040,7 +1040,7 @@
         }
 
         void
-        ResetOptionValues ()
+        OptionParsingStarting ()
         {
             m_thread_idx = LLDB_INVALID_THREAD_ID;
             m_frame_idx = 0;

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Apr 12 19:18:08 2011
@@ -177,7 +177,7 @@
     if (options != NULL)
     {
         Error error;
-        options->Reset();
+        options->NotifyOptionParsingStarting();
 
         // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1,
         // so we need to push a dummy value into position zero.
@@ -187,7 +187,15 @@
         // The "dummy_string" will have already been removed by ParseOptions,
         // so no need to remove it.
 
-        if (error.Fail() || !options->VerifyOptions (result))
+        if (error.Success())
+            error = options->NotifyOptionParsingFinished();
+
+        if (error.Success())
+        {
+            if (options->VerifyOptions (result))
+                return true;
+        }
+        else
         {
             const char *error_cstr = error.AsCString();
             if (error_cstr)
@@ -200,10 +208,9 @@
                 // No error string, output the usage information into result
                 options->GenerateOptionUsage (result.GetErrorStream(), this);
             }
-            // Set the return status to failed (this was an error).
-            result.SetStatus (eReturnStatusFailed);
-            return false;
         }
+        result.SetStatus (eReturnStatusFailed);
+        return false;
     }
     return true;
 }

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Tue Apr 12 19:18:08 2011
@@ -41,11 +41,17 @@
 }
 
 void
-Options::Reset ()
+Options::NotifyOptionParsingStarting ()
 {
     m_seen_options.clear();
     // Let the subclass reset its option values
-    ResetOptionValues ();
+    OptionParsingStarting ();
+}
+
+Error
+Options::NotifyOptionParsingFinished ()
+{
+    return OptionParsingFinished ();
 }
 
 void
@@ -885,3 +891,80 @@
                                                                 matches);
     
 }
+
+
+
+
+void
+OptionGroupOptions::Append (OptionGroup* group)
+{
+    m_option_groups.push_back (group);
+    const OptionDefinition* group_option_defs = group->GetDefinitions ();
+    const uint32_t group_option_count = group->GetNumDefinitions();
+    for (uint32_t i=0; i<group_option_count; ++i)
+        m_option_defs.push_back (group_option_defs[i]);
+}
+
+void
+OptionGroupOptions::Append (OptionGroup* group, uint32_t usage_mask)
+{
+    m_option_groups.push_back (group);
+    const OptionDefinition* group_option_defs = group->GetDefinitions ();
+    const uint32_t group_option_count = group->GetNumDefinitions();
+    for (uint32_t i=0; i<group_option_count; ++i)
+    {
+        m_option_defs.push_back (group_option_defs[i]);
+        m_option_defs.back().usage_mask = usage_mask;
+    }
+}
+
+void
+OptionGroupOptions::Finalize ()
+{
+    m_did_finalize = true;
+    OptionDefinition empty_option_def = { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL };
+    m_option_defs.push_back (empty_option_def);
+}
+
+Error
+OptionGroupOptions::SetOptionValue (uint32_t option_idx,  
+                                    const char *option_value)
+{
+    // After calling OptionGroupOptions::Append(...), you must finalize the groups
+    // by calling OptionGroupOptions::Finlize()
+    assert (m_did_finalize);
+
+    uint32_t curr_idx = 0;
+    OptionGroupsType::iterator pos, end = m_option_groups.end();
+    for (pos = m_option_groups.begin(); pos != end; ++pos)
+    {
+        const uint32_t num_group_definitions = (*pos)->GetNumDefinitions();
+        if (option_idx < curr_idx + num_group_definitions)
+            return (*pos)->SetOptionValue (m_interpreter, option_idx - curr_idx, option_value);
+        curr_idx += num_group_definitions;
+    }
+    Error error;
+    error.SetErrorString ("invalid option index"); // Shouldn't happen...
+    return error;
+}
+
+void
+OptionGroupOptions::OptionParsingStarting ()
+{
+    OptionGroupsType::iterator pos, end = m_option_groups.end();
+    for (pos = m_option_groups.begin(); pos != end; ++pos)
+        (*pos)->OptionParsingStarting (m_interpreter);
+}
+Error
+OptionGroupOptions::OptionParsingFinished ()
+{
+    Error error;
+    OptionGroupsType::iterator pos, end = m_option_groups.end();
+    for (pos = m_option_groups.begin(); pos != end; ++pos)
+    {
+        error = (*pos)->OptionParsingFinished (m_interpreter);
+        if (error.Fail())
+            return error;
+    }
+    return error;
+}

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=129415&r1=129414&r2=129415&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Apr 12 19:18:08 2011
@@ -346,7 +346,7 @@
 }
 
 Error
-ProcessLaunchCommandOptions::SetOptionValue (int option_idx, const char *option_arg)
+ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
     char short_option = (char) m_getopt_table[option_idx].val;





More information about the lldb-commits mailing list