[Lldb-commits] [lldb] r158235 - in /lldb/trunk: include/lldb/Interpreter/ scripts/Python/interface/ source/Commands/ source/Interpreter/

Jim Ingham jingham at apple.com
Fri Jun 8 14:56:11 PDT 2012


Author: jingham
Date: Fri Jun  8 16:56:10 2012
New Revision: 158235

URL: http://llvm.org/viewvc/llvm-project?rev=158235&view=rev
Log:
Make raw & parsed commands subclasses of CommandObject rather than having the raw version implement an 
Execute which was never going to get run and another ExecuteRawCommandString.  Took the knowledge of how
to prepare raw & parsed commands out of CommandInterpreter and put it in CommandObject where it belongs.

Also took all the cases where there were the subcommands of Multiword commands declared in the .h file for
the overall command and moved them into the .cpp file.

Made the CommandObject flags work for raw as well as parsed commands.

Made "expr" use the flags so that it requires you to be paused to run "expr".


Modified:
    lldb/trunk/include/lldb/Interpreter/CommandObject.h
    lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h
    lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
    lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
    lldb/trunk/scripts/Python/interface/SBWatchpoint.i
    lldb/trunk/source/Commands/CommandObjectApropos.cpp
    lldb/trunk/source/Commands/CommandObjectApropos.h
    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/CommandObjectCrossref.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/CommandObjectFrame.cpp
    lldb/trunk/source/Commands/CommandObjectHelp.cpp
    lldb/trunk/source/Commands/CommandObjectHelp.h
    lldb/trunk/source/Commands/CommandObjectLog.cpp
    lldb/trunk/source/Commands/CommandObjectMemory.cpp
    lldb/trunk/source/Commands/CommandObjectMultiword.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectQuit.cpp
    lldb/trunk/source/Commands/CommandObjectQuit.h
    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/CommandObjectSyntax.cpp
    lldb/trunk/source/Commands/CommandObjectSyntax.h
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/Commands/CommandObjectVersion.cpp
    lldb/trunk/source/Commands/CommandObjectVersion.h
    lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
    lldb/trunk/source/Commands/CommandObjectWatchpoint.h
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp
    lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
    lldb/trunk/source/Interpreter/CommandObjectScript.cpp
    lldb/trunk/source/Interpreter/CommandObjectScript.h

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Fri Jun  8 16:56:10 2012
@@ -145,7 +145,7 @@
     IsMultiwordObject () { return false; }
 
     virtual bool
-    WantsRawCommandString() { return false; }
+    WantsRawCommandString() = 0;
 
     // By default, WantsCompletion = !WantsRawCommandString.
     // Subclasses who want raw command string but desire, for example,
@@ -198,22 +198,6 @@
     ParseOptions (Args& args,
                   CommandReturnObject &result);
 
-    bool
-    ExecuteWithOptions (Args& command,
-                        CommandReturnObject &result);
-
-    virtual bool
-    ExecuteRawCommandString (const char *command,
-                             CommandReturnObject &result)
-    {
-        return false;
-    }
-
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result) = 0;
-
     void
     SetCommandName (const char *name);
 
@@ -337,7 +321,10 @@
     ///     A reference to the Flags member variable.
     //------------------------------------------------------------------
     Flags&
-    GetFlags();
+    GetFlags()
+    {
+        return m_flags;
+    }
 
     //------------------------------------------------------------------
     /// The flags const accessor.
@@ -346,7 +333,23 @@
     ///     A const reference to the Flags member variable.
     //------------------------------------------------------------------
     const Flags&
-    GetFlags() const;
+    GetFlags() const
+    {
+        return m_flags;
+    }
+    
+    //------------------------------------------------------------------
+    /// Check the command flags against the interpreter's current execution context.
+    ///
+    /// @param[out] result
+    ///     A command result object, if it is not okay to run the command this will be
+    ///     filled in with a suitable error.
+    ///
+    /// @return
+    ///     \b true if it is okay to run this command, \b false otherwise.
+    //------------------------------------------------------------------
+    bool
+    CheckFlags (CommandReturnObject &result);
     
     //------------------------------------------------------------------
     /// Get the command that appropriate for a "repeat" of the current command.
@@ -382,6 +385,9 @@
         m_command_override_callback = callback;
         m_command_override_baton = baton;
     }
+    
+    virtual bool
+    Execute (const char *args_string, CommandReturnObject &result) = 0;
 
 protected:
     CommandInterpreter &m_interpreter;
@@ -394,13 +400,66 @@
     std::vector<CommandArgumentEntry> m_arguments;
     CommandOverrideCallback m_command_override_callback;
     void * m_command_override_baton;
+    
     // Helper function to populate IDs or ID ranges as the command argument data
     // to the specified command argument entry.
     static void
     AddIDsArgumentData(CommandArgumentEntry &arg, lldb::CommandArgumentType ID, lldb::CommandArgumentType IDRange);
+    
+};
+
+class CommandObjectParsed : public CommandObject
+{
+public:
+
+    CommandObjectParsed (CommandInterpreter &interpreter,
+                         const char *name,
+                         const char *help = NULL,
+                         const char *syntax = NULL,
+                         uint32_t flags = 0) :
+        CommandObject (interpreter, name, help, syntax, flags) {}
+
+    virtual
+    ~CommandObjectParsed () {};
+    
+    virtual bool
+    Execute (const char *args_string, CommandReturnObject &result);
+    
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result) = 0;
+    
+    virtual bool
+    WantsRawCommandString() { return false; };
+};
 
+class CommandObjectRaw : public CommandObject
+{
+public:
+
+    CommandObjectRaw (CommandInterpreter &interpreter,
+                         const char *name,
+                         const char *help = NULL,
+                         const char *syntax = NULL,
+                         uint32_t flags = 0) :
+        CommandObject (interpreter, name, help, syntax, flags) {}
+
+    virtual
+    ~CommandObjectRaw () {};
+    
+    virtual bool
+    Execute (const char *args_string, CommandReturnObject &result);
+    
+protected:    
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result) = 0;
+
+    virtual bool
+    WantsRawCommandString() { return true; };
 };
 
+
 } // namespace lldb_private
 
 

Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h Fri Jun  8 16:56:10 2012
@@ -23,7 +23,7 @@
 // CommandObjectCrossref
 //-------------------------------------------------------------------------
 
-class CommandObjectCrossref : public CommandObject
+class CommandObjectCrossref : public CommandObjectParsed
 {
 public:
     CommandObjectCrossref (CommandInterpreter &interpreter,
@@ -38,10 +38,6 @@
     GenerateHelpText (CommandReturnObject &result);
 
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual bool
     IsCrossRefObject ();
 
     virtual void
@@ -50,6 +46,11 @@
     const char **
     GetObjectTypes () const;
 
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result);
+
 private:
     Args m_crossref_object_types;
 };

Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h Fri Jun  8 16:56:10 2012
@@ -26,6 +26,9 @@
 
 class CommandObjectMultiword : public CommandObject
 {
+// These two want to iterate over the subcommand dictionary.
+friend class CommandInterpreter;
+friend class CommandObjectSyntax;
 public:
     CommandObjectMultiword (CommandInterpreter &interpreter,
                             const char *name,
@@ -53,8 +56,7 @@
     GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL);
 
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
+    WantsRawCommandString() { return false; };
 
     virtual int
     HandleCompletion (Args &input,
@@ -67,6 +69,11 @@
 
     virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index);
 
+    virtual bool
+    Execute (const char *args_string,
+             CommandReturnObject &result);
+protected:
+
     CommandObject::CommandMap m_subcommand_dict;
 };
 

Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Fri Jun  8 16:56:10 2012
@@ -25,7 +25,7 @@
 // CommandObjectRegexCommand
 //-------------------------------------------------------------------------
 
-class CommandObjectRegexCommand : public CommandObject
+class CommandObjectRegexCommand : public CommandObjectRaw
 {
 public:
 
@@ -38,18 +38,6 @@
     virtual
     ~CommandObjectRegexCommand ();
 
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *command,
-                             CommandReturnObject &result);
-
-
     bool
     AddRegexCommand (const char *re_cstr, const char *command_cstr);
 
@@ -60,6 +48,9 @@
     }
 
 protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result);
+
     struct Entry
     {
         RegularExpression regex;

Modified: lldb/trunk/scripts/Python/interface/SBWatchpoint.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBWatchpoint.i?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBWatchpoint.i (original)
+++ lldb/trunk/scripts/Python/interface/SBWatchpoint.i Fri Jun  8 16:56:10 2012
@@ -31,6 +31,9 @@
     bool
     IsValid();
 
+    SBError
+    GetError();
+
     watch_id_t
     GetID ();
 

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Fri Jun  8 16:56:10 2012
@@ -27,10 +27,10 @@
 //-------------------------------------------------------------------------
 
 CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "apropos",
-                   "Find a list of debugger commands related to a particular word/subject.",
-                   NULL)
+    CommandObjectParsed (interpreter,
+                         "apropos",
+                         "Find a list of debugger commands related to a particular word/subject.",
+                         NULL)
 {
     CommandArgumentEntry arg;
     CommandArgumentData search_word_arg;
@@ -52,11 +52,7 @@
 
 
 bool
-CommandObjectApropos::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
 {
     const int argc = args.GetArgumentCount ();
 

Modified: lldb/trunk/source/Commands/CommandObjectApropos.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.h (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.h Fri Jun  8 16:56:10 2012
@@ -22,7 +22,7 @@
 // CommandObjectApropos
 //-------------------------------------------------------------------------
 
-class CommandObjectApropos : public CommandObject
+class CommandObjectApropos : public CommandObjectParsed
 {
 public:
 
@@ -31,8 +31,9 @@
     virtual
     ~CommandObjectApropos ();
 
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result);
 
 

Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Fri Jun  8 16:56:10 2012
@@ -77,10 +77,10 @@
 }
 
 CommandObjectArgs::CommandObjectArgs (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "args",
-                   "When stopped at the start of a function, reads function arguments of type (u?)int(8|16|32|64)_t, (void|char)*",
-                   "args"),
+    CommandObjectParsed (interpreter,
+                         "args",
+                         "When stopped at the start of a function, reads function arguments of type (u?)int(8|16|32|64)_t, (void|char)*",
+                         "args"),
     m_options (interpreter)
 {
 }
@@ -96,11 +96,7 @@
 }
 
 bool
-CommandObjectArgs::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
 {
     ConstString target_triple;
     

Modified: lldb/trunk/source/Commands/CommandObjectArgs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.h (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.h Fri Jun  8 16:56:10 2012
@@ -20,7 +20,7 @@
 
 namespace lldb_private {
     
-    class CommandObjectArgs : public CommandObject
+    class CommandObjectArgs : public CommandObjectParsed
     {
     public:
         
@@ -57,16 +57,14 @@
         GetOptions ();
         
         
-        virtual bool
-        Execute (    Args& command,
-                 CommandReturnObject &result);
-        
-        virtual bool
-        WantsRawCommandString() { return false; }
-        
     protected:
         
         CommandOptions m_options;
+
+        virtual bool
+        DoExecute (    Args& command,
+                 CommandReturnObject &result);
+        
     };
     
 } // namespace lldb_private

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Jun  8 16:56:10 2012
@@ -43,39 +43,543 @@
 }
 
 //-------------------------------------------------------------------------
-// CommandObjectBreakpointSet::CommandOptions
+// CommandObjectBreakpointSet
 //-------------------------------------------------------------------------
-#pragma mark Set::CommandOptions
 
-CommandObjectBreakpointSet::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_condition (),
-    m_filenames (),
-    m_line_num (0),
-    m_column (0),
-    m_check_inlines (true),
-    m_func_names (),
-    m_func_name_type_mask (eFunctionNameTypeNone),
-    m_func_regexp (),
-    m_source_text_regexp(),
-    m_modules (),
-    m_load_addr(),
-    m_ignore_count (0),
-    m_thread_id(LLDB_INVALID_THREAD_ID),
-    m_thread_index (UINT32_MAX),
-    m_thread_name(),
-    m_queue_name(),
-    m_catch_bp (false),
-    m_throw_bp (false),
-    m_language (eLanguageTypeUnknown),
-    m_skip_prologue (eLazyBoolCalculate)
-{
-}
 
-CommandObjectBreakpointSet::CommandOptions::~CommandOptions ()
+class CommandObjectBreakpointSet : public CommandObjectParsed
 {
-}
+public:
+
+    typedef enum BreakpointSetType
+    {
+        eSetTypeInvalid,
+        eSetTypeFileAndLine,
+        eSetTypeAddress,
+        eSetTypeFunctionName,
+        eSetTypeFunctionRegexp,
+        eSetTypeSourceRegexp,
+        eSetTypeException
+    } BreakpointSetType;
+
+    CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "breakpoint set", 
+                             "Sets a breakpoint or set of breakpoints in the executable.", 
+                             "breakpoint set <cmd-options>"),
+        m_options (interpreter)
+    {
+    }
+
+
+    virtual
+    ~CommandObjectBreakpointSet () {}
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+    class CommandOptions : public Options
+    {
+    public:
+
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_condition (),
+            m_filenames (),
+            m_line_num (0),
+            m_column (0),
+            m_check_inlines (true),
+            m_func_names (),
+            m_func_name_type_mask (eFunctionNameTypeNone),
+            m_func_regexp (),
+            m_source_text_regexp(),
+            m_modules (),
+            m_load_addr(),
+            m_ignore_count (0),
+            m_thread_id(LLDB_INVALID_THREAD_ID),
+            m_thread_index (UINT32_MAX),
+            m_thread_name(),
+            m_queue_name(),
+            m_catch_bp (false),
+            m_throw_bp (false),
+            m_language (eLanguageTypeUnknown),
+            m_skip_prologue (eLazyBoolCalculate)
+        {
+        }
+
+
+        virtual
+        ~CommandOptions () {}
+
+        virtual Error
+        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 'a':
+                    m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
+                    if (m_load_addr == LLDB_INVALID_ADDRESS)
+                        m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
+
+                    if (m_load_addr == LLDB_INVALID_ADDRESS)
+                        error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
+                    break;
+
+                case 'C':
+                    m_column = Args::StringToUInt32 (option_arg, 0);
+                    break;
+
+                case 'c':
+                    m_condition.assign(option_arg);
+                    break;
+
+                case 'f':
+                    m_filenames.AppendIfUnique (FileSpec(option_arg, false));
+                    break;
+
+                case 'l':
+                    m_line_num = Args::StringToUInt32 (option_arg, 0);
+                    break;
+
+                case 'b':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeBase;
+                    break;
+
+                case 'n':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeAuto;
+                    break;
+
+                case 'F':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeFull;
+                    break;
+
+                case 'S':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeSelector;
+                    break;
+
+                case 'M':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeMethod;
+                    break;
+
+                case 'p':
+                    m_source_text_regexp.assign (option_arg);
+                    break;
+                    
+                case 'r':
+                    m_func_regexp.assign (option_arg);
+                    break;
+
+                case 's':
+                    {
+                        m_modules.AppendIfUnique (FileSpec (option_arg, false));
+                        break;
+                    }
+                case 'i':
+                {
+                    m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_ignore_count == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
+                }
+                break;
+                case 't' :
+                {
+                    m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
+                    if (m_thread_id == LLDB_INVALID_THREAD_ID)
+                       error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
+                }
+                break;
+                case 'T':
+                    m_thread_name.assign (option_arg);
+                    break;
+                case 'q':
+                    m_queue_name.assign (option_arg);
+                    break;
+                case 'x':
+                {
+                    m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_thread_id == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
+                    
+                }
+                break;
+                case 'E':
+                {
+                    LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
+
+                    switch (language)
+                    {
+                        case eLanguageTypeC89:
+                        case eLanguageTypeC:
+                        case eLanguageTypeC99:
+                            m_language = eLanguageTypeC;
+                            break;
+                        case eLanguageTypeC_plus_plus:
+                            m_language = eLanguageTypeC_plus_plus;
+                            break;
+                        case eLanguageTypeObjC:
+                            m_language = eLanguageTypeObjC;
+                            break;
+                        case eLanguageTypeObjC_plus_plus:
+                            error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
+                            break;
+                        case eLanguageTypeUnknown:
+                            error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
+                            break;
+                        default:
+                            error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
+                    }
+                }
+                break;
+                case 'w':
+                {
+                    bool success;
+                    m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
+                }
+                break;
+                case 'h':
+                {
+                    bool success;
+                    m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
+                }
+                case 'K':
+                {
+                    bool success;
+                    bool value;
+                    value = Args::StringToBoolean (option_arg, true, &success);
+                    if (value)
+                        m_skip_prologue = eLazyBoolYes;
+                    else
+                        m_skip_prologue = eLazyBoolNo;
+                        
+                    if (!success)
+                        error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
+                }
+                break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
+
+            return error;
+        }
+        void
+        OptionParsingStarting ()
+        {
+            m_condition.clear();
+            m_filenames.Clear();
+            m_line_num = 0;
+            m_column = 0;
+            m_func_names.clear();
+            m_func_name_type_mask = 0;
+            m_func_regexp.clear();
+            m_load_addr = LLDB_INVALID_ADDRESS;
+            m_modules.Clear();
+            m_ignore_count = 0;
+            m_thread_id = LLDB_INVALID_THREAD_ID;
+            m_thread_index = UINT32_MAX;
+            m_thread_name.clear();
+            m_queue_name.clear();
+            m_language = eLanguageTypeUnknown;
+            m_catch_bp = false;
+            m_throw_bp = true;
+            m_skip_prologue = eLazyBoolCalculate;
+        }
+    
+        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.
+
+        std::string m_condition;
+        FileSpecList m_filenames;
+        uint32_t m_line_num;
+        uint32_t m_column;
+        bool m_check_inlines;
+        std::vector<std::string> m_func_names;
+        uint32_t m_func_name_type_mask;
+        std::string m_func_regexp;
+        std::string m_source_text_regexp;
+        FileSpecList m_modules;
+        lldb::addr_t m_load_addr;
+        uint32_t m_ignore_count;
+        lldb::tid_t m_thread_id;
+        uint32_t m_thread_index;
+        std::string m_thread_name;
+        std::string m_queue_name;
+        bool m_catch_bp;
+        bool m_throw_bp;
+        lldb::LanguageType m_language;
+        LazyBool m_skip_prologue;
+
+    };
+
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target.  Must set target before setting breakpoints (see 'target create' command).");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+
+        // The following are the various types of breakpoints that could be set:
+        //   1).  -f -l -p  [-s -g]   (setting breakpoint by source location)
+        //   2).  -a  [-s -g]         (setting breakpoint by address)
+        //   3).  -n  [-s -g]         (setting breakpoint by function name)
+        //   4).  -r  [-s -g]         (setting breakpoint by function name regular expression)
+        //   5).  -p -f               (setting a breakpoint by comparing a reg-exp to source text)
+        //   6).  -E [-w -h]          (setting a breakpoint for exceptions for a given language.)
+
+        BreakpointSetType break_type = eSetTypeInvalid;
+
+        if (m_options.m_line_num != 0)
+            break_type = eSetTypeFileAndLine;
+        else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
+            break_type = eSetTypeAddress;
+        else if (!m_options.m_func_names.empty())
+            break_type = eSetTypeFunctionName;
+        else if  (!m_options.m_func_regexp.empty())
+            break_type = eSetTypeFunctionRegexp;
+        else if (!m_options.m_source_text_regexp.empty())
+            break_type = eSetTypeSourceRegexp;
+        else if (m_options.m_language != eLanguageTypeUnknown)
+            break_type = eSetTypeException;
+
+        Breakpoint *bp = NULL;
+        FileSpec module_spec;
+        bool use_module = false;
+        int num_modules = m_options.m_modules.GetSize();
+        
+        const bool internal = false;
+
+        if ((num_modules > 0) && (break_type != eSetTypeAddress))
+            use_module = true;
+
+        switch (break_type)
+        {
+            case eSetTypeFileAndLine: // Breakpoint by source position
+                {
+                    FileSpec file;
+                    uint32_t num_files = m_options.m_filenames.GetSize();
+                    if (num_files == 0)
+                    {
+                        if (!GetDefaultFile (target, file, result))
+                        {
+                            result.AppendError("No file supplied and no default file available.");
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
+                        }
+                    }
+                    else if (num_files > 1)
+                    {
+                        result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
+                    else
+                        file = m_options.m_filenames.GetFileSpecAtIndex(0);
+                        
+                    bp = target->CreateBreakpoint (&(m_options.m_modules),
+                                                   file,
+                                                   m_options.m_line_num,
+                                                   m_options.m_check_inlines,
+                                                   m_options.m_skip_prologue,
+                                                   internal).get();
+                }
+                break;
+
+            case eSetTypeAddress: // Breakpoint by address
+                bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
+                break;
+
+            case eSetTypeFunctionName: // Breakpoint by function name
+                {
+                    uint32_t name_type_mask = m_options.m_func_name_type_mask;
+                    
+                    if (name_type_mask == 0)
+                        name_type_mask = eFunctionNameTypeAuto;
+                    
+                    bp = target->CreateBreakpoint (&(m_options.m_modules),
+                                                   &(m_options.m_filenames),
+                                                   m_options.m_func_names,
+                                                   name_type_mask,
+                                                   m_options.m_skip_prologue,
+                                                   internal).get();
+                }
+                break;
+
+            case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
+                {
+                    RegularExpression regexp(m_options.m_func_regexp.c_str());
+                    if (!regexp.IsValid())
+                    {
+                        char err_str[1024];
+                        regexp.GetErrorAsCString(err_str, sizeof(err_str));
+                        result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
+                                                     err_str);
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
+                    
+                    bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
+                                                            &(m_options.m_filenames),
+                                                            regexp,
+                                                            m_options.m_skip_prologue,
+                                                            internal).get();
+                }
+                break;
+            case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
+                {
+                    int num_files = m_options.m_filenames.GetSize();
+                    
+                    if (num_files == 0)
+                    {
+                        FileSpec file;
+                        if (!GetDefaultFile (target, file, result))
+                        {
+                            result.AppendError ("No files provided and could not find default file.");
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
+                        }
+                        else
+                        {
+                            m_options.m_filenames.Append (file);
+                        }
+                    }
+                    
+                    RegularExpression regexp(m_options.m_source_text_regexp.c_str());
+                    if (!regexp.IsValid())
+                    {
+                        char err_str[1024];
+                        regexp.GetErrorAsCString(err_str, sizeof(err_str));
+                        result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
+                                                     err_str);
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
+                    bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
+                }
+                break;
+            case eSetTypeException:
+                {
+                    bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
+                }
+                break;
+            default:
+                break;
+        }
+
+        // Now set the various options that were passed in:
+        if (bp)
+        {
+            if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
+                bp->SetThreadID (m_options.m_thread_id);
+                
+            if (m_options.m_thread_index != UINT32_MAX)
+                bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
+            
+            if (!m_options.m_thread_name.empty())
+                bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
+            
+            if (!m_options.m_queue_name.empty())
+                bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
+                
+            if (m_options.m_ignore_count != 0)
+                bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
+
+            if (!m_options.m_condition.empty())
+                bp->GetOptions()->SetCondition(m_options.m_condition.c_str());
+        }
+        
+        if (bp)
+        {
+            Stream &output_stream = result.GetOutputStream();
+            output_stream.Printf ("Breakpoint created: ");
+            bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
+            output_stream.EOL();
+            // Don't print out this warning for exception breakpoints.  They can get set before the target
+            // is set, but we won't know how to actually set the breakpoint till we run.
+            if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
+                output_stream.Printf ("WARNING:  Unable to resolve breakpoint to any actual locations.\n");
+            result.SetStatus (eReturnStatusSuccessFinishResult);
+        }
+        else if (!bp)
+        {
+            result.AppendError ("Breakpoint creation failed: No breakpoint created.");
+            result.SetStatus (eReturnStatusFailed);
+        }
+
+        return result.Succeeded();
+    }
 
+private:
+    bool
+    GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
+    {
+        uint32_t default_line;
+        // First use the Source Manager's default file. 
+        // Then use the current stack frame's file.
+        if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
+        {
+            StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
+            if (cur_frame == NULL)
+            {
+                result.AppendError ("No selected frame to use to find the default file.");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+            else if (!cur_frame->HasDebugInformation())
+            {
+                result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+            else
+            {
+                const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
+                if (sc.line_entry.file)
+                {
+                    file = sc.line_entry.file;
+                }
+                else
+                {
+                    result.AppendError ("Can't find the file for the selected frame to use as the default file.");
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+    
+    CommandOptions m_options;
+};
 // If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
 // update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
 #define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
@@ -160,1522 +664,1120 @@
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
-const OptionDefinition*
-CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
+//-------------------------------------------------------------------------
+// CommandObjectBreakpointModify
+//-------------------------------------------------------------------------
+#pragma mark Modify
 
-Error
-CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
+class CommandObjectBreakpointModify : public CommandObjectParsed
 {
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+public:
 
-    switch (short_option)
+    CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "breakpoint modify", 
+                             "Modify the options on a breakpoint or set of breakpoints in the executable.  "
+                             "If no breakpoint is specified, acts on the last created breakpoint.  "
+                             "With the exception of -e, -d and -i, passing an empty argument clears the modification.", 
+                             NULL),
+        m_options (interpreter)
     {
-        case 'a':
-            m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
-            if (m_load_addr == LLDB_INVALID_ADDRESS)
-                m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
-
-            if (m_load_addr == LLDB_INVALID_ADDRESS)
-                error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
-            break;
-
-        case 'C':
-            m_column = Args::StringToUInt32 (option_arg, 0);
-            break;
-
-        case 'c':
-            m_condition.assign(option_arg);
-            break;
-
-        case 'f':
-            m_filenames.AppendIfUnique (FileSpec(option_arg, false));
-            break;
-
-        case 'l':
-            m_line_num = Args::StringToUInt32 (option_arg, 0);
-            break;
-
-        case 'b':
-            m_func_names.push_back (option_arg);
-            m_func_name_type_mask |= eFunctionNameTypeBase;
-            break;
-
-        case 'n':
-            m_func_names.push_back (option_arg);
-            m_func_name_type_mask |= eFunctionNameTypeAuto;
-            break;
-
-        case 'F':
-            m_func_names.push_back (option_arg);
-            m_func_name_type_mask |= eFunctionNameTypeFull;
-            break;
-
-        case 'S':
-            m_func_names.push_back (option_arg);
-            m_func_name_type_mask |= eFunctionNameTypeSelector;
-            break;
-
-        case 'M':
-            m_func_names.push_back (option_arg);
-            m_func_name_type_mask |= eFunctionNameTypeMethod;
-            break;
-
-        case 'p':
-            m_source_text_regexp.assign (option_arg);
-            break;
-            
-        case 'r':
-            m_func_regexp.assign (option_arg);
-            break;
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back (arg);   
+    }
 
-        case 's':
-            {
-                m_modules.AppendIfUnique (FileSpec (option_arg, false));
-                break;
-            }
-        case 'i':
+
+    virtual
+    ~CommandObjectBreakpointModify () {}
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+    class CommandOptions : public Options
+    {
+    public:
+
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_ignore_count (0),
+            m_thread_id(LLDB_INVALID_THREAD_ID),
+            m_thread_id_passed(false),
+            m_thread_index (UINT32_MAX),
+            m_thread_index_passed(false),
+            m_thread_name(),
+            m_queue_name(),
+            m_condition (),
+            m_enable_passed (false),
+            m_enable_value (false),
+            m_name_passed (false),
+            m_queue_passed (false),
+            m_condition_passed (false)
         {
-            m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-            if (m_ignore_count == UINT32_MAX)
-               error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
-        }
-        break;
-        case 't' :
-        {
-            m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
-            if (m_thread_id == LLDB_INVALID_THREAD_ID)
-               error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
-        }
-        break;
-        case 'T':
-            m_thread_name.assign (option_arg);
-            break;
-        case 'q':
-            m_queue_name.assign (option_arg);
-            break;
-        case 'x':
-        {
-            m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-            if (m_thread_id == UINT32_MAX)
-               error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
-            
         }
-        break;
-        case 'E':
+
+        virtual
+        ~CommandOptions () {}
+
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
-            LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
 
-            switch (language)
+            switch (short_option)
             {
-                case eLanguageTypeC89:
-                case eLanguageTypeC:
-                case eLanguageTypeC99:
-                    m_language = eLanguageTypeC;
-                    break;
-                case eLanguageTypeC_plus_plus:
-                    m_language = eLanguageTypeC_plus_plus;
+                case 'c':
+                    if (option_arg != NULL)
+                        m_condition.assign (option_arg);
+                    else
+                        m_condition.clear();
+                    m_condition_passed = true;
                     break;
-                case eLanguageTypeObjC:
-                    m_language = eLanguageTypeObjC;
+                case 'd':
+                    m_enable_passed = true;
+                    m_enable_value = false;
                     break;
-                case eLanguageTypeObjC_plus_plus:
-                    error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
+                case 'e':
+                    m_enable_passed = true;
+                    m_enable_value = true;
+                    break;
+                case 'i':
+                {
+                    m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_ignore_count == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
+                }
+                break;
+                case 't' :
+                {
+                    if (option_arg[0] == '\0')
+                    {
+                        m_thread_id = LLDB_INVALID_THREAD_ID;
+                        m_thread_id_passed = true;
+                    }
+                    else
+                    {
+                        m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
+                        if (m_thread_id == LLDB_INVALID_THREAD_ID)
+                           error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
+                        else
+                            m_thread_id_passed = true;
+                    }
+                }
+                break;
+                case 'T':
+                    if (option_arg != NULL)
+                        m_thread_name.assign (option_arg);
+                    else
+                        m_thread_name.clear();
+                    m_name_passed = true;
                     break;
-                case eLanguageTypeUnknown:
-                    error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
+                case 'q':
+                    if (option_arg != NULL)
+                        m_queue_name.assign (option_arg);
+                    else
+                        m_queue_name.clear();
+                    m_queue_passed = true;
                     break;
+                case 'x':
+                {
+                    if (option_arg[0] == '\n')
+                    {
+                        m_thread_index = UINT32_MAX;
+                        m_thread_index_passed = true;
+                    }
+                    else
+                    {
+                        m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
+                        if (m_thread_id == UINT32_MAX)
+                           error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
+                        else
+                            m_thread_index_passed = true;
+                    }
+                }
+                break;
                 default:
-                    error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
             }
+
+            return error;
         }
-        break;
-        case 'w':
+        void
+        OptionParsingStarting ()
         {
-            bool success;
-            m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
-            if (!success)
-                error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
-        }
-        break;
-        case 'h':
-        {
-            bool success;
-            m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
-            if (!success)
-                error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
-        }
-        case 'K':
-        {
-            bool success;
-            bool value;
-            value = Args::StringToBoolean (option_arg, true, &success);
-            if (value)
-                m_skip_prologue = eLazyBoolYes;
-            else
-                m_skip_prologue = eLazyBoolNo;
-                
-            if (!success)
-                error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
+            m_ignore_count = 0;
+            m_thread_id = LLDB_INVALID_THREAD_ID;
+            m_thread_id_passed = false;
+            m_thread_index = UINT32_MAX;
+            m_thread_index_passed = false;
+            m_thread_name.clear();
+            m_queue_name.clear();
+            m_condition.clear();
+            m_enable_passed = false;
+            m_queue_passed = false;
+            m_name_passed = false;
+            m_condition_passed = false;
         }
-        break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        
 
-    return error;
-}
+        // Options table: Required for subclasses of Options.
 
-void
-CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
-{
-    m_condition.clear();
-    m_filenames.Clear();
-    m_line_num = 0;
-    m_column = 0;
-    m_func_names.clear();
-    m_func_name_type_mask = 0;
-    m_func_regexp.clear();
-    m_load_addr = LLDB_INVALID_ADDRESS;
-    m_modules.Clear();
-    m_ignore_count = 0;
-    m_thread_id = LLDB_INVALID_THREAD_ID;
-    m_thread_index = UINT32_MAX;
-    m_thread_name.clear();
-    m_queue_name.clear();
-    m_language = eLanguageTypeUnknown;
-    m_catch_bp = false;
-    m_throw_bp = true;
-    m_skip_prologue = eLazyBoolCalculate;
-}
+        static OptionDefinition g_option_table[];
 
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointSet
-//-------------------------------------------------------------------------
-#pragma mark Set
+        // Instance variables to hold the values for command options.
 
-CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "breakpoint set", 
-                   "Sets a breakpoint or set of breakpoints in the executable.", 
-                   "breakpoint set <cmd-options>"),
-    m_options (interpreter)
-{
-}
-
-CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
-{
-}
-
-Options *
-CommandObjectBreakpointSet::GetOptions ()
-{
-    return &m_options;
-}
-
-bool
-CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
-{
-    uint32_t default_line;
-    // First use the Source Manager's default file. 
-    // Then use the current stack frame's file.
-    if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
+        uint32_t m_ignore_count;
+        lldb::tid_t m_thread_id;
+        bool m_thread_id_passed;
+        uint32_t m_thread_index;
+        bool m_thread_index_passed;
+        std::string m_thread_name;
+        std::string m_queue_name;
+        std::string m_condition;
+        bool m_enable_passed;
+        bool m_enable_value;
+        bool m_name_passed;
+        bool m_queue_passed;
+        bool m_condition_passed;
+
+    };
+
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
-        if (cur_frame == NULL)
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
         {
-            result.AppendError ("No selected frame to use to find the default file.");
+            result.AppendError ("Invalid target.  No existing target or breakpoints.");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-        else if (!cur_frame->HasDebugInformation())
-        {
-            result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-        else
-        {
-            const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
-            if (sc.line_entry.file)
-            {
-                file = sc.line_entry.file;
-            }
-            else
-            {
-                result.AppendError ("Can't find the file for the selected frame to use as the default file.");
-                result.SetStatus (eReturnStatusFailed);
-                return false;
-            }
-        }
-    }
-    return true;
-}
 
-bool
-CommandObjectBreakpointSet::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
-    {
-        result.AppendError ("Invalid target.  Must set target before setting breakpoints (see 'target create' command).");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
-
-    // The following are the various types of breakpoints that could be set:
-    //   1).  -f -l -p  [-s -g]   (setting breakpoint by source location)
-    //   2).  -a  [-s -g]         (setting breakpoint by address)
-    //   3).  -n  [-s -g]         (setting breakpoint by function name)
-    //   4).  -r  [-s -g]         (setting breakpoint by function name regular expression)
-    //   5).  -p -f               (setting a breakpoint by comparing a reg-exp to source text)
-    //   6).  -E [-w -h]          (setting a breakpoint for exceptions for a given language.)
-
-    BreakpointSetType break_type = eSetTypeInvalid;
-
-    if (m_options.m_line_num != 0)
-        break_type = eSetTypeFileAndLine;
-    else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
-        break_type = eSetTypeAddress;
-    else if (!m_options.m_func_names.empty())
-        break_type = eSetTypeFunctionName;
-    else if  (!m_options.m_func_regexp.empty())
-        break_type = eSetTypeFunctionRegexp;
-    else if (!m_options.m_source_text_regexp.empty())
-        break_type = eSetTypeSourceRegexp;
-    else if (m_options.m_language != eLanguageTypeUnknown)
-        break_type = eSetTypeException;
-
-    Breakpoint *bp = NULL;
-    FileSpec module_spec;
-    bool use_module = false;
-    int num_modules = m_options.m_modules.GetSize();
-    
-    const bool internal = false;
-
-    if ((num_modules > 0) && (break_type != eSetTypeAddress))
-        use_module = true;
-
-    switch (break_type)
-    {
-        case eSetTypeFileAndLine: // Breakpoint by source position
-            {
-                FileSpec file;
-                uint32_t num_files = m_options.m_filenames.GetSize();
-                if (num_files == 0)
-                {
-                    if (!GetDefaultFile (target, file, result))
-                    {
-                        result.AppendError("No file supplied and no default file available.");
-                        result.SetStatus (eReturnStatusFailed);
-                        return false;
-                    }
-                }
-                else if (num_files > 1)
-                {
-                    result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
-                else
-                    file = m_options.m_filenames.GetFileSpecAtIndex(0);
-                    
-                bp = target->CreateBreakpoint (&(m_options.m_modules),
-                                               file,
-                                               m_options.m_line_num,
-                                               m_options.m_check_inlines,
-                                               m_options.m_skip_prologue,
-                                               internal).get();
-            }
-            break;
+        Mutex::Locker locker;
+        target->GetBreakpointList().GetListMutex(locker);
+        
+        BreakpointIDList valid_bp_ids;
 
-        case eSetTypeAddress: // Breakpoint by address
-            bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
-            break;
+        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
 
-        case eSetTypeFunctionName: // Breakpoint by function name
+        if (result.Succeeded())
+        {
+            const size_t count = valid_bp_ids.GetSize(); 
+            for (size_t i = 0; i < count; ++i)
             {
-                uint32_t name_type_mask = m_options.m_func_name_type_mask;
-                
-                if (name_type_mask == 0)
-                    name_type_mask = eFunctionNameTypeAuto;
-                
-                bp = target->CreateBreakpoint (&(m_options.m_modules),
-                                               &(m_options.m_filenames),
-                                               m_options.m_func_names,
-                                               name_type_mask,
-                                               m_options.m_skip_prologue,
-                                               internal).get();
-            }
-            break;
+                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
 
-        case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
-            {
-                RegularExpression regexp(m_options.m_func_regexp.c_str());
-                if (!regexp.IsValid())
-                {
-                    char err_str[1024];
-                    regexp.GetErrorAsCString(err_str, sizeof(err_str));
-                    result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
-                                                 err_str);
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
-                
-                bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
-                                                        &(m_options.m_filenames),
-                                                        regexp,
-                                                        m_options.m_skip_prologue,
-                                                        internal).get();
-            }
-            break;
-        case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
-            {
-                int num_files = m_options.m_filenames.GetSize();
-                
-                if (num_files == 0)
+                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                 {
-                    FileSpec file;
-                    if (!GetDefaultFile (target, file, result))
+                    Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
                     {
-                        result.AppendError ("No files provided and could not find default file.");
-                        result.SetStatus (eReturnStatusFailed);
-                        return false;
+                        BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
+                        if (location)
+                        {
+                            if (m_options.m_thread_id_passed)
+                                location->SetThreadID (m_options.m_thread_id);
+                                
+                            if (m_options.m_thread_index_passed)
+                                location->SetThreadIndex(m_options.m_thread_index);
+                            
+                            if (m_options.m_name_passed)
+                                location->SetThreadName(m_options.m_thread_name.c_str());
+                            
+                            if (m_options.m_queue_passed)
+                                location->SetQueueName(m_options.m_queue_name.c_str());
+                                
+                            if (m_options.m_ignore_count != 0)
+                                location->SetIgnoreCount(m_options.m_ignore_count);
+                                
+                            if (m_options.m_enable_passed)
+                                location->SetEnabled (m_options.m_enable_value);
+                                
+                            if (m_options.m_condition_passed)
+                                location->SetCondition (m_options.m_condition.c_str());
+                        }
                     }
                     else
                     {
-                        m_options.m_filenames.Append (file);
+                        if (m_options.m_thread_id_passed)
+                            bp->SetThreadID (m_options.m_thread_id);
+                            
+                        if (m_options.m_thread_index_passed)
+                            bp->SetThreadIndex(m_options.m_thread_index);
+                        
+                        if (m_options.m_name_passed)
+                            bp->SetThreadName(m_options.m_thread_name.c_str());
+                        
+                        if (m_options.m_queue_passed)
+                            bp->SetQueueName(m_options.m_queue_name.c_str());
+                            
+                        if (m_options.m_ignore_count != 0)
+                            bp->SetIgnoreCount(m_options.m_ignore_count);
+                            
+                        if (m_options.m_enable_passed)
+                            bp->SetEnabled (m_options.m_enable_value);
+                            
+                        if (m_options.m_condition_passed)
+                            bp->SetCondition (m_options.m_condition.c_str());
                     }
                 }
-                
-                RegularExpression regexp(m_options.m_source_text_regexp.c_str());
-                if (!regexp.IsValid())
-                {
-                    char err_str[1024];
-                    regexp.GetErrorAsCString(err_str, sizeof(err_str));
-                    result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
-                                                 err_str);
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
-                bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
-            }
-            break;
-        case eSetTypeException:
-            {
-                bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
-            }
-            break;
-        default:
-            break;
-    }
-
-    // Now set the various options that were passed in:
-    if (bp)
-    {
-        if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
-            bp->SetThreadID (m_options.m_thread_id);
-            
-        if (m_options.m_thread_index != UINT32_MAX)
-            bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
-        
-        if (!m_options.m_thread_name.empty())
-            bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
-        
-        if (!m_options.m_queue_name.empty())
-            bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
-            
-        if (m_options.m_ignore_count != 0)
-            bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
-
-        if (!m_options.m_condition.empty())
-            bp->GetOptions()->SetCondition(m_options.m_condition.c_str());
-    }
-    
-    if (bp)
-    {
-        Stream &output_stream = result.GetOutputStream();
-        output_stream.Printf ("Breakpoint created: ");
-        bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
-        output_stream.EOL();
-        // Don't print out this warning for exception breakpoints.  They can get set before the target
-        // is set, but we won't know how to actually set the breakpoint till we run.
-        if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
-            output_stream.Printf ("WARNING:  Unable to resolve breakpoint to any actual locations.\n");
-        result.SetStatus (eReturnStatusSuccessFinishResult);
-    }
-    else if (!bp)
-    {
-        result.AppendError ("Breakpoint creation failed: No breakpoint created.");
-        result.SetStatus (eReturnStatusFailed);
-    }
-
-    return result.Succeeded();
-}
-
-//-------------------------------------------------------------------------
-// CommandObjectMultiwordBreakpoint
-//-------------------------------------------------------------------------
-#pragma mark MultiwordBreakpoint
-
-CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
-    CommandObjectMultiword (interpreter, 
-                            "breakpoint",
-                            "A set of commands for operating on breakpoints. Also see _regexp-break.",
-                            "breakpoint <command> [<command-options>]")
-{
-    bool status;
-
-    CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
-    CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
-    CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
-    CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
-    CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
-    CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
-    CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
-    CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
-
-    list_command_object->SetCommandName ("breakpoint list");
-    enable_command_object->SetCommandName("breakpoint enable");
-    disable_command_object->SetCommandName("breakpoint disable");
-    clear_command_object->SetCommandName("breakpoint clear");
-    delete_command_object->SetCommandName("breakpoint delete");
-    set_command_object->SetCommandName("breakpoint set");
-    command_command_object->SetCommandName ("breakpoint command");
-    modify_command_object->SetCommandName ("breakpoint modify");
-
-    status = LoadSubCommand ("list",       list_command_object);
-    status = LoadSubCommand ("enable",     enable_command_object);
-    status = LoadSubCommand ("disable",    disable_command_object);
-    status = LoadSubCommand ("clear",      clear_command_object);
-    status = LoadSubCommand ("delete",     delete_command_object);
-    status = LoadSubCommand ("set",        set_command_object);
-    status = LoadSubCommand ("command",    command_command_object);
-    status = LoadSubCommand ("modify",     modify_command_object);
-}
-
-CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
-{
-}
-
-void
-CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
-                                                         BreakpointIDList *valid_ids)
-{
-    // args can be strings representing 1). integers (for breakpoint ids)
-    //                                  2). the full breakpoint & location canonical representation
-    //                                  3). the word "to" or a hyphen, representing a range (in which case there
-    //                                      had *better* be an entry both before & after of one of the first two types.
-    // If args is empty, we will use the last created breakpoint (if there is one.)
-
-    Args temp_args;
-
-    if (args.GetArgumentCount() == 0)
-    {
-        if (target->GetLastCreatedBreakpoint())
-        {
-            valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        } 
-        else
-        {   
-            result.AppendError("No breakpoint specified and no last created breakpoint.");
-            result.SetStatus (eReturnStatusFailed);
-        }
-        return;
-    }
-    
-    // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
-    // the new TEMP_ARGS.  Do not copy breakpoint id range strings over; instead generate a list of strings for
-    // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
-
-    BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
-
-    // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
-
-    valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
-
-    // At this point,  all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
-    // and put into valid_ids.
-
-    if (result.Succeeded())
-    {
-        // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
-        // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
-
-        const size_t count = valid_ids->GetSize();
-        for (size_t i = 0; i < count; ++i)
-        {
-            BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
-            Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-            if (breakpoint != NULL)
-            {
-                int num_locations = breakpoint->GetNumLocations();
-                if (cur_bp_id.GetLocationID() > num_locations)
-                {
-                    StreamString id_str;
-                    BreakpointID::GetCanonicalReference (&id_str, 
-                                                         cur_bp_id.GetBreakpointID(),
-                                                         cur_bp_id.GetLocationID());
-                    i = valid_ids->GetSize() + 1;
-                    result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
-                                                 id_str.GetData());
-                    result.SetStatus (eReturnStatusFailed);
-                }
-            }
-            else
-            {
-                i = valid_ids->GetSize() + 1;
-                result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
-                result.SetStatus (eReturnStatusFailed);
             }
         }
+        
+        return result.Succeeded();
     }
-}
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointList::Options
-//-------------------------------------------------------------------------
-#pragma mark List::CommandOptions
-
-CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_level (lldb::eDescriptionLevelBrief)  // Breakpoint List defaults to brief descriptions
-{
-}
 
-CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
-{
-}
-
-OptionDefinition
-CommandObjectBreakpointList::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
-        "Show debugger internal breakpoints" },
-
-    { LLDB_OPT_SET_1, false, "brief",    'b', no_argument, NULL, 0, eArgTypeNone,
-        "Give a brief description of the breakpoint (no location info)."},
-
-    // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
-    // But I need to see it for now, and don't want to wait.
-    { LLDB_OPT_SET_2, false, "full",    'f', no_argument, NULL, 0, eArgTypeNone,
-        "Give a full description of the breakpoint and its locations."},
-
-    { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
-        "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
-
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+private:
+    CommandOptions m_options;
 };
 
-const OptionDefinition*
-CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
-
-Error
-CommandObjectBreakpointList::CommandOptions::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 'b':
-            m_level = lldb::eDescriptionLevelBrief;
-            break;
-        case 'f':
-            m_level = lldb::eDescriptionLevelFull;
-            break;
-        case 'v':
-            m_level = lldb::eDescriptionLevelVerbose;
-            break;
-        case 'i':
-            m_internal = true;
-            break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-
-    return error;
-}
-
-void
-CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
-{
-    m_level = lldb::eDescriptionLevelFull;
-    m_internal = false;
-}
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointList
-//-------------------------------------------------------------------------
-#pragma mark List
-
-CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "breakpoint list",
-                   "List some or all breakpoints at configurable levels of detail.",
-                   NULL),
-    m_options (interpreter)
-{
-    CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-
-    // Define the first (and only) variant of this arg.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatOptional;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg.push_back (bp_id_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
-
-CommandObjectBreakpointList::~CommandObjectBreakpointList ()
-{
-}
-
-Options *
-CommandObjectBreakpointList::GetOptions ()
-{
-    return &m_options;
-}
-
-bool
-CommandObjectBreakpointList::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+#pragma mark Modify::CommandOptions
+OptionDefinition
+CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
 {
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
-    {
-        result.AppendError ("Invalid target. No current target or breakpoints.");
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        return true;
-    }
-
-    const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
-    Mutex::Locker locker;
-    target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
-
-    size_t num_breakpoints = breakpoints.GetSize();
-
-    if (num_breakpoints == 0)
-    {
-        result.AppendMessage ("No breakpoints currently set.");
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        return true;
-    }
-
-    Stream &output_stream = result.GetOutputStream();
-
-    if (args.GetArgumentCount() == 0)
-    {
-        // No breakpoint selected; show info about all currently set breakpoints.
-        result.AppendMessage ("Current breakpoints:");
-        for (size_t i = 0; i < num_breakpoints; ++i)
-        {
-            Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
-            AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
-        }
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular breakpoints selected; show info about that breakpoint.
-        BreakpointIDList valid_bp_ids;
-        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
-
-        if (result.Succeeded())
-        {
-            for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
-            {
-                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
-                Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
-            }
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        }
-        else
-        {
-            result.AppendError ("Invalid breakpoint id.");
-            result.SetStatus (eReturnStatusFailed);
-        }
-    }
-
-    return result.Succeeded();
-}
+{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
+{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "thread-id",    't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "thread-name",  'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "queue-name",   'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
+{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
+{ LLDB_OPT_SET_1,   false, "enable",       'e', no_argument,       NULL, 0, eArgTypeNone, "Enable the breakpoint."},
+{ LLDB_OPT_SET_2,   false, "disable",      'd', no_argument,       NULL, 0, eArgTypeNone, "Disable the breakpoint."},
+{ 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectBreakpointEnable
 //-------------------------------------------------------------------------
 #pragma mark Enable
 
-CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "enable",
-                   "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
-                   NULL)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back (arg);   
-}
-
-
-CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
-{
-}
-
-
-bool
-CommandObjectBreakpointEnable::Execute 
-(
-    Args& args, 
-    CommandReturnObject &result
-)
+class CommandObjectBreakpointEnable : public CommandObjectParsed
 {
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
+public:
+    CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "enable",
+                             "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
+                             NULL)
     {
-        result.AppendError ("Invalid target.  No existing target or breakpoints.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back (arg);   
     }
 
-    Mutex::Locker locker;
-    target->GetBreakpointList().GetListMutex(locker);
-
-    const BreakpointList &breakpoints = target->GetBreakpointList();
 
-    size_t num_breakpoints = breakpoints.GetSize();
+    virtual
+    ~CommandObjectBreakpointEnable () {}
 
-    if (num_breakpoints == 0)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("No breakpoints exist to be enabled.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target.  No existing target or breakpoints.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (args.GetArgumentCount() == 0)
-    {
-        // No breakpoint selected; enable all currently set breakpoints.
-        target->EnableAllBreakpoints ();
-        result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular breakpoint selected; enable that breakpoint.
-        BreakpointIDList valid_bp_ids;
-        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
+        Mutex::Locker locker;
+        target->GetBreakpointList().GetListMutex(locker);
 
-        if (result.Succeeded())
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+
+        size_t num_breakpoints = breakpoints.GetSize();
+
+        if (num_breakpoints == 0)
         {
-            int enable_count = 0;
-            int loc_count = 0;
-            const size_t count = valid_bp_ids.GetSize();
-            for (size_t i = 0; i < count; ++i)
-            {
-                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+            result.AppendError ("No breakpoints exist to be enabled.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+        if (command.GetArgumentCount() == 0)
+        {
+            // No breakpoint selected; enable all currently set breakpoints.
+            target->EnableAllBreakpoints ();
+            result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular breakpoint selected; enable that breakpoint.
+            BreakpointIDList valid_bp_ids;
+            CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+
+            if (result.Succeeded())
+            {
+                int enable_count = 0;
+                int loc_count = 0;
+                const size_t count = valid_bp_ids.GetSize();
+                for (size_t i = 0; i < count; ++i)
                 {
-                    Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                    BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+
+                    if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                     {
-                        BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
-                        if (location)
+                        Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                        if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
                         {
-                            location->SetEnabled (true);
-                            ++loc_count;
+                            BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
+                            if (location)
+                            {
+                                location->SetEnabled (true);
+                                ++loc_count;
+                            }
+                        }
+                        else
+                        {
+                            breakpoint->SetEnabled (true);
+                            ++enable_count;
                         }
-                    }
-                    else
-                    {
-                        breakpoint->SetEnabled (true);
-                        ++enable_count;
                     }
                 }
+                result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
             }
-            result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
-    }
 
-    return result.Succeeded();
-}
+        return result.Succeeded();
+    }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectBreakpointDisable
 //-------------------------------------------------------------------------
 #pragma mark Disable
 
-CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "breakpoint disable",
-                   "Disable the specified breakpoint(s) without removing it/them.  If no breakpoints are specified, disable them all.",
-                   NULL)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back (arg);   
-}
-
-CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
+class CommandObjectBreakpointDisable : public CommandObjectParsed
 {
-}
-
-bool
-CommandObjectBreakpointDisable::Execute
-(
-    Args& args, 
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
+public:
+    CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "breakpoint disable",
+                             "Disable the specified breakpoint(s) without removing it/them.  If no breakpoints are specified, disable them all.",
+                             NULL)
     {
-        result.AppendError ("Invalid target.  No existing target or breakpoints.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back (arg);   
     }
 
-    Mutex::Locker locker;
-    target->GetBreakpointList().GetListMutex(locker);
 
-    const BreakpointList &breakpoints = target->GetBreakpointList();
-    size_t num_breakpoints = breakpoints.GetSize();
+    virtual
+    ~CommandObjectBreakpointDisable () {}
 
-    if (num_breakpoints == 0)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("No breakpoints exist to be disabled.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target.  No existing target or breakpoints.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (args.GetArgumentCount() == 0)
-    {
-        // No breakpoint selected; disable all currently set breakpoints.
-        target->DisableAllBreakpoints ();
-        result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular breakpoint selected; disable that breakpoint.
-        BreakpointIDList valid_bp_ids;
+        Mutex::Locker locker;
+        target->GetBreakpointList().GetListMutex(locker);
 
-        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+        size_t num_breakpoints = breakpoints.GetSize();
 
-        if (result.Succeeded())
+        if (num_breakpoints == 0)
         {
-            int disable_count = 0;
-            int loc_count = 0;
-            const size_t count = valid_bp_ids.GetSize();
-            for (size_t i = 0; i < count; ++i)
-            {
-                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+            result.AppendError ("No breakpoints exist to be disabled.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+        if (command.GetArgumentCount() == 0)
+        {
+            // No breakpoint selected; disable all currently set breakpoints.
+            target->DisableAllBreakpoints ();
+            result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular breakpoint selected; disable that breakpoint.
+            BreakpointIDList valid_bp_ids;
+
+            CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+
+            if (result.Succeeded())
+            {
+                int disable_count = 0;
+                int loc_count = 0;
+                const size_t count = valid_bp_ids.GetSize();
+                for (size_t i = 0; i < count; ++i)
                 {
-                    Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                    BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+
+                    if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                     {
-                        BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
-                        if (location)
+                        Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                        if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
                         {
-                            location->SetEnabled (false);
-                            ++loc_count;
+                            BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
+                            if (location)
+                            {
+                                location->SetEnabled (false);
+                                ++loc_count;
+                            }
+                        }
+                        else
+                        {
+                            breakpoint->SetEnabled (false);
+                            ++disable_count;
                         }
-                    }
-                    else
-                    {
-                        breakpoint->SetEnabled (false);
-                        ++disable_count;
                     }
                 }
+                result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
             }
-            result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
+
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+};
 
 //-------------------------------------------------------------------------
-// CommandObjectBreakpointClear::CommandOptions
+// CommandObjectBreakpointList
 //-------------------------------------------------------------------------
-#pragma mark Clear::CommandOptions
-
-CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_filename (),
-    m_line_num (0)
-{
-}
+#pragma mark List
 
-CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
+class CommandObjectBreakpointList : public CommandObjectParsed
 {
-}
+public:
+    CommandObjectBreakpointList (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter, 
+                             "breakpoint list",
+                             "List some or all breakpoints at configurable levels of detail.",
+                             NULL),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData bp_id_arg;
 
-OptionDefinition
-CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
-        "Specify the breakpoint by source location in this particular file."},
+        // Define the first (and only) variant of this arg.
+        bp_id_arg.arg_type = eArgTypeBreakpointID;
+        bp_id_arg.arg_repetition = eArgRepeatOptional;
 
-    { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
-        "Specify the breakpoint by source location at this particular line."},
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (bp_id_arg);
 
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
-};
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+    }
 
-const OptionDefinition*
-CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
 
-Error
-CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+    virtual
+    ~CommandObjectBreakpointList () {}
 
-    switch (short_option)
+    virtual Options *
+    GetOptions ()
     {
-        case 'f':
-            m_filename.assign (option_arg);
-            break;
-
-        case 'l':
-            m_line_num = Args::StringToUInt32 (option_arg, 0);
-            break;
-
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
+        return &m_options;
     }
+    
+    class CommandOptions : public Options
+    {
+    public:
 
-    return error;
-}
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_level (lldb::eDescriptionLevelBrief)  // Breakpoint List defaults to brief descriptions
+        {
+        }
 
-void
-CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
-{
-    m_filename.clear();
-    m_line_num = 0;
-}
+        virtual
+        ~CommandOptions () {}
 
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointClear
-//-------------------------------------------------------------------------
-#pragma mark Clear
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
 
-CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "breakpoint clear", 
-                   "Clears a breakpoint or set of breakpoints in the executable.", 
-                   "breakpoint clear <cmd-options>"),
-    m_options (interpreter)
-{
-}
+            switch (short_option)
+            {
+                case 'b':
+                    m_level = lldb::eDescriptionLevelBrief;
+                    break;
+                case 'f':
+                    m_level = lldb::eDescriptionLevelFull;
+                    break;
+                case 'v':
+                    m_level = lldb::eDescriptionLevelVerbose;
+                    break;
+                case 'i':
+                    m_internal = true;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
 
-CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
-{
-}
+            return error;
+        }
 
-Options *
-CommandObjectBreakpointClear::GetOptions ()
-{
-    return &m_options;
-}
+        void
+        OptionParsingStarting ()
+        {
+            m_level = lldb::eDescriptionLevelFull;
+            m_internal = false;
+        }
 
-bool
-CommandObjectBreakpointClear::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
-    {
-        result.AppendError ("Invalid target. No existing target or breakpoints.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        const OptionDefinition *
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
 
-    // The following are the various types of breakpoints that could be cleared:
-    //   1). -f -l (clearing breakpoint by source location)
+        // Options table: Required for subclasses of Options.
 
-    BreakpointClearType break_type = eClearTypeInvalid;
+        static OptionDefinition g_option_table[];
 
-    if (m_options.m_line_num != 0)
-        break_type = eClearTypeFileAndLine;
+        // Instance variables to hold the values for command options.
 
-    Mutex::Locker locker;
-    target->GetBreakpointList().GetListMutex(locker);
+        lldb::DescriptionLevel m_level;
 
-    BreakpointList &breakpoints = target->GetBreakpointList();
-    size_t num_breakpoints = breakpoints.GetSize();
+        bool m_internal;
+    };
 
-    // Early return if there's no breakpoint at all.
-    if (num_breakpoints == 0)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("Breakpoint clear: No breakpoint cleared.");
-        result.SetStatus (eReturnStatusFailed);
-        return result.Succeeded();
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target. No current target or breakpoints.");
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return true;
+        }
 
-    // Find matching breakpoints and delete them.
+        const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
+        Mutex::Locker locker;
+        target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
 
-    // First create a copy of all the IDs.
-    std::vector<break_id_t> BreakIDs;
-    for (size_t i = 0; i < num_breakpoints; ++i)
-        BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
-
-    int num_cleared = 0;
-    StreamString ss;
-    switch (break_type)
-    {
-        case eClearTypeFileAndLine: // Breakpoint by source position
+        size_t num_breakpoints = breakpoints.GetSize();
+
+        if (num_breakpoints == 0)
+        {
+            result.AppendMessage ("No breakpoints currently set.");
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return true;
+        }
+
+        Stream &output_stream = result.GetOutputStream();
+
+        if (command.GetArgumentCount() == 0)
+        {
+            // No breakpoint selected; show info about all currently set breakpoints.
+            result.AppendMessage ("Current breakpoints:");
+            for (size_t i = 0; i < num_breakpoints; ++i)
             {
-                const ConstString filename(m_options.m_filename.c_str());
-                BreakpointLocationCollection loc_coll;
+                Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
+                AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
+            }
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular breakpoints selected; show info about that breakpoint.
+            BreakpointIDList valid_bp_ids;
+            CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
 
-                for (size_t i = 0; i < num_breakpoints; ++i)
+            if (result.Succeeded())
+            {
+                for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
                 {
-                    Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
-                    
-                    if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
-                    {
-                        // If the collection size is 0, it's a full match and we can just remove the breakpoint.
-                        if (loc_coll.GetSize() == 0)
-                        {
-                            bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
-                            ss.EOL();
-                            target->RemoveBreakpointByID (bp->GetID());
-                            ++num_cleared;
-                        }
-                    }
+                    BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+                    Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                    AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
                 }
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            }
+            else
+            {
+                result.AppendError ("Invalid breakpoint id.");
+                result.SetStatus (eReturnStatusFailed);
             }
-            break;
+        }
 
-        default:
-            break;
+        return result.Succeeded();
     }
 
-    if (num_cleared > 0)
+private:
+    CommandOptions m_options;
+};
+
+#pragma mark List::CommandOptions
+OptionDefinition
+CommandObjectBreakpointList::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
+        "Show debugger internal breakpoints" },
+
+    { LLDB_OPT_SET_1, false, "brief",    'b', no_argument, NULL, 0, eArgTypeNone,
+        "Give a brief description of the breakpoint (no location info)."},
+
+    // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
+    // But I need to see it for now, and don't want to wait.
+    { LLDB_OPT_SET_2, false, "full",    'f', no_argument, NULL, 0, eArgTypeNone,
+        "Give a full description of the breakpoint and its locations."},
+
+    { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
+        "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
+
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectBreakpointClear
+//-------------------------------------------------------------------------
+#pragma mark Clear
+
+class CommandObjectBreakpointClear : public CommandObjectParsed
+{
+public:
+
+    typedef enum BreakpointClearType
+    {
+        eClearTypeInvalid,
+        eClearTypeFileAndLine
+    } BreakpointClearType;
+
+    CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "breakpoint clear", 
+                             "Clears a breakpoint or set of breakpoints in the executable.", 
+                             "breakpoint clear <cmd-options>"),
+        m_options (interpreter)
     {
-        Stream &output_stream = result.GetOutputStream();
-        output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
-        output_stream << ss.GetData();
-        output_stream.EOL();
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
     }
-    else
+
+    virtual
+    ~CommandObjectBreakpointClear () {}
+
+    virtual Options *
+    GetOptions ()
     {
-        result.AppendError ("Breakpoint clear: No breakpoint cleared.");
-        result.SetStatus (eReturnStatusFailed);
+        return &m_options;
     }
 
-    return result.Succeeded();
-}
+    class CommandOptions : public Options
+    {
+    public:
 
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointDelete
-//-------------------------------------------------------------------------
-#pragma mark Delete
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_filename (),
+            m_line_num (0)
+        {
+        }
 
-CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "breakpoint delete",
-                   "Delete the specified breakpoint(s).  If no breakpoints are specified, delete them all.",
-                   NULL)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back (arg);   
-}
+        virtual
+        ~CommandOptions () {}
+
+        virtual Error
+        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 'f':
+                    m_filename.assign (option_arg);
+                    break;
+
+                case 'l':
+                    m_line_num = Args::StringToUInt32 (option_arg, 0);
+                    break;
+
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
+
+            return error;
+        }
+
+        void
+        OptionParsingStarting ()
+        {
+            m_filename.clear();
+            m_line_num = 0;
+        }
+
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
 
-CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
-{
-}
+        // Options table: Required for subclasses of Options.
 
-bool
-CommandObjectBreakpointDelete::Execute 
-(
-    Args& args, 
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
-    {
-        result.AppendError ("Invalid target. No existing target or breakpoints.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        static OptionDefinition g_option_table[];
 
-    Mutex::Locker locker;
-    target->GetBreakpointList().GetListMutex(locker);
-    
-    const BreakpointList &breakpoints = target->GetBreakpointList();
+        // Instance variables to hold the values for command options.
 
-    size_t num_breakpoints = breakpoints.GetSize();
+        std::string m_filename;
+        uint32_t m_line_num;
 
-    if (num_breakpoints == 0)
-    {
-        result.AppendError ("No breakpoints exist to be deleted.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+    };
 
-    if (args.GetArgumentCount() == 0)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
         {
-            result.AppendMessage("Operation cancelled...");
+            result.AppendError ("Invalid target. No existing target or breakpoints.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        else
+
+        // The following are the various types of breakpoints that could be cleared:
+        //   1). -f -l (clearing breakpoint by source location)
+
+        BreakpointClearType break_type = eClearTypeInvalid;
+
+        if (m_options.m_line_num != 0)
+            break_type = eClearTypeFileAndLine;
+
+        Mutex::Locker locker;
+        target->GetBreakpointList().GetListMutex(locker);
+
+        BreakpointList &breakpoints = target->GetBreakpointList();
+        size_t num_breakpoints = breakpoints.GetSize();
+
+        // Early return if there's no breakpoint at all.
+        if (num_breakpoints == 0)
         {
-            target->RemoveAllBreakpoints ();
-            result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
+            result.AppendError ("Breakpoint clear: No breakpoint cleared.");
+            result.SetStatus (eReturnStatusFailed);
+            return result.Succeeded();
         }
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular breakpoint selected; disable that breakpoint.
-        BreakpointIDList valid_bp_ids;
-        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
 
-        if (result.Succeeded())
-        {
-            int delete_count = 0;
-            int disable_count = 0;
-            const size_t count = valid_bp_ids.GetSize();
-            for (size_t i = 0; i < count; ++i)
-            {
-                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+        // Find matching breakpoints and delete them.
 
-                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+        // First create a copy of all the IDs.
+        std::vector<break_id_t> BreakIDs;
+        for (size_t i = 0; i < num_breakpoints; ++i)
+            BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
+
+        int num_cleared = 0;
+        StreamString ss;
+        switch (break_type)
+        {
+            case eClearTypeFileAndLine: // Breakpoint by source position
                 {
-                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                    const ConstString filename(m_options.m_filename.c_str());
+                    BreakpointLocationCollection loc_coll;
+
+                    for (size_t i = 0; i < num_breakpoints; ++i)
                     {
-                        Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                        BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
-                        // It makes no sense to try to delete individual locations, so we disable them instead.
-                        if (location)
+                        Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
+                        
+                        if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
                         {
-                            location->SetEnabled (false);
-                            ++disable_count;
+                            // If the collection size is 0, it's a full match and we can just remove the breakpoint.
+                            if (loc_coll.GetSize() == 0)
+                            {
+                                bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
+                                ss.EOL();
+                                target->RemoveBreakpointByID (bp->GetID());
+                                ++num_cleared;
+                            }
                         }
                     }
-                    else
-                    {
-                        target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
-                        ++delete_count;
-                    }
                 }
-            }
-            result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
-                                           delete_count, disable_count);
+                break;
+
+            default:
+                break;
+        }
+
+        if (num_cleared > 0)
+        {
+            Stream &output_stream = result.GetOutputStream();
+            output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
+            output_stream << ss.GetData();
+            output_stream.EOL();
             result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
-    }
-    return result.Succeeded();
-}
+        else
+        {
+            result.AppendError ("Breakpoint clear: No breakpoint cleared.");
+            result.SetStatus (eReturnStatusFailed);
+        }
 
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointModify::CommandOptions
-//-------------------------------------------------------------------------
-#pragma mark Modify::CommandOptions
+        return result.Succeeded();
+    }
 
-CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_ignore_count (0),
-    m_thread_id(LLDB_INVALID_THREAD_ID),
-    m_thread_id_passed(false),
-    m_thread_index (UINT32_MAX),
-    m_thread_index_passed(false),
-    m_thread_name(),
-    m_queue_name(),
-    m_condition (),
-    m_enable_passed (false),
-    m_enable_value (false),
-    m_name_passed (false),
-    m_queue_passed (false),
-    m_condition_passed (false)
-{
-}
+private:
+    CommandOptions m_options;
+};
 
-CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
-{
-}
+#pragma mark Clear::CommandOptions
 
 OptionDefinition
-CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
+CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
-{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "thread-id",    't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "thread-name",  'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "queue-name",   'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
-{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
-{ LLDB_OPT_SET_1,   false, "enable",       'e', no_argument,       NULL, 0, eArgTypeNone, "Enable the breakpoint."},
-{ LLDB_OPT_SET_2,   false, "disable",      'd', no_argument,       NULL, 0, eArgTypeNone, "Disable the breakpoint."},
-{ 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
+    { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
+        "Specify the breakpoint by source location in this particular file."},
+
+    { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
+        "Specify the breakpoint by source location at this particular line."},
+
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
-const OptionDefinition*
-CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
+//-------------------------------------------------------------------------
+// CommandObjectBreakpointDelete
+//-------------------------------------------------------------------------
+#pragma mark Delete
 
-Error
-CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
+class CommandObjectBreakpointDelete : public CommandObjectParsed
 {
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+public:
+    CommandObjectBreakpointDelete (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "breakpoint delete",
+                             "Delete the specified breakpoint(s).  If no breakpoints are specified, delete them all.",
+                             NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back (arg);   
+    }
 
-    switch (short_option)
+    virtual
+    ~CommandObjectBreakpointDelete () {}
+
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        case 'c':
-            if (option_arg != NULL)
-                m_condition.assign (option_arg);
-            else
-                m_condition.clear();
-            m_condition_passed = true;
-            break;
-        case 'd':
-            m_enable_passed = true;
-            m_enable_value = false;
-            break;
-        case 'e':
-            m_enable_passed = true;
-            m_enable_value = true;
-            break;
-        case 'i':
-        {
-            m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-            if (m_ignore_count == UINT32_MAX)
-               error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target. No existing target or breakpoints.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+
+        Mutex::Locker locker;
+        target->GetBreakpointList().GetListMutex(locker);
+        
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+
+        size_t num_breakpoints = breakpoints.GetSize();
+
+        if (num_breakpoints == 0)
+        {
+            result.AppendError ("No breakpoints exist to be deleted.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        break;
-        case 't' :
+
+        if (command.GetArgumentCount() == 0)
         {
-            if (option_arg[0] == '\0')
+            if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
             {
-                m_thread_id = LLDB_INVALID_THREAD_ID;
-                m_thread_id_passed = true;
+                result.AppendMessage("Operation cancelled...");
             }
             else
             {
-                m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
-                if (m_thread_id == LLDB_INVALID_THREAD_ID)
-                   error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
-                else
-                    m_thread_id_passed = true;
+                target->RemoveAllBreakpoints ();
+                result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
             }
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
-        break;
-        case 'T':
-            if (option_arg != NULL)
-                m_thread_name.assign (option_arg);
-            else
-                m_thread_name.clear();
-            m_name_passed = true;
-            break;
-        case 'q':
-            if (option_arg != NULL)
-                m_queue_name.assign (option_arg);
-            else
-                m_queue_name.clear();
-            m_queue_passed = true;
-            break;
-        case 'x':
+        else
         {
-            if (option_arg[0] == '\n')
-            {
-                m_thread_index = UINT32_MAX;
-                m_thread_index_passed = true;
-            }
-            else
-            {
-                m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
-                if (m_thread_id == UINT32_MAX)
-                   error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
-                else
-                    m_thread_index_passed = true;
+            // Particular breakpoint selected; disable that breakpoint.
+            BreakpointIDList valid_bp_ids;
+            CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+
+            if (result.Succeeded())
+            {
+                int delete_count = 0;
+                int disable_count = 0;
+                const size_t count = valid_bp_ids.GetSize();
+                for (size_t i = 0; i < count; ++i)
+                {
+                    BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+
+                    if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+                    {
+                        if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                        {
+                            Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                            BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
+                            // It makes no sense to try to delete individual locations, so we disable them instead.
+                            if (location)
+                            {
+                                location->SetEnabled (false);
+                                ++disable_count;
+                            }
+                        }
+                        else
+                        {
+                            target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
+                            ++delete_count;
+                        }
+                    }
+                }
+                result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
+                                               delete_count, disable_count);
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
             }
         }
-        break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
+        return result.Succeeded();
     }
-
-    return error;
-}
-
-void
-CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
-{
-    m_ignore_count = 0;
-    m_thread_id = LLDB_INVALID_THREAD_ID;
-    m_thread_id_passed = false;
-    m_thread_index = UINT32_MAX;
-    m_thread_index_passed = false;
-    m_thread_name.clear();
-    m_queue_name.clear();
-    m_condition.clear();
-    m_enable_passed = false;
-    m_queue_passed = false;
-    m_name_passed = false;
-    m_condition_passed = false;
-}
+};
 
 //-------------------------------------------------------------------------
-// CommandObjectBreakpointModify
+// CommandObjectMultiwordBreakpoint
 //-------------------------------------------------------------------------
-#pragma mark Modify
+#pragma mark MultiwordBreakpoint
 
-CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "breakpoint modify", 
-                   "Modify the options on a breakpoint or set of breakpoints in the executable.  "
-                   "If no breakpoint is specified, acts on the last created breakpoint.  "
-                   "With the exception of -e, -d and -i, passing an empty argument clears the modification.", 
-                   NULL),
-    m_options (interpreter)
+CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
+    CommandObjectMultiword (interpreter, 
+                            "breakpoint",
+                            "A set of commands for operating on breakpoints. Also see _regexp-break.",
+                            "breakpoint <command> [<command-options>]")
 {
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back (arg);   
-}
+    bool status;
 
-CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
-{
+    CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
+    CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
+    CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
+    CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
+    CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
+    CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
+    CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
+    CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
+
+    list_command_object->SetCommandName ("breakpoint list");
+    enable_command_object->SetCommandName("breakpoint enable");
+    disable_command_object->SetCommandName("breakpoint disable");
+    clear_command_object->SetCommandName("breakpoint clear");
+    delete_command_object->SetCommandName("breakpoint delete");
+    set_command_object->SetCommandName("breakpoint set");
+    command_command_object->SetCommandName ("breakpoint command");
+    modify_command_object->SetCommandName ("breakpoint modify");
+
+    status = LoadSubCommand ("list",       list_command_object);
+    status = LoadSubCommand ("enable",     enable_command_object);
+    status = LoadSubCommand ("disable",    disable_command_object);
+    status = LoadSubCommand ("clear",      clear_command_object);
+    status = LoadSubCommand ("delete",     delete_command_object);
+    status = LoadSubCommand ("set",        set_command_object);
+    status = LoadSubCommand ("command",    command_command_object);
+    status = LoadSubCommand ("modify",     modify_command_object);
 }
 
-Options *
-CommandObjectBreakpointModify::GetOptions ()
+CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
 {
-    return &m_options;
 }
 
-bool
-CommandObjectBreakpointModify::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
+void
+CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
+                                                         BreakpointIDList *valid_ids)
 {
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
+    // args can be strings representing 1). integers (for breakpoint ids)
+    //                                  2). the full breakpoint & location canonical representation
+    //                                  3). the word "to" or a hyphen, representing a range (in which case there
+    //                                      had *better* be an entry both before & after of one of the first two types.
+    // If args is empty, we will use the last created breakpoint (if there is one.)
+
+    Args temp_args;
+
+    if (args.GetArgumentCount() == 0)
     {
-        result.AppendError ("Invalid target.  No existing target or breakpoints.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        if (target->GetLastCreatedBreakpoint())
+        {
+            valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        } 
+        else
+        {   
+            result.AppendError("No breakpoint specified and no last created breakpoint.");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        return;
     }
-
-    Mutex::Locker locker;
-    target->GetBreakpointList().GetListMutex(locker);
     
-    BreakpointIDList valid_bp_ids;
+    // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
+    // the new TEMP_ARGS.  Do not copy breakpoint id range strings over; instead generate a list of strings for
+    // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
+
+    BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
+
+    // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
+
+    valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
 
-    CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+    // At this point,  all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
+    // and put into valid_ids.
 
     if (result.Succeeded())
     {
-        const size_t count = valid_bp_ids.GetSize(); 
+        // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
+        // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
+
+        const size_t count = valid_ids->GetSize();
         for (size_t i = 0; i < count; ++i)
         {
-            BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
-
-            if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+            BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
+            Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+            if (breakpoint != NULL)
             {
-                Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
-                {
-                    BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
-                    if (location)
-                    {
-                        if (m_options.m_thread_id_passed)
-                            location->SetThreadID (m_options.m_thread_id);
-                            
-                        if (m_options.m_thread_index_passed)
-                            location->SetThreadIndex(m_options.m_thread_index);
-                        
-                        if (m_options.m_name_passed)
-                            location->SetThreadName(m_options.m_thread_name.c_str());
-                        
-                        if (m_options.m_queue_passed)
-                            location->SetQueueName(m_options.m_queue_name.c_str());
-                            
-                        if (m_options.m_ignore_count != 0)
-                            location->SetIgnoreCount(m_options.m_ignore_count);
-                            
-                        if (m_options.m_enable_passed)
-                            location->SetEnabled (m_options.m_enable_value);
-                            
-                        if (m_options.m_condition_passed)
-                            location->SetCondition (m_options.m_condition.c_str());
-                    }
-                }
-                else
+                int num_locations = breakpoint->GetNumLocations();
+                if (cur_bp_id.GetLocationID() > num_locations)
                 {
-                    if (m_options.m_thread_id_passed)
-                        bp->SetThreadID (m_options.m_thread_id);
-                        
-                    if (m_options.m_thread_index_passed)
-                        bp->SetThreadIndex(m_options.m_thread_index);
-                    
-                    if (m_options.m_name_passed)
-                        bp->SetThreadName(m_options.m_thread_name.c_str());
-                    
-                    if (m_options.m_queue_passed)
-                        bp->SetQueueName(m_options.m_queue_name.c_str());
-                        
-                    if (m_options.m_ignore_count != 0)
-                        bp->SetIgnoreCount(m_options.m_ignore_count);
-                        
-                    if (m_options.m_enable_passed)
-                        bp->SetEnabled (m_options.m_enable_value);
-                        
-                    if (m_options.m_condition_passed)
-                        bp->SetCondition (m_options.m_condition.c_str());
+                    StreamString id_str;
+                    BreakpointID::GetCanonicalReference (&id_str, 
+                                                         cur_bp_id.GetBreakpointID(),
+                                                         cur_bp_id.GetLocationID());
+                    i = valid_ids->GetSize() + 1;
+                    result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
+                                                 id_str.GetData());
+                    result.SetStatus (eReturnStatusFailed);
                 }
             }
+            else
+            {
+                i = valid_ids->GetSize() + 1;
+                result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
+                result.SetStatus (eReturnStatusFailed);
+            }
         }
     }
-    
-    return result.Succeeded();
 }
-
-

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Fri Jun  8 16:56:10 2012
@@ -42,326 +42,6 @@
 
 };
 
-//-------------------------------------------------------------------------
-// CommandObjectdBreakpointSet
-//-------------------------------------------------------------------------
-
-
-class CommandObjectBreakpointSet : public CommandObject
-{
-public:
-
-    typedef enum BreakpointSetType
-    {
-        eSetTypeInvalid,
-        eSetTypeFileAndLine,
-        eSetTypeAddress,
-        eSetTypeFunctionName,
-        eSetTypeFunctionRegexp,
-        eSetTypeSourceRegexp,
-        eSetTypeException
-    } BreakpointSetType;
-
-    CommandObjectBreakpointSet (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointSet ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        std::string m_condition;
-        FileSpecList m_filenames;
-        uint32_t m_line_num;
-        uint32_t m_column;
-        bool m_check_inlines;
-        std::vector<std::string> m_func_names;
-        uint32_t m_func_name_type_mask;
-        std::string m_func_regexp;
-        std::string m_source_text_regexp;
-        FileSpecList m_modules;
-        lldb::addr_t m_load_addr;
-        uint32_t m_ignore_count;
-        lldb::tid_t m_thread_id;
-        uint32_t m_thread_index;
-        std::string m_thread_name;
-        std::string m_queue_name;
-        bool m_catch_bp;
-        bool m_throw_bp;
-        lldb::LanguageType m_language;
-        LazyBool m_skip_prologue;
-
-    };
-
-private:
-    bool
-    GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result);
-    
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectMultiwordBreakpointModify
-//-------------------------------------------------------------------------
-
-
-class CommandObjectBreakpointModify : public CommandObject
-{
-public:
-
-    CommandObjectBreakpointModify (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointModify ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        uint32_t m_ignore_count;
-        lldb::tid_t m_thread_id;
-        bool m_thread_id_passed;
-        uint32_t m_thread_index;
-        bool m_thread_index_passed;
-        std::string m_thread_name;
-        std::string m_queue_name;
-        std::string m_condition;
-        bool m_enable_passed;
-        bool m_enable_value;
-        bool m_name_passed;
-        bool m_queue_passed;
-        bool m_condition_passed;
-
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointEnable
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointEnable : public CommandObject
-{
-public:
-    CommandObjectBreakpointEnable (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointEnable ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointDisable
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointDisable : public CommandObject
-{
-public:
-    CommandObjectBreakpointDisable (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointDisable ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointList
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointList : public CommandObject
-{
-public:
-    CommandObjectBreakpointList (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointList ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition *
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        lldb::DescriptionLevel m_level;
-
-        bool m_internal;
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointClear
-//-------------------------------------------------------------------------
-
-
-class CommandObjectBreakpointClear : public CommandObject
-{
-public:
-
-    typedef enum BreakpointClearType
-    {
-        eClearTypeInvalid,
-        eClearTypeFileAndLine
-    } BreakpointClearType;
-
-    CommandObjectBreakpointClear (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointClear ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        std::string m_filename;
-        uint32_t m_line_num;
-
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointDelete
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointDelete : public CommandObject
-{
-public:
-    CommandObjectBreakpointDelete (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointDelete ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectBreakpoint_h_

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Jun  8 16:56:10 2012
@@ -28,143 +28,22 @@
 using namespace lldb_private;
 
 //-------------------------------------------------------------------------
-// CommandObjectBreakpointCommandAdd::CommandOptions
+// CommandObjectBreakpointCommandAdd
 //-------------------------------------------------------------------------
 
-CommandObjectBreakpointCommandAdd::CommandOptions::CommandOptions (CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_use_commands (false),
-    m_use_script_language (false),
-    m_script_language (eScriptLanguageNone),
-    m_use_one_liner (false),
-    m_one_liner(),
-    m_function_name()
-{
-}
 
-CommandObjectBreakpointCommandAdd::CommandOptions::~CommandOptions ()
+class CommandObjectBreakpointCommandAdd : public CommandObjectParsed
 {
-}
-
-// FIXME: "script-type" needs to have its contents determined dynamically, so somebody can add a new scripting
-// language to lldb and have it pickable here without having to change this enumeration by hand and rebuild lldb proper.
+public:
 
-static OptionEnumValueElement
-g_script_option_enumeration[4] =
-{
-    { eScriptLanguageNone,    "command",         "Commands are in the lldb command interpreter language"},
-    { eScriptLanguagePython,  "python",          "Commands are in the Python language."},
-    { eSortOrderByName,       "default-script",  "Commands are in the default scripting language."},
-    { 0,                      NULL,              NULL }
-};
-
-OptionDefinition
-CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_1, false, "one-liner", 'o', required_argument, NULL, NULL, eArgTypeOneLiner,
-        "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
-
-    { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', required_argument, NULL, NULL, eArgTypeBoolean,
-        "Specify whether breakpoint command execution should terminate on error." },
-
-    { LLDB_OPT_SET_ALL,   false, "script-type",     's', required_argument, g_script_option_enumeration, NULL, eArgTypeNone,
-        "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
-
-    { LLDB_OPT_SET_2,   false, "python-function",     'F', required_argument, NULL, NULL, eArgTypePythonFunction,
-        "Give the name of a Python function to run as command for this breakpoint. Be sure to give a module name if appropriate."},
-    
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
-};
-
-const OptionDefinition*
-CommandObjectBreakpointCommandAdd::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
-
-
-Error
-CommandObjectBreakpointCommandAdd::CommandOptions::SetOptionValue 
-(
-    uint32_t option_idx, 
-    const char *option_arg
-)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
-
-    switch (short_option)
+    CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "add",
+                             "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.",
+                             NULL),
+        m_options (interpreter)
     {
-    case 'o':
-        m_use_one_liner = true;
-        m_one_liner = option_arg;
-        break;
-
-    case 's':
-        m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, 
-                                                                             g_option_table[option_idx].enum_values, 
-                                                                             eScriptLanguageNone,
-                                                                             error);
-
-        if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault)
-        {
-            m_use_script_language = true;
-        }
-        else
-        {
-            m_use_script_language = false;
-        }          
-        break;
-
-    case 'e':
-        {
-            bool success = false;
-            m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
-            if (!success)
-                error.SetErrorStringWithFormat("invalid value for stop-on-error: \"%s\"", option_arg);
-        }
-        break;
-            
-    case 'F':
-        {
-            m_use_one_liner = false;
-            m_use_script_language = true;
-            m_function_name.assign(option_arg);
-        }
-        break;
-
-    default:
-        break;
-    }
-    return error;
-}
-
-void
-CommandObjectBreakpointCommandAdd::CommandOptions::OptionParsingStarting ()
-{
-    m_use_commands = true;
-    m_use_script_language = false;
-    m_script_language = eScriptLanguageNone;
-
-    m_use_one_liner = false;
-    m_stop_on_error = true;
-    m_one_liner.clear();
-    m_function_name.clear();
-}
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointCommandAdd
-//-------------------------------------------------------------------------
-
-
-CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "add",
-                   "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.",
-                   NULL),
-    m_options (interpreter)
-{
-    SetHelpLong (
+        SetHelpLong (
 "\nGeneral information about entering breakpoint commands \n\
 ------------------------------------------------------ \n\
  \n\
@@ -282,518 +161,698 @@
 debugger prompt.  You may enter as many debugger commands as you like, \n\
 but do NOT enter more than one command per line. \n" );
 
+        CommandArgumentEntry arg;
+        CommandArgumentData bp_id_arg;
 
-    CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
+        // Define the first (and only) variant of this arg.
+        bp_id_arg.arg_type = eArgTypeBreakpointID;
+        bp_id_arg.arg_repetition = eArgRepeatPlain;
 
-    // Define the first (and only) variant of this arg.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatPlain;
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (bp_id_arg);
 
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg.push_back (bp_id_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
-
-CommandObjectBreakpointCommandAdd::~CommandObjectBreakpointCommandAdd ()
-{
-}
-
-bool
-CommandObjectBreakpointCommandAdd::Execute 
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-
-    if (target == NULL)
-    {
-        result.AppendError ("There is not a current executable; there are no breakpoints to which to add commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
     }
 
-    const BreakpointList &breakpoints = target->GetBreakpointList();
-    size_t num_breakpoints = breakpoints.GetSize();
+    virtual
+    ~CommandObjectBreakpointCommandAdd () {}
 
-    if (num_breakpoints == 0)
+    virtual Options *
+    GetOptions ()
     {
-        result.AppendError ("No breakpoints exist to have commands added");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return &m_options;
     }
 
-    if (m_options.m_use_script_language == false && m_options.m_function_name.size())
+    void
+    CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, 
+                                             CommandReturnObject &result)
     {
-        result.AppendError ("need to enable scripting to have a function run as a breakpoint command");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger()));
+        std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+        if (reader_sp && data_ap.get())
+        {
+            BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
+            bp_options->SetCallback (BreakpointOptionsCallbackFunction, baton_sp);
+
+            Error err (reader_sp->Initialize (CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback,
+                                              bp_options,                   // baton
+                                              eInputReaderGranularityLine,  // token size, to pass to callback function
+                                              "DONE",                       // end token
+                                              "> ",                         // prompt
+                                              true));                       // echo input
+            if (err.Success())
+            {
+                m_interpreter.GetDebugger().PushInputReader (reader_sp);
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            }
+            else
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+        }
+        else
+        {
+            result.AppendError("out of memory");
+            result.SetStatus (eReturnStatusFailed);
+        }
+
     }
     
-    BreakpointIDList valid_bp_ids;
-    CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+    /// Set a one-liner as the callback for the breakpoint.
+    void 
+    SetBreakpointCommandCallback (BreakpointOptions *bp_options,
+                                  const char *oneliner)
+    {
+        std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+
+        // It's necessary to set both user_source and script_source to the oneliner.
+        // The former is used to generate callback description (as in breakpoint command list)
+        // while the latter is used for Python to interpret during the actual callback.
+        data_ap->user_source.AppendString (oneliner);
+        data_ap->script_source.assign (oneliner);
+        data_ap->stop_on_error = m_options.m_stop_on_error;
 
-    if (result.Succeeded())
+        BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
+        bp_options->SetCallback (BreakpointOptionsCallbackFunction, baton_sp);
+
+        return;
+    }
+
+    static size_t
+    GenerateBreakpointCommandCallback (void *baton, 
+                                       InputReader &reader, 
+                                       lldb::InputReaderAction notification,
+                                       const char *bytes, 
+                                       size_t bytes_len)
     {
-        const size_t count = valid_bp_ids.GetSize();
-        for (size_t i = 0; i < count; ++i)
+        StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
+        bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode();
+        
+        switch (notification)
         {
-            BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
-            if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+        case eInputReaderActivate:
+            if (!batch_mode)
             {
-                Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                BreakpointOptions *bp_options = NULL;
-                if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID)
-                {
-                    // This breakpoint does not have an associated location.
-                    bp_options = bp->GetOptions();
-                }
-                else                    
-                {
-                    BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
-                    // This breakpoint does have an associated location.
-                    // Get its breakpoint options.
-                    if (bp_loc_sp)
-                        bp_options = bp_loc_sp->GetLocationOptions();
-                }
+                out_stream->Printf ("%s\n", g_reader_instructions);
+                if (reader.GetPrompt())
+                    out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
+            }
+            break;
 
-                // Skip this breakpoint if bp_options is not good.
-                if (bp_options == NULL) continue;
+        case eInputReaderDeactivate:
+            break;
 
-                // If we are using script language, get the script interpreter
-                // in order to set or collect command callback.  Otherwise, call
-                // the methods associated with this object.
-                if (m_options.m_use_script_language)
+        case eInputReaderReactivate:
+            if (reader.GetPrompt() && !batch_mode)
+            {
+                out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
+            }
+            break;
+
+        case eInputReaderAsynchronousOutputWritten:
+            break;
+            
+        case eInputReaderGotToken:
+            if (bytes && bytes_len && baton)
+            {
+                BreakpointOptions *bp_options = (BreakpointOptions *) baton;
+                if (bp_options)
                 {
-                    // Special handling for one-liner specified inline.
-                    if (m_options.m_use_one_liner)
-                    {
-                        m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
-                                                                                            m_options.m_one_liner.c_str());
-                    }
-                    // Special handling for using a Python function by name
-                    // instead of extending the breakpoint callback data structures, we just automatize
-                    // what the user would do manually: make their breakpoint command be a function call
-                    else if (m_options.m_function_name.size())
-                    {
-                        std::string oneliner(m_options.m_function_name);
-                        oneliner += "(frame, bp_loc, dict)";
-                        m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
-                                                                                            oneliner.c_str());
-                    }
-                    else
+                    Baton *bp_options_baton = bp_options->GetBaton();
+                    if (bp_options_baton)
+                        ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); 
+                }
+            }
+            if (!reader.IsDone() && reader.GetPrompt() && !batch_mode)
+            {
+                out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
+            }
+            break;
+            
+        case eInputReaderInterrupt:
+            {
+                // Finish, and cancel the breakpoint command.
+                reader.SetIsDone (true);
+                BreakpointOptions *bp_options = (BreakpointOptions *) baton;
+                if (bp_options)
+                {
+                    Baton *bp_options_baton = bp_options->GetBaton ();
+                    if (bp_options_baton)
                     {
-                        m_interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_options,
-                                                                                                       result);
+                        ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->user_source.Clear();
+                        ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->script_source.clear();
                     }
                 }
-                else
+                if (!batch_mode)
                 {
-                    // Special handling for one-liner specified inline.
-                    if (m_options.m_use_one_liner)
-                        SetBreakpointCommandCallback (bp_options,
-                                                      m_options.m_one_liner.c_str());
-                    else
-                        CollectDataForBreakpointCommandCallback (bp_options, 
-                                                                 result);
+                    out_stream->Printf ("Warning: No command attached to breakpoint.\n");
+                    out_stream->Flush();
                 }
             }
+            break;
+            
+        case eInputReaderEndOfFile:
+            reader.SetIsDone (true);
+            break;
+            
+        case eInputReaderDone:
+            break;
         }
+
+        return bytes_len;
     }
+    
+    static bool
+    BreakpointOptionsCallbackFunction (void *baton,
+                                       StoppointCallbackContext *context, 
+                                       lldb::user_id_t break_id,
+                                       lldb::user_id_t break_loc_id)
+    {
+        bool ret_value = true;
+        if (baton == NULL)
+            return true;
+        
+        
+        BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton;
+        StringList &commands = data->user_source;
+        
+        if (commands.GetSize() > 0)
+        {
+            ExecutionContext exe_ctx (context->exe_ctx_ref);
+            Target *target = exe_ctx.GetTargetPtr();
+            if (target)
+            {
+                CommandReturnObject result;
+                Debugger &debugger = target->GetDebugger();
+                // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously
+                // if the debugger is set up that way.
+                    
+                StreamSP output_stream (debugger.GetAsyncOutputStream());
+                StreamSP error_stream (debugger.GetAsyncErrorStream());
+                result.SetImmediateOutputStream (output_stream);
+                result.SetImmediateErrorStream (error_stream);
+        
+                bool stop_on_continue = true;
+                bool echo_commands    = false;
+                bool print_results    = true;
+
+                debugger.GetCommandInterpreter().HandleCommands (commands, 
+                                                                 &exe_ctx,
+                                                                 stop_on_continue, 
+                                                                 data->stop_on_error, 
+                                                                 echo_commands, 
+                                                                 print_results,
+                                                                 eLazyBoolNo,
+                                                                 result);
+                result.GetImmediateOutputStream()->Flush();
+                result.GetImmediateErrorStream()->Flush();
+           }
+        }
+        return ret_value;
+    }    
 
-    return result.Succeeded();
-}
+    class CommandOptions : public Options
+    {
+    public:
 
-Options *
-CommandObjectBreakpointCommandAdd::GetOptions ()
-{
-    return &m_options;
-}
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_use_commands (false),
+            m_use_script_language (false),
+            m_script_language (eScriptLanguageNone),
+            m_use_one_liner (false),
+            m_one_liner(),
+            m_function_name()
+        {
+        }
 
-const char *g_reader_instructions = "Enter your debugger command(s).  Type 'DONE' to end.";
+        virtual
+        ~CommandOptions () {}
 
-void
-CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback
-(
-    BreakpointOptions *bp_options,
-    CommandReturnObject &result
-)
-{
-    InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger()));
-    std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
-    if (reader_sp && data_ap.get())
-    {
-        BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
-        bp_options->SetCallback (CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction, baton_sp);
+        virtual Error
+        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 'o':
+                m_use_one_liner = true;
+                m_one_liner = option_arg;
+                break;
+
+            case 's':
+                m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, 
+                                                                                     g_option_table[option_idx].enum_values, 
+                                                                                     eScriptLanguageNone,
+                                                                                     error);
+
+                if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault)
+                {
+                    m_use_script_language = true;
+                }
+                else
+                {
+                    m_use_script_language = false;
+                }          
+                break;
+
+            case 'e':
+                {
+                    bool success = false;
+                    m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat("invalid value for stop-on-error: \"%s\"", option_arg);
+                }
+                break;
+                    
+            case 'F':
+                {
+                    m_use_one_liner = false;
+                    m_use_script_language = true;
+                    m_function_name.assign(option_arg);
+                }
+                break;
 
-        Error err (reader_sp->Initialize (CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback,
-                                          bp_options,                   // baton
-                                          eInputReaderGranularityLine,  // token size, to pass to callback function
-                                          "DONE",                       // end token
-                                          "> ",                         // prompt
-                                          true));                       // echo input
-        if (err.Success())
+            default:
+                break;
+            }
+            return error;
+        }
+        void
+        OptionParsingStarting ()
         {
-            m_interpreter.GetDebugger().PushInputReader (reader_sp);
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            m_use_commands = true;
+            m_use_script_language = false;
+            m_script_language = eScriptLanguageNone;
+
+            m_use_one_liner = false;
+            m_stop_on_error = true;
+            m_one_liner.clear();
+            m_function_name.clear();
         }
-        else
+
+        const OptionDefinition*
+        GetDefinitions ()
         {
-            result.AppendError (err.AsCString());
-            result.SetStatus (eReturnStatusFailed);
+            return g_option_table;
         }
-    }
-    else
-    {
-        result.AppendError("out of memory");
-        result.SetStatus (eReturnStatusFailed);
-    }
 
-}
+        // Options table: Required for subclasses of Options.
 
-// Set a one-liner as the callback for the breakpoint.
-void
-CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (BreakpointOptions *bp_options,
-                                                                 const char *oneliner)
-{
-    std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+        static OptionDefinition g_option_table[];
 
-    // It's necessary to set both user_source and script_source to the oneliner.
-    // The former is used to generate callback description (as in breakpoint command list)
-    // while the latter is used for Python to interpret during the actual callback.
-    data_ap->user_source.AppendString (oneliner);
-    data_ap->script_source.assign (oneliner);
-    data_ap->stop_on_error = m_options.m_stop_on_error;
+        // Instance variables to hold the values for command options.
 
-    BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
-    bp_options->SetCallback (CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction, baton_sp);
+        bool m_use_commands;
+        bool m_use_script_language;
+        lldb::ScriptLanguage m_script_language;
 
-    return;
-}
+        // Instance variables to hold the values for one_liner options.
+        bool m_use_one_liner;
+        std::string m_one_liner;
+        bool m_stop_on_error;
+        std::string m_function_name;
+    };
 
-size_t
-CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback
-(
-    void *baton, 
-    InputReader &reader, 
-    lldb::InputReaderAction notification,
-    const char *bytes, 
-    size_t bytes_len
-)
-{
-    StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
-    bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode();
-    
-    switch (notification)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-    case eInputReaderActivate:
-        if (!batch_mode)
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+
+        if (target == NULL)
         {
-            out_stream->Printf ("%s\n", g_reader_instructions);
-            if (reader.GetPrompt())
-                out_stream->Printf ("%s", reader.GetPrompt());
-            out_stream->Flush();
+            result.AppendError ("There is not a current executable; there are no breakpoints to which to add commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        break;
 
-    case eInputReaderDeactivate:
-        break;
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+        size_t num_breakpoints = breakpoints.GetSize();
 
-    case eInputReaderReactivate:
-        if (reader.GetPrompt() && !batch_mode)
+        if (num_breakpoints == 0)
         {
-            out_stream->Printf ("%s", reader.GetPrompt());
-            out_stream->Flush();
+            result.AppendError ("No breakpoints exist to have commands added");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        break;
 
-    case eInputReaderAsynchronousOutputWritten:
-        break;
-        
-    case eInputReaderGotToken:
-        if (bytes && bytes_len && baton)
-        {
-            BreakpointOptions *bp_options = (BreakpointOptions *) baton;
-            if (bp_options)
-            {
-                Baton *bp_options_baton = bp_options->GetBaton();
-                if (bp_options_baton)
-                    ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); 
-            }
-        }
-        if (!reader.IsDone() && reader.GetPrompt() && !batch_mode)
+        if (m_options.m_use_script_language == false && m_options.m_function_name.size())
         {
-            out_stream->Printf ("%s", reader.GetPrompt());
-            out_stream->Flush();
+            result.AppendError ("need to enable scripting to have a function run as a breakpoint command");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        break;
         
-    case eInputReaderInterrupt:
+        BreakpointIDList valid_bp_ids;
+        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+
+        if (result.Succeeded())
         {
-            // Finish, and cancel the breakpoint command.
-            reader.SetIsDone (true);
-            BreakpointOptions *bp_options = (BreakpointOptions *) baton;
-            if (bp_options)
+            const size_t count = valid_bp_ids.GetSize();
+            for (size_t i = 0; i < count; ++i)
             {
-                Baton *bp_options_baton = bp_options->GetBaton ();
-                if (bp_options_baton)
+                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                 {
-                    ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->user_source.Clear();
-                    ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->script_source.clear();
+                    Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                    BreakpointOptions *bp_options = NULL;
+                    if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID)
+                    {
+                        // This breakpoint does not have an associated location.
+                        bp_options = bp->GetOptions();
+                    }
+                    else                    
+                    {
+                        BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
+                        // This breakpoint does have an associated location.
+                        // Get its breakpoint options.
+                        if (bp_loc_sp)
+                            bp_options = bp_loc_sp->GetLocationOptions();
+                    }
+
+                    // Skip this breakpoint if bp_options is not good.
+                    if (bp_options == NULL) continue;
+
+                    // If we are using script language, get the script interpreter
+                    // in order to set or collect command callback.  Otherwise, call
+                    // the methods associated with this object.
+                    if (m_options.m_use_script_language)
+                    {
+                        // Special handling for one-liner specified inline.
+                        if (m_options.m_use_one_liner)
+                        {
+                            m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
+                                                                                                m_options.m_one_liner.c_str());
+                        }
+                        // Special handling for using a Python function by name
+                        // instead of extending the breakpoint callback data structures, we just automatize
+                        // what the user would do manually: make their breakpoint command be a function call
+                        else if (m_options.m_function_name.size())
+                        {
+                            std::string oneliner(m_options.m_function_name);
+                            oneliner += "(frame, bp_loc, dict)";
+                            m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
+                                                                                                oneliner.c_str());
+                        }
+                        else
+                        {
+                            m_interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_options,
+                                                                                                           result);
+                        }
+                    }
+                    else
+                    {
+                        // Special handling for one-liner specified inline.
+                        if (m_options.m_use_one_liner)
+                            SetBreakpointCommandCallback (bp_options,
+                                                          m_options.m_one_liner.c_str());
+                        else
+                            CollectDataForBreakpointCommandCallback (bp_options, 
+                                                                     result);
+                    }
                 }
             }
-            if (!batch_mode)
-            {
-                out_stream->Printf ("Warning: No command attached to breakpoint.\n");
-                out_stream->Flush();
-            }
         }
-        break;
-        
-    case eInputReaderEndOfFile:
-        reader.SetIsDone (true);
-        break;
-        
-    case eInputReaderDone:
-        break;
+
+        return result.Succeeded();
     }
 
-    return bytes_len;
-}
+private:
+    CommandOptions m_options;
+    static const char *g_reader_instructions;
 
+};
+
+const char *
+CommandObjectBreakpointCommandAdd::g_reader_instructions = "Enter your debugger command(s).  Type 'DONE' to end.";
+
+// FIXME: "script-type" needs to have its contents determined dynamically, so somebody can add a new scripting
+// language to lldb and have it pickable here without having to change this enumeration by hand and rebuild lldb proper.
+
+static OptionEnumValueElement
+g_script_option_enumeration[4] =
+{
+    { eScriptLanguageNone,    "command",         "Commands are in the lldb command interpreter language"},
+    { eScriptLanguagePython,  "python",          "Commands are in the Python language."},
+    { eSortOrderByName,       "default-script",  "Commands are in the default scripting language."},
+    { 0,                      NULL,              NULL }
+};
+
+OptionDefinition
+CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_1, false, "one-liner", 'o', required_argument, NULL, NULL, eArgTypeOneLiner,
+        "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
+
+    { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', required_argument, NULL, NULL, eArgTypeBoolean,
+        "Specify whether breakpoint command execution should terminate on error." },
+
+    { LLDB_OPT_SET_ALL,   false, "script-type",     's', required_argument, g_script_option_enumeration, NULL, eArgTypeNone,
+        "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
+
+    { LLDB_OPT_SET_2,   false, "python-function",     'F', required_argument, NULL, NULL, eArgTypePythonFunction,
+        "Give the name of a Python function to run as command for this breakpoint. Be sure to give a module name if appropriate."},
+    
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectBreakpointCommandDelete
 //-------------------------------------------------------------------------
 
-CommandObjectBreakpointCommandDelete::CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "delete",
-                   "Delete the set of commands from a breakpoint.",
-                   NULL)
+class CommandObjectBreakpointCommandDelete : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
+public:
+    CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter, 
+                             "delete",
+                             "Delete the set of commands from a breakpoint.",
+                             NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData bp_id_arg;
 
-    // Define the first (and only) variant of this arg.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatPlain;
+        // Define the first (and only) variant of this arg.
+        bp_id_arg.arg_type = eArgTypeBreakpointID;
+        bp_id_arg.arg_repetition = eArgRepeatPlain;
 
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg.push_back (bp_id_arg);
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (bp_id_arg);
 
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+    }
 
-CommandObjectBreakpointCommandDelete::~CommandObjectBreakpointCommandDelete ()
-{
-}
 
-bool
-CommandObjectBreakpointCommandDelete::Execute 
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+    virtual
+    ~CommandObjectBreakpointCommandDelete () {}
 
-    if (target == NULL)
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("There is not a current executable; there are no breakpoints from which to delete commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
 
-    const BreakpointList &breakpoints = target->GetBreakpointList();
-    size_t num_breakpoints = breakpoints.GetSize();
+        if (target == NULL)
+        {
+            result.AppendError ("There is not a current executable; there are no breakpoints from which to delete commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (num_breakpoints == 0)
-    {
-        result.AppendError ("No breakpoints exist to have commands deleted");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+        size_t num_breakpoints = breakpoints.GetSize();
 
-    if (command.GetArgumentCount() == 0)
-    {
-        result.AppendError ("No breakpoint specified from which to delete the commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        if (num_breakpoints == 0)
+        {
+            result.AppendError ("No breakpoints exist to have commands deleted");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    BreakpointIDList valid_bp_ids;
-    CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+        if (command.GetArgumentCount() == 0)
+        {
+            result.AppendError ("No breakpoint specified from which to delete the commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (result.Succeeded())
-    {
-        const size_t count = valid_bp_ids.GetSize();
-        for (size_t i = 0; i < count; ++i)
+        BreakpointIDList valid_bp_ids;
+        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+
+        if (result.Succeeded())
         {
-            BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
-            if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+            const size_t count = valid_bp_ids.GetSize();
+            for (size_t i = 0; i < count; ++i)
             {
-                Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                 {
-                    BreakpointLocationSP bp_loc_sp (bp->FindLocationByID (cur_bp_id.GetLocationID()));
-                    if (bp_loc_sp)
-                        bp_loc_sp->ClearCallback();
+                    Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                    {
+                        BreakpointLocationSP bp_loc_sp (bp->FindLocationByID (cur_bp_id.GetLocationID()));
+                        if (bp_loc_sp)
+                            bp_loc_sp->ClearCallback();
+                        else
+                        {
+                            result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 
+                                                         cur_bp_id.GetBreakpointID(),
+                                                         cur_bp_id.GetLocationID());
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
+                        }
+                    }
                     else
                     {
-                        result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 
-                                                     cur_bp_id.GetBreakpointID(),
-                                                     cur_bp_id.GetLocationID());
-                        result.SetStatus (eReturnStatusFailed);
-                        return false;
+                        bp->ClearCallback();
                     }
                 }
-                else
-                {
-                    bp->ClearCallback();
-                }
             }
         }
+        return result.Succeeded();
     }
-    return result.Succeeded();
-}
-
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectBreakpointCommandList
 //-------------------------------------------------------------------------
 
-CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "list",
-                   "List the script or set of commands to be executed when the breakpoint is hit.",
-                    NULL)
+class CommandObjectBreakpointCommandList : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandArgumentData bp_id_arg;
-
-    // Define the first (and only) variant of this arg.
-    bp_id_arg.arg_type = eArgTypeBreakpointID;
-    bp_id_arg.arg_repetition = eArgRepeatPlain;
+public:
+    CommandObjectBreakpointCommandList (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "list",
+                             "List the script or set of commands to be executed when the breakpoint is hit.",
+                              NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData bp_id_arg;
 
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg.push_back (bp_id_arg);
+        // Define the first (and only) variant of this arg.
+        bp_id_arg.arg_type = eArgTypeBreakpointID;
+        bp_id_arg.arg_repetition = eArgRepeatPlain;
 
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (bp_id_arg);
 
-CommandObjectBreakpointCommandList::~CommandObjectBreakpointCommandList ()
-{
-}
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+    }
 
-bool
-CommandObjectBreakpointCommandList::Execute 
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+    virtual
+    ~CommandObjectBreakpointCommandList () {}
 
-    if (target == NULL)
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result)
     {
-        result.AppendError ("There is not a current executable; there are no breakpoints for which to list commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+
+        if (target == NULL)
+        {
+            result.AppendError ("There is not a current executable; there are no breakpoints for which to list commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    const BreakpointList &breakpoints = target->GetBreakpointList();
-    size_t num_breakpoints = breakpoints.GetSize();
+        const BreakpointList &breakpoints = target->GetBreakpointList();
+        size_t num_breakpoints = breakpoints.GetSize();
 
-    if (num_breakpoints == 0)
-    {
-        result.AppendError ("No breakpoints exist for which to list commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        if (num_breakpoints == 0)
+        {
+            result.AppendError ("No breakpoints exist for which to list commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (command.GetArgumentCount() == 0)
-    {
-        result.AppendError ("No breakpoint specified for which to list the commands");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        if (command.GetArgumentCount() == 0)
+        {
+            result.AppendError ("No breakpoint specified for which to list the commands");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    BreakpointIDList valid_bp_ids;
-    CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
+        BreakpointIDList valid_bp_ids;
+        CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
 
-    if (result.Succeeded())
-    {
-        const size_t count = valid_bp_ids.GetSize();
-        for (size_t i = 0; i < count; ++i)
+        if (result.Succeeded())
         {
-            BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
-            if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
+            const size_t count = valid_bp_ids.GetSize();
+            for (size_t i = 0; i < count; ++i)
             {
-                Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
-                
-                if (bp)
+                BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
+                if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
                 {
-                    const BreakpointOptions *bp_options = NULL;
-                    if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                    Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
+                    
+                    if (bp)
                     {
-                        BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
-                        if (bp_loc_sp)
-                            bp_options = bp_loc_sp->GetOptionsNoCreate();
+                        const BreakpointOptions *bp_options = NULL;
+                        if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
+                        {
+                            BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
+                            if (bp_loc_sp)
+                                bp_options = bp_loc_sp->GetOptionsNoCreate();
+                            else
+                            {
+                                result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 
+                                                             cur_bp_id.GetBreakpointID(),
+                                                             cur_bp_id.GetLocationID());
+                                result.SetStatus (eReturnStatusFailed);
+                                return false;
+                            }
+                        }
                         else
                         {
-                            result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 
-                                                         cur_bp_id.GetBreakpointID(),
-                                                         cur_bp_id.GetLocationID());
-                            result.SetStatus (eReturnStatusFailed);
-                            return false;
+                            bp_options = bp->GetOptions();
+                        }
+
+                        if (bp_options)
+                        {
+                            StreamString id_str;
+                            BreakpointID::GetCanonicalReference (&id_str, 
+                                                                 cur_bp_id.GetBreakpointID(), 
+                                                                 cur_bp_id.GetLocationID());
+                            const Baton *baton = bp_options->GetBaton();
+                            if (baton)
+                            {
+                                result.GetOutputStream().Printf ("Breakpoint %s:\n", id_str.GetData());
+                                result.GetOutputStream().IndentMore ();
+                                baton->GetDescription(&result.GetOutputStream(), eDescriptionLevelFull);
+                                result.GetOutputStream().IndentLess ();
+                            }
+                            else
+                            {
+                                result.AppendMessageWithFormat ("Breakpoint %s does not have an associated command.\n", 
+                                                                id_str.GetData());
+                            }
                         }
+                        result.SetStatus (eReturnStatusSuccessFinishResult);
                     }
                     else
                     {
-                        bp_options = bp->GetOptions();
+                        result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", cur_bp_id.GetBreakpointID());
+                        result.SetStatus (eReturnStatusFailed);
                     }
 
-                    if (bp_options)
-                    {
-                        StreamString id_str;
-                        BreakpointID::GetCanonicalReference (&id_str, 
-                                                             cur_bp_id.GetBreakpointID(), 
-                                                             cur_bp_id.GetLocationID());
-                        const Baton *baton = bp_options->GetBaton();
-                        if (baton)
-                        {
-                            result.GetOutputStream().Printf ("Breakpoint %s:\n", id_str.GetData());
-                            result.GetOutputStream().IndentMore ();
-                            baton->GetDescription(&result.GetOutputStream(), eDescriptionLevelFull);
-                            result.GetOutputStream().IndentLess ();
-                        }
-                        else
-                        {
-                            result.AppendMessageWithFormat ("Breakpoint %s does not have an associated command.\n", 
-                                                            id_str.GetData());
-                        }
-                    }
-                    result.SetStatus (eReturnStatusSuccessFinishResult);
                 }
-                else
-                {
-                    result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", cur_bp_id.GetBreakpointID());
-                    result.SetStatus (eReturnStatusFailed);
-                }
-
             }
         }
-    }
 
-    return result.Succeeded();
-}
+        return result.Succeeded();
+    }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectBreakpointCommand
@@ -819,60 +878,8 @@
     status = LoadSubCommand ("list",   list_command_object);
 }
 
-
 CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand ()
 {
 }
 
-bool
-CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction 
-(
-    void *baton, 
-    StoppointCallbackContext *context,
-    lldb::user_id_t break_id, 
-    lldb::user_id_t break_loc_id
-)
-{
-    bool ret_value = true;
-    if (baton == NULL)
-        return true;
-    
-    
-    BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton;
-    StringList &commands = data->user_source;
-    
-    if (commands.GetSize() > 0)
-    {
-        ExecutionContext exe_ctx (context->exe_ctx_ref);
-        Target *target = exe_ctx.GetTargetPtr();
-        if (target)
-        {
-            CommandReturnObject result;
-            Debugger &debugger = target->GetDebugger();
-            // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously
-            // if the debugger is set up that way.
-                
-            StreamSP output_stream (debugger.GetAsyncOutputStream());
-            StreamSP error_stream (debugger.GetAsyncErrorStream());
-            result.SetImmediateOutputStream (output_stream);
-            result.SetImmediateErrorStream (error_stream);
-    
-            bool stop_on_continue = true;
-            bool echo_commands    = false;
-            bool print_results    = true;
-
-            debugger.GetCommandInterpreter().HandleCommands (commands, 
-                                                             &exe_ctx,
-                                                             stop_on_continue, 
-                                                             data->stop_on_error, 
-                                                             echo_commands, 
-                                                             print_results,
-                                                             eLazyBoolNo,
-                                                             result);
-            result.GetImmediateOutputStream()->Flush();
-            result.GetImmediateErrorStream()->Flush();
-       }
-    }
-    return ret_value;
-}
 

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Fri Jun  8 16:56:10 2012
@@ -39,136 +39,8 @@
     virtual
     ~CommandObjectBreakpointCommand ();
 
-
-    static bool
-    BreakpointOptionsCallbackFunction (void *baton, 
-                                       StoppointCallbackContext *context,
-                                       lldb::user_id_t break_id, 
-                                       lldb::user_id_t break_loc_id);
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointCommandAdd
-//-------------------------------------------------------------------------
-
-
-class CommandObjectBreakpointCommandAdd : public CommandObject
-{
-public:
-
-    CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointCommandAdd ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    void
-    CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, 
-                                             CommandReturnObject &result);
-
-    /// Set a one-liner as the callback for the breakpoint.
-    void 
-    SetBreakpointCommandCallback (BreakpointOptions *bp_options,
-                                  const char *oneliner);
-
-    static size_t
-    GenerateBreakpointCommandCallback (void *baton, 
-                                       InputReader &reader, 
-                                       lldb::InputReaderAction notification,
-                                       const char *bytes, 
-                                       size_t bytes_len);
-    
-    static bool
-    BreakpointOptionsCallbackFunction (void *baton, 
-                                       StoppointCallbackContext *context, 
-                                       lldb::user_id_t break_id,
-                                       lldb::user_id_t break_loc_id);
-    
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        bool m_use_commands;
-        bool m_use_script_language;
-        lldb::ScriptLanguage m_script_language;
-
-        // Instance variables to hold the values for one_liner options.
-        bool m_use_one_liner;
-        std::string m_one_liner;
-        bool m_stop_on_error;
-        std::string m_function_name;
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointCommandDelete
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointCommandDelete : public CommandObject
-{
-public:
-    CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointCommandDelete ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectBreakpointCommandList
-//-------------------------------------------------------------------------
-
-class CommandObjectBreakpointCommandList : public CommandObject
-{
-public:
-    CommandObjectBreakpointCommandList (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectBreakpointCommandList ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
 };
 
-
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectBreakpointCommand_h_

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Fri Jun  8 16:56:10 2012
@@ -34,9 +34,27 @@
 // CommandObjectCommandsSource
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsHistory : public CommandObject
+class CommandObjectCommandsHistory : public CommandObjectParsed
 {
-private:
+public:
+    CommandObjectCommandsHistory(CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "command history",
+                             "Dump the history of commands in this session.",
+                             NULL),
+        m_options (interpreter)
+    {
+    }
+
+    ~CommandObjectCommandsHistory () {}
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+protected:
 
     class CommandOptions : public Options
     {
@@ -108,34 +126,8 @@
         uint32_t m_end_idx;
     };
     
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-
-public:
-    CommandObjectCommandsHistory(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "command history",
-                       "Dump the history of commands in this session.",
-                       NULL),
-        m_options (interpreter)
-    {
-    }
-
-    ~CommandObjectCommandsHistory ()
-    {
-    }
-
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         m_interpreter.DumpHistory (result.GetOutputStream(),
@@ -144,6 +136,8 @@
         return result.Succeeded();
 
     }
+
+    CommandOptions m_options;
 };
 
 OptionDefinition
@@ -160,9 +154,69 @@
 // CommandObjectCommandsSource
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsSource : public CommandObject
+class CommandObjectCommandsSource : public CommandObjectParsed
 {
-private:
+public:
+    CommandObjectCommandsSource(CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "command source",
+                             "Read in debugger commands from the file <filename> and execute them.",
+                             NULL),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData file_arg;
+        
+        // Define the first (and only) variant of this arg.
+        file_arg.arg_type = eArgTypeFilename;
+        file_arg.arg_repetition = eArgRepeatPlain;
+        
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (file_arg);
+        
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+    }
+
+    ~CommandObjectCommandsSource () {}
+
+    virtual const char*
+    GetRepeatCommand (Args &current_command_args, uint32_t index)
+    {
+        return "";
+    }
+    
+    int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
+                                                             CommandCompletions::eDiskFileCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
+    }
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+protected:
 
     class CommandOptions : public Options
     {
@@ -226,51 +280,13 @@
         bool m_stop_on_continue;
     };
     
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-
-public:
-    CommandObjectCommandsSource(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "command source",
-                       "Read in debugger commands from the file <filename> and execute them.",
-                       NULL),
-        m_options (interpreter)
-    {
-        CommandArgumentEntry arg;
-        CommandArgumentData file_arg;
-        
-        // Define the first (and only) variant of this arg.
-        file_arg.arg_type = eArgTypeFilename;
-        file_arg.arg_repetition = eArgRepeatPlain;
-        
-        // There is only one variant this argument could be; put it into the argument entry.
-        arg.push_back (file_arg);
-        
-        // Push the data for the first argument into the m_arguments vector.
-        m_arguments.push_back (arg);
-    }
-
-    ~CommandObjectCommandsSource ()
-    {
-    }
-
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    DoExecute(Args& command, CommandReturnObject &result)
     {
-        const int argc = args.GetArgumentCount();
+        const int argc = command.GetArgumentCount();
         if (argc == 1)
         {
-            const char *filename = args.GetArgumentAtIndex(0);
+            const char *filename = command.GetArgumentAtIndex(0);
 
             result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename);
 
@@ -296,36 +312,7 @@
         return result.Succeeded();
 
     }
-    
-    virtual const char*
-    GetRepeatCommand (Args &current_command_args, uint32_t index)
-    {
-        return "";
-    }
-    
-    int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
-                                                             CommandCompletions::eDiskFileCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        return matches.GetSize();
-    }
+    CommandOptions m_options;    
 };
 
 OptionDefinition
@@ -346,13 +333,13 @@
                                                      "def my_command_impl(debugger, args, result, dict):";
 
 
-class CommandObjectCommandsAlias : public CommandObject
+class CommandObjectCommandsAlias : public CommandObjectRaw
 {
     
     
 public:
     CommandObjectCommandsAlias (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
+        CommandObjectRaw (interpreter,
                        "command alias",
                        "Allow users to define their own debugger command abbreviations.",
                        NULL)
@@ -451,14 +438,9 @@
     {
     }
 
-    bool
-    WantsRawCommandString ()
-    {
-        return true;
-    }
-    
-    bool
-    ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result)
+protected:
+    virtual bool
+    DoExecute (const char *raw_command_line, CommandReturnObject &result)
     {
         Args args (raw_command_line);
         std::string raw_command_string (raw_command_line);
@@ -518,16 +500,24 @@
         {
             // Note that args was initialized with the original command, and has not been updated to this point.
             // Therefore can we pass it to the version of Execute that does not need/expect raw input in the alias.
-            return Execute (args, result);
+            return HandleAliasingNormalCommand (args, result);
         }
         else
         {
+            return HandleAliasingRawCommand (alias_command, raw_command_string, *cmd_obj, result);
+        }
+        return result.Succeeded();
+    }
+
+    bool
+    HandleAliasingRawCommand (const std::string &alias_command, std::string &raw_command_string, CommandObject &cmd_obj, CommandReturnObject &result)
+    {
             // Verify & handle any options/arguments passed to the alias command
             
             OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector);
             OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
             
-            CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (cmd_obj->GetCommandName(), false);
+            CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (cmd_obj.GetCommandName(), false);
 
             if (!m_interpreter.ProcessAliasOptionsArgs (cmd_obj_sp, raw_command_string.c_str(), option_arg_vector_sp))
             {
@@ -562,16 +552,11 @@
                 result.AppendError ("Unable to create requested alias.\n");
                 result.SetStatus (eReturnStatusFailed);
             }
-        }
-        return result.Succeeded();
+            return result.Succeeded ();
     }
-
+    
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    HandleAliasingNormalCommand (Args& args, CommandReturnObject &result)
     {
         size_t argc = args.GetArgumentCount();
 
@@ -686,6 +671,7 @@
 
         return result.Succeeded();
     }
+    
 };
 
 #pragma mark CommandObjectCommandsUnalias
@@ -693,11 +679,11 @@
 // CommandObjectCommandsUnalias
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsUnalias : public CommandObject
+class CommandObjectCommandsUnalias : public CommandObjectParsed
 {
 public:
     CommandObjectCommandsUnalias (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
+        CommandObjectParsed (interpreter,
                        "command unalias",
                        "Allow the user to remove/delete a user-defined command abbreviation.",
                        NULL)
@@ -720,13 +706,9 @@
     {
     }
 
-
+protected:
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         CommandObject::CommandMap::iterator pos;
         CommandObject *cmd_obj;
@@ -777,16 +759,16 @@
     }
 };
 
-#pragma mark CommandObjectCommandsAddRegex
 //-------------------------------------------------------------------------
 // CommandObjectCommandsAddRegex
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectCommandsAddRegex
 
-class CommandObjectCommandsAddRegex : public CommandObject
+class CommandObjectCommandsAddRegex : public CommandObjectParsed
 {
 public:
     CommandObjectCommandsAddRegex (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
+        CommandObjectParsed (interpreter,
                        "command regex",
                        "Allow the user to create a regular expression command.",
                        "command regex <cmd-name> [s/<regex>/<subst>/ ...]"),
@@ -822,10 +804,11 @@
     }
     
     
+protected:
     bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        const size_t argc = args.GetArgumentCount();
+        const size_t argc = command.GetArgumentCount();
         if (argc == 0)
         {
             result.AppendError ("usage: 'command regex <command-name> [s/<regex1>/<subst1>/ s/<regex2>/<subst2>/ ...]'\n");
@@ -834,7 +817,7 @@
         else
         {   
             Error error;
-            const char *name = args.GetArgumentAtIndex(0);
+            const char *name = command.GetArgumentAtIndex(0);
             m_regex_cmd_ap.reset (new CommandObjectRegexCommand (m_interpreter, 
                                                                  name, 
                                                                  m_options.GetHelp (),
@@ -864,7 +847,7 @@
             {
                 for (size_t arg_idx = 1; arg_idx < argc; ++arg_idx)
                 {
-                    llvm::StringRef arg_strref (args.GetArgumentAtIndex(arg_idx));
+                    llvm::StringRef arg_strref (command.GetArgumentAtIndex(arg_idx));
                     error = AppendRegexSubstitution (arg_strref);
                     if (error.Fail())
                         break;
@@ -1007,7 +990,78 @@
                          InputReader &reader, 
                          lldb::InputReaderAction notification,
                          const char *bytes, 
-                         size_t bytes_len);
+                         size_t bytes_len)
+    {
+        CommandObjectCommandsAddRegex *add_regex_cmd = (CommandObjectCommandsAddRegex *) baton;
+        bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode();    
+        
+        switch (notification)
+        {
+            case eInputReaderActivate:
+                if (!batch_mode)
+                {
+                    StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream ();
+                    out_stream->Printf("%s\n", "Enter regular expressions in the form 's/<regex>/<subst>/' and terminate with an empty line:");
+                    out_stream->Flush();
+                }
+                break;
+            case eInputReaderReactivate:
+                break;
+                
+            case eInputReaderDeactivate:
+                break;
+            
+            case eInputReaderAsynchronousOutputWritten:
+                break;
+                        
+            case eInputReaderGotToken:
+                while (bytes_len > 0 && (bytes[bytes_len-1] == '\r' || bytes[bytes_len-1] == '\n'))
+                    --bytes_len;
+                if (bytes_len == 0)
+                    reader.SetIsDone(true);
+                else if (bytes)
+                {
+                    llvm::StringRef bytes_strref (bytes, bytes_len);
+                    Error error (add_regex_cmd->AppendRegexSubstitution (bytes_strref));
+                    if (error.Fail())
+                    {
+                        if (!batch_mode)
+                        {
+                            StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
+                            out_stream->Printf("error: %s\n", error.AsCString());
+                            out_stream->Flush();
+                        }
+                        add_regex_cmd->InputReaderDidCancel ();
+                        reader.SetIsDone (true);
+                    }
+                }
+                break;
+                
+            case eInputReaderInterrupt:
+                {
+                    reader.SetIsDone (true);
+                    if (!batch_mode)
+                    {
+                        StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
+                        out_stream->PutCString("Regular expression command creations was cancelled.\n");
+                        out_stream->Flush();
+                    }
+                    add_regex_cmd->InputReaderDidCancel ();
+                }
+                break;
+                
+            case eInputReaderEndOfFile:
+                reader.SetIsDone (true);
+                break;
+                
+            case eInputReaderDone:
+                add_regex_cmd->AddRegexCommandToInterpreter();
+                break;
+        }
+        
+        return bytes_len;
+    }
+
 private:
     std::auto_ptr<CommandObjectRegexCommand> m_regex_cmd_ap;    
 
@@ -1082,95 +1136,16 @@
          std::string m_help;
          std::string m_syntax;
      };
-     
-     CommandOptions m_options;
-     
+          
      virtual Options *
      GetOptions ()
      {
          return &m_options;
      }
-
+     
+     CommandOptions m_options;
 };
 
-size_t
-CommandObjectCommandsAddRegex::InputReaderCallback (void *baton, 
-                                                    InputReader &reader, 
-                                                    lldb::InputReaderAction notification,
-                                                    const char *bytes, 
-                                                    size_t bytes_len)
-{
-    CommandObjectCommandsAddRegex *add_regex_cmd = (CommandObjectCommandsAddRegex *) baton;
-    bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode();    
-    
-    switch (notification)
-    {
-        case eInputReaderActivate:
-            if (!batch_mode)
-            {
-                StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream ();
-                out_stream->Printf("%s\n", "Enter regular expressions in the form 's/<regex>/<subst>/' and terminate with an empty line:");
-                out_stream->Flush();
-            }
-            break;
-        case eInputReaderReactivate:
-            break;
-            
-        case eInputReaderDeactivate:
-            break;
-        
-        case eInputReaderAsynchronousOutputWritten:
-            break;
-                    
-        case eInputReaderGotToken:
-            while (bytes_len > 0 && (bytes[bytes_len-1] == '\r' || bytes[bytes_len-1] == '\n'))
-                --bytes_len;
-            if (bytes_len == 0)
-                reader.SetIsDone(true);
-            else if (bytes)
-            {
-                llvm::StringRef bytes_strref (bytes, bytes_len);
-                Error error (add_regex_cmd->AppendRegexSubstitution (bytes_strref));
-                if (error.Fail())
-                {
-                    if (!batch_mode)
-                    {
-                        StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
-                        out_stream->Printf("error: %s\n", error.AsCString());
-                        out_stream->Flush();
-                    }
-                    add_regex_cmd->InputReaderDidCancel ();
-                    reader.SetIsDone (true);
-                }
-            }
-            break;
-            
-        case eInputReaderInterrupt:
-            {
-                reader.SetIsDone (true);
-                if (!batch_mode)
-                {
-                    StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
-                    out_stream->PutCString("Regular expression command creations was cancelled.\n");
-                    out_stream->Flush();
-                }
-                add_regex_cmd->InputReaderDidCancel ();
-            }
-            break;
-            
-        case eInputReaderEndOfFile:
-            reader.SetIsDone (true);
-            break;
-            
-        case eInputReaderDone:
-            add_regex_cmd->AddRegexCommandToInterpreter();
-            break;
-    }
-    
-    return bytes_len;
-}
-
-                                                                 
 OptionDefinition
 CommandObjectCommandsAddRegex::CommandOptions::g_option_table[] =
 {
@@ -1180,7 +1155,7 @@
 };
 
 
-class CommandObjectPythonFunction : public CommandObject
+class CommandObjectPythonFunction : public CommandObjectRaw
 {
 private:
     std::string m_function_name;
@@ -1192,12 +1167,12 @@
                                  std::string name,
                                  std::string funct,
                                  ScriptedCommandSynchronicity synch) :
-    CommandObject (interpreter,
-                   name.c_str(),
-                   (std::string("Run Python function ") + funct).c_str(),
-                   NULL),
-    m_function_name(funct),
-    m_synchro(synch)
+        CommandObjectRaw (interpreter,
+                          name.c_str(),
+                          (std::string("Run Python function ") + funct).c_str(),
+                          NULL),
+        m_function_name(funct),
+        m_synchro(synch)
     {
         ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
         if (scripter)
@@ -1214,7 +1189,26 @@
     }
     
     virtual bool
-    ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result)
+    IsRemovable ()
+    {
+        return true;
+    }
+
+    const std::string&
+    GetFunctionName ()
+    {
+        return m_function_name;
+    }
+
+    ScriptedCommandSynchronicity
+    GetSynchronicity ()
+    {
+        return m_synchro;
+    }
+    
+protected:
+    virtual bool
+    DoExecute (const char *raw_command_line, CommandReturnObject &result)
     {
         ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
         
@@ -1235,55 +1229,78 @@
         return result.Succeeded();
     }
     
-    virtual bool
-    WantsRawCommandString ()
-    {
-        return true;
-    }
+};
 
-    bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    {
-        std::string cmd_string;
-        command.GetCommandString(cmd_string);
-        return ExecuteRawCommandString(cmd_string.c_str(), result);
-    }
+//-------------------------------------------------------------------------
+// CommandObjectCommandsScriptImport
+//-------------------------------------------------------------------------
 
-    virtual bool
-    IsRemovable ()
+class CommandObjectCommandsScriptImport : public CommandObjectParsed
+{
+public:
+    CommandObjectCommandsScriptImport (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "command script import",
+                             "Import a scripting module in LLDB.",
+                             NULL),
+        m_options(interpreter)
     {
-        return true;
+        CommandArgumentEntry arg1;
+        CommandArgumentData cmd_arg;
+        
+        // Define the first (and only) variant of this arg.
+        cmd_arg.arg_type = eArgTypeFilename;
+        cmd_arg.arg_repetition = eArgRepeatPlain;
+        
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (cmd_arg);
+        
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
     }
-
-    const std::string&
-    GetFunctionName ()
+    
+    ~CommandObjectCommandsScriptImport ()
     {
-        return m_function_name;
     }
-
-    ScriptedCommandSynchronicity
-    GetSynchronicity ()
+    
+    int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
     {
-        return m_synchro;
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
+                                                             CommandCompletions::eDiskFileCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
     }
     
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectCommandsScriptImport
-//-------------------------------------------------------------------------
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
 
-class CommandObjectCommandsScriptImport : public CommandObject
-{
-private:
+protected:
     
     class CommandOptions : public Options
     {
     public:
         
         CommandOptions (CommandInterpreter &interpreter) :
-        Options (interpreter)
+            Options (interpreter)
         {
         }
         
@@ -1329,47 +1346,9 @@
         
         bool m_allow_reload;
     };
-    
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
 
-public:
-    CommandObjectCommandsScriptImport (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "command script import",
-                   "Import a scripting module in LLDB.",
-                   NULL),
-    m_options(interpreter)
-    {
-        CommandArgumentEntry arg1;
-        CommandArgumentData cmd_arg;
-        
-        // Define the first (and only) variant of this arg.
-        cmd_arg.arg_type = eArgTypeFilename;
-        cmd_arg.arg_repetition = eArgRepeatPlain;
-        
-        // There is only one variant this argument could be; put it into the argument entry.
-        arg1.push_back (cmd_arg);
-        
-        // Push the data for the first argument into the m_arguments vector.
-        m_arguments.push_back (arg1);
-    }
-    
-    ~CommandObjectCommandsScriptImport ()
-    {
-    }
-    
     bool
-    Execute
-    (
-     Args& args,
-     CommandReturnObject &result
-     )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
@@ -1379,7 +1358,7 @@
             return false;
         }
         
-        size_t argc = args.GetArgumentCount();
+        size_t argc = command.GetArgumentCount();
         
         if (argc != 1)
         {
@@ -1388,7 +1367,7 @@
             return false;
         }
         
-        std::string path = args.GetArgumentAtIndex(0);
+        std::string path = command.GetArgumentAtIndex(0);
         Error error;
         
         if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(),
@@ -1406,29 +1385,7 @@
         return result.Succeeded();
     }
     
-    int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
-                                                             CommandCompletions::eDiskFileCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        return matches.GetSize();
-    }
+    CommandOptions m_options;
 };
 
 OptionDefinition
@@ -1443,9 +1400,41 @@
 // CommandObjectCommandsScriptAdd
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsScriptAdd : public CommandObject
+class CommandObjectCommandsScriptAdd : public CommandObjectParsed
 {
-private:
+public:
+    CommandObjectCommandsScriptAdd(CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "command script add",
+                             "Add a scripted function as an LLDB command.",
+                             NULL),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentData cmd_arg;
+        
+        // Define the first (and only) variant of this arg.
+        cmd_arg.arg_type = eArgTypeCommandName;
+        cmd_arg.arg_repetition = eArgRepeatPlain;
+        
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (cmd_arg);
+        
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+    }
+    
+    ~CommandObjectCommandsScriptAdd ()
+    {
+    }
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     
     class CommandOptions : public Options
     {
@@ -1505,15 +1494,8 @@
         std::string m_funct_name;
         ScriptedCommandSynchronicity m_synchronous;
     };
-    
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
+
+private:
     class PythonAliasReader : public InputReaderEZ
     {
     private:
@@ -1632,38 +1614,9 @@
         }
     };
     
-public:
-    CommandObjectCommandsScriptAdd(CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "command script add",
-                   "Add a scripted function as an LLDB command.",
-                   NULL),
-    m_options (interpreter)
-    {
-        CommandArgumentEntry arg1;
-        CommandArgumentData cmd_arg;
-        
-        // Define the first (and only) variant of this arg.
-        cmd_arg.arg_type = eArgTypeCommandName;
-        cmd_arg.arg_repetition = eArgRepeatPlain;
-        
-        // There is only one variant this argument could be; put it into the argument entry.
-        arg1.push_back (cmd_arg);
-        
-        // Push the data for the first argument into the m_arguments vector.
-        m_arguments.push_back (arg1);
-    }
-    
-    ~CommandObjectCommandsScriptAdd ()
-    {
-    }
-    
+protected:
     bool
-    Execute
-    (
-     Args& args,
-     CommandReturnObject &result
-     )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
@@ -1673,7 +1626,7 @@
             return false;
         }
         
-        size_t argc = args.GetArgumentCount();
+        size_t argc = command.GetArgumentCount();
         
         if (argc != 1)
         {
@@ -1682,7 +1635,7 @@
             return false;
         }
         
-        std::string cmd_name = args.GetArgumentAtIndex(0);
+        std::string cmd_name = command.GetArgumentAtIndex(0);
         
         if (m_options.m_funct_name.empty())
         {
@@ -1734,6 +1687,8 @@
         return result.Succeeded();
         
     }
+    
+    CommandOptions m_options;
 };
 
 static OptionEnumValueElement g_script_synchro_type[] =
@@ -1756,13 +1711,13 @@
 // CommandObjectCommandsScriptList
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsScriptList : public CommandObject
+class CommandObjectCommandsScriptList : public CommandObjectParsed
 {
 private:
 
 public:
     CommandObjectCommandsScriptList(CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
+    CommandObjectParsed (interpreter,
                    "command script list",
                    "List defined scripted commands.",
                    NULL)
@@ -1774,11 +1729,7 @@
     }
     
     bool
-    Execute
-    (
-     Args& args,
-     CommandReturnObject &result
-     )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         m_interpreter.GetHelp(result,
@@ -1796,16 +1747,16 @@
 // CommandObjectCommandsScriptClear
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsScriptClear : public CommandObject
+class CommandObjectCommandsScriptClear : public CommandObjectParsed
 {
 private:
     
 public:
     CommandObjectCommandsScriptClear(CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "command script clear",
-                   "Delete all scripted commands.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "command script clear",
+                             "Delete all scripted commands.",
+                             NULL)
     {
     }
     
@@ -1813,12 +1764,9 @@
     {
     }
     
+protected:
     bool
-    Execute
-    (
-     Args& args,
-     CommandReturnObject &result
-     )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         m_interpreter.RemoveAllUser();
@@ -1826,8 +1774,6 @@
         result.SetStatus (eReturnStatusSuccessFinishResult);
         
         return true;
-        
-        
     }
 };
 
@@ -1835,16 +1781,14 @@
 // CommandObjectCommandsScriptDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectCommandsScriptDelete : public CommandObject
+class CommandObjectCommandsScriptDelete : public CommandObjectParsed
 {
-private:
-    
 public:
     CommandObjectCommandsScriptDelete(CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "command script delete",
-                   "Delete a scripted command.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "command script delete",
+                             "Delete a scripted command.",
+                             NULL)
     {
         CommandArgumentEntry arg1;
         CommandArgumentData cmd_arg;
@@ -1864,15 +1808,12 @@
     {
     }
     
+protected:
     bool
-    Execute
-    (
-     Args& args,
-     CommandReturnObject &result
-     )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
-        size_t argc = args.GetArgumentCount();
+        size_t argc = command.GetArgumentCount();
         
         if (argc != 1)
         {
@@ -1881,7 +1822,7 @@
             return false;
         }
         
-        const char* cmd_name = args.GetArgumentAtIndex(0);
+        const char* cmd_name = command.GetArgumentAtIndex(0);
         
         if (cmd_name && *cmd_name && m_interpreter.HasUserCommands() && m_interpreter.UserCommandExists(cmd_name))
         {

Modified: lldb/trunk/source/Commands/CommandObjectCrossref.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCrossref.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCrossref.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCrossref.cpp Fri Jun  8 16:56:10 2012
@@ -29,7 +29,7 @@
     const char *help,
     const char *syntax
 ) :
-    CommandObject (interpreter, name, help, syntax),
+    CommandObjectParsed (interpreter, name, help, syntax),
     m_crossref_object_types()
 {
 }
@@ -39,11 +39,7 @@
 }
 
 bool
-CommandObjectCrossref::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
+CommandObjectCrossref::DoExecute (Args& command, CommandReturnObject &result)
 {
     if (m_crossref_object_types.GetArgumentCount() == 0)
     {

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Fri Jun  8 16:56:10 2012
@@ -210,10 +210,10 @@
 //-------------------------------------------------------------------------
 
 CommandObjectDisassemble::CommandObjectDisassemble (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "disassemble",
-                   "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.",
-                   "disassemble [<cmd-options>]"),
+    CommandObjectParsed (interpreter,
+                         "disassemble",
+                         "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.",
+                         "disassemble [<cmd-options>]"),
     m_options (interpreter)
 {
 }
@@ -223,11 +223,7 @@
 }
 
 bool
-CommandObjectDisassemble::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
+CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
 {
     Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
     if (target == NULL)

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Fri Jun  8 16:56:10 2012
@@ -23,7 +23,7 @@
 // CommandObjectDisassemble
 //-------------------------------------------------------------------------
 
-class CommandObjectDisassemble : public CommandObject
+class CommandObjectDisassemble : public CommandObjectParsed
 {
 public:
     class CommandOptions : public Options
@@ -85,11 +85,11 @@
         return &m_options;
     }
 
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result);
 
-protected:
     CommandOptions m_options;
 
 };

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Jun  8 16:56:10 2012
@@ -134,10 +134,11 @@
 }
 
 CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "expression",
-                   "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.",
-                   NULL),
+    CommandObjectRaw (interpreter,
+                      "expression",
+                      "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.",
+                      NULL,
+                      eFlagProcessMustBePaused),
     m_option_group (interpreter),
     m_format_options (eFormatDefault),
     m_command_options (),
@@ -180,18 +181,6 @@
     return &m_option_group;
 }
 
-
-bool
-CommandObjectExpression::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    return false;
-}
-
-
 size_t
 CommandObjectExpression::MultiLineExpressionCallback
 (
@@ -418,7 +407,7 @@
 }
 
 bool
-CommandObjectExpression::ExecuteRawCommandString
+CommandObjectExpression::DoExecute
 (
     const char *command,
     CommandReturnObject &result

Modified: lldb/trunk/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.h (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.h Fri Jun  8 16:56:10 2012
@@ -20,7 +20,7 @@
 
 namespace lldb_private {
 
-class CommandObjectExpression : public CommandObject
+class CommandObjectExpression : public CommandObjectRaw
 {
 public:
 
@@ -66,19 +66,10 @@
     Options *
     GetOptions ();
 
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *command,
-                             CommandReturnObject &result);
-
 protected:
+    virtual bool
+    DoExecute (const char *command,
+               CommandReturnObject &result);
 
     static size_t
     MultiLineExpressionCallback (void *baton, 

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Jun  8 16:56:10 2012
@@ -52,16 +52,16 @@
 // CommandObjectFrameInfo
 //-------------------------------------------------------------------------
 
-class CommandObjectFrameInfo : public CommandObject
+class CommandObjectFrameInfo : public CommandObjectParsed
 {
 public:
 
     CommandObjectFrameInfo (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "frame info",
-                       "List information about the currently selected frame in the current thread.",
-                       "frame info",
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "frame info",
+                             "List information about the currently selected frame in the current thread.",
+                             "frame info",
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
     }
 
@@ -69,8 +69,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
@@ -95,7 +96,7 @@
 // CommandObjectFrameSelect
 //-------------------------------------------------------------------------
 
-class CommandObjectFrameSelect : public CommandObject
+class CommandObjectFrameSelect : public CommandObjectParsed
 {
 public:
 
@@ -155,11 +156,11 @@
     };
     
     CommandObjectFrameSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "frame select",
-                       "Select a frame by index from within the current thread and make it the current frame.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter,
+                             "frame select",
+                             "Select a frame by index from within the current thread and make it the current frame.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -188,8 +189,9 @@
     }
 
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
@@ -319,21 +321,21 @@
 //----------------------------------------------------------------------
 // List images with associated information
 //----------------------------------------------------------------------
-class CommandObjectFrameVariable : public CommandObject
+class CommandObjectFrameVariable : public CommandObjectParsed
 {
 public:
 
     CommandObjectFrameVariable (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "frame variable",
-                       "Show frame variables. All argument and local variables "
-                       "that are in scope will be shown when no arguments are given. "
-                       "If any arguments are specified, they can be names of "
-                       "argument, local, file static and file global variables. "
-                       "Children of aggregate variables can be specified such as "
-                       "'var->child.x'.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter,
+                             "frame variable",
+                             "Show frame variables. All argument and local variables "
+                             "that are in scope will be shown when no arguments are given. "
+                             "If any arguments are specified, they can be names of "
+                             "argument, local, file static and file global variables. "
+                             "Children of aggregate variables can be specified such as "
+                             "'var->child.x'.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_option_group (interpreter),
         m_option_variable(true), // Include the frame specific options by passing "true"
         m_option_format (eFormatDefault),
@@ -370,13 +372,9 @@
         return &m_option_group;
     }
 
-
+protected:
     virtual bool
-    Execute
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
         StackFrame *frame = exe_ctx.GetFramePtr();

Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Fri Jun  8 16:56:10 2012
@@ -26,10 +26,10 @@
 //-------------------------------------------------------------------------
 
 CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "help",
-                   "Show a list of all debugger commands, or give details about specific commands.",
-                   "help [<cmd-name>]"), m_options (interpreter)
+    CommandObjectParsed (interpreter,
+                         "help",
+                         "Show a list of all debugger commands, or give details about specific commands.",
+                         "help [<cmd-name>]"), m_options (interpreter)
 {
     CommandArgumentEntry arg;
     CommandArgumentData command_arg;
@@ -58,7 +58,7 @@
 };
 
 bool
-CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
+CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
 {
     CommandObject::CommandMap::iterator pos;
     CommandObject *cmd_obj;

Modified: lldb/trunk/source/Commands/CommandObjectHelp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.h (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.h Fri Jun  8 16:56:10 2012
@@ -23,7 +23,7 @@
 // CommandObjectHelp
 //-------------------------------------------------------------------------
 
-class CommandObjectHelp : public CommandObject
+class CommandObjectHelp : public CommandObjectParsed
 {
 public:
 
@@ -32,10 +32,6 @@
     virtual
     ~CommandObjectHelp ();
 
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
     virtual int
     HandleCompletion (Args &input,
                       int &cursor_index,
@@ -102,14 +98,20 @@
         bool m_show_user_defined;        
     };
     
-    CommandOptions m_options;
-    
     virtual Options *
     GetOptions ()
     {
         return &m_options;
     }
+    
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result);
 
+private:
+    CommandOptions m_options;
+    
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Fri Jun  8 16:56:10 2012
@@ -42,17 +42,17 @@
 using namespace lldb_private;
 
 
-class CommandObjectLogEnable : public CommandObject
+class CommandObjectLogEnable : public CommandObjectParsed
 {
 public:
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
     CommandObjectLogEnable(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "log enable",
-                       "Enable logging for a single log channel.",
-                        NULL),
+        CommandObjectParsed (interpreter,
+                             "log enable",
+                             "Enable logging for a single log channel.",
+                             NULL),
         m_options (interpreter)
     {
 
@@ -110,31 +110,6 @@
 //        return matches.GetSize();
 //    }
 //
-    virtual bool
-    Execute (Args& args,
-             CommandReturnObject &result)
-    {
-        if (args.GetArgumentCount() < 2)
-        {
-            result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
-        }
-        else
-        {
-            std::string channel(args.GetArgumentAtIndex(0));
-            args.Shift ();  // Shift off the channel
-            bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(), 
-                                                                  args.GetConstArgumentVector(), 
-                                                                  m_options.log_file.c_str(), 
-                                                                  m_options.log_options, 
-                                                                  result.GetErrorStream());
-            if (success)
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
-            else
-                result.SetStatus (eReturnStatusFailed);
-        }    
-        return result.Succeeded();
-    }
-
 
     class CommandOptions : public Options
     {
@@ -201,6 +176,31 @@
     };
 
 protected:
+    virtual bool
+    DoExecute (Args& args,
+             CommandReturnObject &result)
+    {
+        if (args.GetArgumentCount() < 2)
+        {
+            result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
+        }
+        else
+        {
+            std::string channel(args.GetArgumentAtIndex(0));
+            args.Shift ();  // Shift off the channel
+            bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(), 
+                                                                  args.GetConstArgumentVector(), 
+                                                                  m_options.log_file.c_str(), 
+                                                                  m_options.log_options, 
+                                                                  result.GetErrorStream());
+            if (success)
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            else
+                result.SetStatus (eReturnStatusFailed);
+        }    
+        return result.Succeeded();
+    }
+
     CommandOptions m_options;
 };
 
@@ -218,17 +218,17 @@
 { 0, false, NULL,                       0,  0,                 NULL, 0, eArgTypeNone,       NULL }
 };
 
-class CommandObjectLogDisable : public CommandObject
+class CommandObjectLogDisable : public CommandObjectParsed
 {
 public:
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
     CommandObjectLogDisable(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "log disable",
-                       "Disable one or more log channel categories.",
-                       NULL)
+        CommandObjectParsed (interpreter,
+                             "log disable",
+                             "Disable one or more log channel categories.",
+                             NULL)
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -257,8 +257,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         const size_t argc = args.GetArgumentCount();
@@ -297,17 +298,17 @@
     }
 };
 
-class CommandObjectLogList : public CommandObject
+class CommandObjectLogList : public CommandObjectParsed
 {
 public:
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
     CommandObjectLogList(CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "log list",
-                       "List the log categories for one or more log channels.  If none specified, lists them all.",
-                       NULL)
+        CommandObjectParsed (interpreter, 
+                             "log list",
+                             "List the log categories for one or more log channels.  If none specified, lists them all.",
+                             NULL)
     {
         CommandArgumentEntry arg;
         CommandArgumentData channel_arg;
@@ -328,8 +329,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         const size_t argc = args.GetArgumentCount();
@@ -372,17 +374,17 @@
     }
 };
 
-class CommandObjectLogTimer : public CommandObject
+class CommandObjectLogTimer : public CommandObjectParsed
 {
 public:
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
     CommandObjectLogTimer(CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "log timers",
-                       "Enable, disable, dump, and reset LLDB internal performance timers.",
-                       "log timers < enable <depth> | disable | dump | increment <bool> | reset >")
+        CommandObjectParsed (interpreter,
+                           "log timers",
+                           "Enable, disable, dump, and reset LLDB internal performance timers.",
+                           "log timers < enable <depth> | disable | dump | increment <bool> | reset >")
     {
     }
 
@@ -391,8 +393,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         const size_t argc = args.GetArgumentCount();

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Jun  8 16:56:10 2012
@@ -283,16 +283,16 @@
 //----------------------------------------------------------------------
 // Read memory from the inferior process
 //----------------------------------------------------------------------
-class CommandObjectMemoryRead : public CommandObject
+class CommandObjectMemoryRead : public CommandObjectParsed
 {
 public:
 
     CommandObjectMemoryRead (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "memory read",
-                       "Read from the memory of the process being debugged.",
-                       NULL,
-                       eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter,
+                             "memory read",
+                             "Read from the memory of the process being debugged.",
+                             NULL,
+                             eFlagProcessMustBePaused),
         m_option_group (interpreter),
         m_format_options (eFormatBytesWithASCII, 1, 8),
         m_memory_options (),
@@ -361,8 +361,9 @@
         return m_cmd_name.c_str();
     }
 
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
@@ -763,7 +764,6 @@
         return true;
     }
 
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupFormat m_format_options;
     OptionGroupReadMemory m_memory_options;
@@ -789,7 +789,7 @@
 //----------------------------------------------------------------------
 // Write memory to the inferior process
 //----------------------------------------------------------------------
-class CommandObjectMemoryWrite : public CommandObject
+class CommandObjectMemoryWrite : public CommandObjectParsed
 {
 public:
 
@@ -867,12 +867,11 @@
     };
 
     CommandObjectMemoryWrite (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "memory write",
-                       "Write to the memory of the process being debugged.",
-                       //"memory write [<cmd-options>] <addr> [value1 value2 ...]",
-                       NULL,
-                       eFlagProcessMustBeLaunched),
+        CommandObjectParsed (interpreter,
+                             "memory write",
+                             "Write to the memory of the process being debugged.",
+                             NULL,
+                             eFlagProcessMustBeLaunched),
         m_option_group (interpreter),
         m_format_options (eFormatBytes, 1, UINT64_MAX),
         m_memory_options ()
@@ -945,9 +944,9 @@
         return min <= sval64 && sval64 <= max;
     }
 
+protected:
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
         if (process == NULL)
@@ -1221,8 +1220,6 @@
         return true;
     }
 
-protected:
-    
     OptionGroupOptions m_option_group;
     OptionGroupFormat m_format_options;
     OptionGroupWriteMemory m_memory_options;

Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Jun  8 16:56:10 2012
@@ -107,12 +107,9 @@
 }
 
 bool
-CommandObjectMultiword::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+CommandObjectMultiword::Execute(const char *args_string, CommandReturnObject &result)
 {
+    Args args (args_string);
     const size_t argc = args.GetArgumentCount();
     if (argc == 0)
     {
@@ -139,7 +136,7 @@
 
                     args.Shift();
 
-                    sub_cmd_obj->ExecuteWithOptions (args, result);
+                    sub_cmd_obj->Execute (args_string, result);
                 }
                 else
                 {

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Fri Jun  8 16:56:10 2012
@@ -31,15 +31,15 @@
 //----------------------------------------------------------------------
 // "platform select <platform-name>"
 //----------------------------------------------------------------------
-class CommandObjectPlatformSelect : public CommandObject
+class CommandObjectPlatformSelect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform select",
-                       "Create a platform if needed and select it as the current platform.",
-                       "platform select <platform-name>",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform select",
+                             "Create a platform if needed and select it as the current platform.",
+                             "platform select <platform-name>",
+                             0),
         m_option_group (interpreter),
         m_platform_options (false) // Don't include the "--platform" option by passing false
     {
@@ -52,8 +52,37 @@
     {
     }
 
+    virtual int
+    HandleCompletion (Args &input,
+                      int &cursor_index,
+                      int &cursor_char_position,
+                      int match_start_point,
+                      int max_return_elements,
+                      bool &word_complete,
+                      StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::PlatformPluginNames (m_interpreter, 
+                                                 completion_str.c_str(),
+                                                 match_start_point,
+                                                 max_return_elements,
+                                                 NULL,
+                                                 word_complete,
+                                                 matches);
+        return matches.GetSize();
+    }
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         if (args.GetArgumentCount() == 1)
         {
@@ -89,37 +118,7 @@
         }
         return result.Succeeded();
     }
-    
-    
-    virtual int
-    HandleCompletion (Args &input,
-                      int &cursor_index,
-                      int &cursor_char_position,
-                      int match_start_point,
-                      int max_return_elements,
-                      bool &word_complete,
-                      StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::PlatformPluginNames (m_interpreter, 
-                                                 completion_str.c_str(),
-                                                 match_start_point,
-                                                 max_return_elements,
-                                                 NULL,
-                                                 word_complete,
-                                                 matches);
-        return matches.GetSize();
-    }
 
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupPlatform m_platform_options;
 };
@@ -127,15 +126,15 @@
 //----------------------------------------------------------------------
 // "platform list"
 //----------------------------------------------------------------------
-class CommandObjectPlatformList : public CommandObject
+class CommandObjectPlatformList : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "platform list",
-                       "List all platforms that are available.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "platform list",
+                             "List all platforms that are available.",
+                             NULL,
+                             0)
     {
     }
 
@@ -144,8 +143,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();
         ostrm.Printf("Available platforms:\n");
@@ -181,15 +181,15 @@
 //----------------------------------------------------------------------
 // "platform status"
 //----------------------------------------------------------------------
-class CommandObjectPlatformStatus : public CommandObject
+class CommandObjectPlatformStatus : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "platform status",
-                       "Display status for the currently selected platform.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "platform status",
+                             "Display status for the currently selected platform.",
+                             NULL,
+                             0)
     {
     }
 
@@ -198,8 +198,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();      
         
@@ -221,15 +222,15 @@
 //----------------------------------------------------------------------
 // "platform connect <connect-url>"
 //----------------------------------------------------------------------
-class CommandObjectPlatformConnect : public CommandObject
+class CommandObjectPlatformConnect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformConnect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform connect",
-                       "Connect a platform by name to be the currently selected platform.",
-                       "platform connect <connect-url>",
-                       0)
+        CommandObjectParsed (interpreter, 
+                             "platform connect",
+                             "Connect a platform by name to be the currently selected platform.",
+                             "platform connect <connect-url>",
+                             0)
     {
     }
 
@@ -238,8 +239,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();      
         
@@ -270,15 +272,15 @@
 //----------------------------------------------------------------------
 // "platform disconnect"
 //----------------------------------------------------------------------
-class CommandObjectPlatformDisconnect : public CommandObject
+class CommandObjectPlatformDisconnect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformDisconnect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform disconnect",
-                       "Disconnect a platform by name to be the currently selected platform.",
-                       "platform disconnect",
-                       0)
+        CommandObjectParsed (interpreter, 
+                             "platform disconnect",
+                             "Disconnect a platform by name to be the currently selected platform.",
+                             "platform disconnect",
+                             0)
     {
     }
 
@@ -287,8 +289,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
@@ -347,15 +350,15 @@
 //----------------------------------------------------------------------
 // "platform process launch"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessLaunch : public CommandObject
+class CommandObjectPlatformProcessLaunch : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform process launch",
-                       "Launch a new process on a remote platform.",
-                       "platform process launch program",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform process launch",
+                             "Launch a new process on a remote platform.",
+                             "platform process launch program",
+                             0),
         m_options (interpreter)
     {
     }
@@ -365,8 +368,15 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         
@@ -453,12 +463,6 @@
         return result.Succeeded();
     }
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
 protected:
     ProcessLaunchCommandOptions m_options;
 };
@@ -468,15 +472,15 @@
 //----------------------------------------------------------------------
 // "platform process list"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessList : public CommandObject
+class CommandObjectPlatformProcessList : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform process list",
-                       "List processes on a remote platform by name, pid, or many other matching attributes.",
-                       "platform process list",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform process list",
+                             "List processes on a remote platform by name, pid, or many other matching attributes.",
+                             "platform process list",
+                             0),
         m_options (interpreter)
     {
     }
@@ -486,8 +490,15 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         
@@ -581,14 +592,6 @@
         return result.Succeeded();
     }
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-protected:
-    
     class CommandOptions : public Options
     {
     public:
@@ -744,15 +747,15 @@
 //----------------------------------------------------------------------
 // "platform process info"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessInfo : public CommandObject
+class CommandObjectPlatformProcessInfo : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessInfo (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "platform process info",
-                   "Get detailed information for one or more process by process ID.",
-                   "platform process info <pid> [<pid> <pid> ...]",
-                   0)
+    CommandObjectParsed (interpreter, 
+                         "platform process info",
+                         "Get detailed information for one or more process by process ID.",
+                         "platform process info <pid> [<pid> <pid> ...]",
+                         0)
     {
         CommandArgumentEntry arg;
         CommandArgumentData pid_args;
@@ -773,8 +776,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
@@ -872,15 +876,15 @@
 };
 
 
-class CommandObjectPlatformShell : public CommandObject
+class CommandObjectPlatformShell : public CommandObjectRaw
 {
 public:
     CommandObjectPlatformShell (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "platform shell",
-                   "Run a shell command on a the selected platform.",
-                   "platform shell <shell-command>",
-                   0)
+        CommandObjectRaw (interpreter, 
+                         "platform shell",
+                         "Run a shell command on a the selected platform.",
+                         "platform shell <shell-command>",
+                         0)
     {
     }
     
@@ -889,18 +893,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    {
-        return false;
-    }
-    
-    virtual bool
-    WantsRawCommandString() { return true; }    
-
-    bool
-    ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result)
+    DoExecute (const char *raw_command_line, CommandReturnObject &result)
     {
         // TODO: Implement "Platform::RunShellCommand()" and switch over to using
         // the current platform when it is in the interface. 
@@ -936,8 +931,6 @@
         }
         return true;
     }
-
-protected:
 };
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Jun  8 16:56:10 2012
@@ -31,15 +31,15 @@
 // CommandObjectProcessLaunch
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessLaunch
-class CommandObjectProcessLaunch : public CommandObject
+class CommandObjectProcessLaunch : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process launch",
-                       "Launch the executable in the debugger.",
-                       NULL),
+        CommandObjectParsed (interpreter,
+                             "process launch",
+                             "Launch the executable in the debugger.",
+                             NULL),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -67,8 +67,15 @@
         return &m_options;
     }
 
+    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
+    {
+        // No repeat for "process launch"...
+        return "";
+    }
+
+protected:
     bool
-    Execute (Args& launch_args, CommandReturnObject &result)
+    DoExecute (Args& launch_args, CommandReturnObject &result)
     {
         Debugger &debugger = m_interpreter.GetDebugger();
         Target *target = debugger.GetSelectedTarget().get();
@@ -256,12 +263,6 @@
         return result.Succeeded();
     }
 
-    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
-    {
-        // No repeat for "process launch"...
-        return "";
-    }
-
 protected:
     ProcessLaunchCommandOptions m_options;
 };
@@ -293,7 +294,7 @@
 // CommandObjectProcessAttach
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessAttach
-class CommandObjectProcessAttach : public CommandObject
+class CommandObjectProcessAttach : public CommandObjectParsed
 {
 public:
 
@@ -432,10 +433,10 @@
     };
 
     CommandObjectProcessAttach (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process attach",
-                       "Attach to a process.",
-                       "process attach <cmd-options>"),
+        CommandObjectParsed (interpreter,
+                             "process attach",
+                             "Attach to a process.",
+                             "process attach <cmd-options>"),
         m_options (interpreter)
     {
     }
@@ -444,8 +445,15 @@
     {
     }
 
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -603,14 +611,6 @@
         return result.Succeeded();
     }
     
-    Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-
-protected:
-
     CommandOptions m_options;
 };
 
@@ -631,16 +631,16 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessContinue
 
-class CommandObjectProcessContinue : public CommandObject
+class CommandObjectProcessContinue : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessContinue (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process continue",
-                       "Continue execution of all threads in the current process.",
-                       "process continue",
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "process continue",
+                             "Continue execution of all threads in the current process.",
+                             "process continue",
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
     }
 
@@ -649,8 +649,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -719,16 +720,16 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessDetach
 
-class CommandObjectProcessDetach : public CommandObject
+class CommandObjectProcessDetach : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessDetach (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process detach",
-                       "Detach from the current process being debugged.",
-                       "process detach",
-                       eFlagProcessMustBeLaunched)
+        CommandObjectParsed (interpreter,
+                             "process detach",
+                             "Detach from the current process being debugged.",
+                             "process detach",
+                             eFlagProcessMustBeLaunched)
     {
     }
 
@@ -736,8 +737,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -769,7 +771,7 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessConnect
 
-class CommandObjectProcessConnect : public CommandObject
+class CommandObjectProcessConnect : public CommandObjectParsed
 {
 public:
     
@@ -829,11 +831,11 @@
     };
 
     CommandObjectProcessConnect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process connect",
-                       "Connect to a remote debug service.",
-                       "process connect <remote-url>",
-                       0),
+        CommandObjectParsed (interpreter,
+                             "process connect",
+                             "Connect to a remote debug service.",
+                             "process connect <remote-url>",
+                             0),
         m_options (interpreter)
     {
     }
@@ -843,8 +845,15 @@
     }
 
     
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         
@@ -919,14 +928,6 @@
         }
         return result.Succeeded();
     }
-
-    Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-protected:
     
     CommandOptions m_options;
 };
@@ -944,16 +945,16 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessLoad
 
-class CommandObjectProcessLoad : public CommandObject
+class CommandObjectProcessLoad : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessLoad (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process load",
-                       "Load a shared library into the current process.",
-                       "process load <filename> [<filename> ...]",
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "process load",
+                             "Load a shared library into the current process.",
+                             "process load <filename> [<filename> ...]",
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
     }
 
@@ -961,8 +962,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -1003,16 +1005,16 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessUnload
 
-class CommandObjectProcessUnload : public CommandObject
+class CommandObjectProcessUnload : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessUnload (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process unload",
-                       "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
-                       "process unload <index>",
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "process unload",
+                             "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
+                             "process unload <index>",
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
     }
 
@@ -1020,8 +1022,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -1069,15 +1072,15 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessSignal
 
-class CommandObjectProcessSignal : public CommandObject
+class CommandObjectProcessSignal : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessSignal (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process signal",
-                       "Send a UNIX signal to the current process being debugged.",
-                       NULL)
+        CommandObjectParsed (interpreter,
+                             "process signal",
+                             "Send a UNIX signal to the current process being debugged.",
+                             NULL)
     {
         CommandArgumentEntry arg;
         CommandArgumentData signal_arg;
@@ -1097,8 +1100,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -1154,17 +1158,17 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessInterrupt
 
-class CommandObjectProcessInterrupt : public CommandObject
+class CommandObjectProcessInterrupt : public CommandObjectParsed
 {
 public:
 
 
     CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "process interrupt",
-                   "Interrupt the current process being debugged.",
-                   "process interrupt",
-                   eFlagProcessMustBeLaunched)
+        CommandObjectParsed (interpreter,
+                             "process interrupt",
+                             "Interrupt the current process being debugged.",
+                             "process interrupt",
+                             eFlagProcessMustBeLaunched)
     {
     }
 
@@ -1172,8 +1176,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -1217,16 +1222,16 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessKill
 
-class CommandObjectProcessKill : public CommandObject
+class CommandObjectProcessKill : public CommandObjectParsed
 {
 public:
 
     CommandObjectProcessKill (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "process kill",
-                   "Terminate the current process being debugged.",
-                   "process kill",
-                   eFlagProcessMustBeLaunched)
+        CommandObjectParsed (interpreter, 
+                             "process kill",
+                             "Terminate the current process being debugged.",
+                             "process kill",
+                             eFlagProcessMustBeLaunched)
     {
     }
 
@@ -1234,8 +1239,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -1275,15 +1281,15 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessStatus
 
-class CommandObjectProcessStatus : public CommandObject
+class CommandObjectProcessStatus : public CommandObjectParsed
 {
 public:
     CommandObjectProcessStatus (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "process status",
-                   "Show the current status and location of executing process.",
-                   "process status",
-                   0)
+        CommandObjectParsed (interpreter, 
+                             "process status",
+                             "Show the current status and location of executing process.",
+                             "process status",
+                             0)
     {
     }
 
@@ -1293,11 +1299,7 @@
 
 
     bool
-    Execute
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1331,7 +1333,7 @@
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessHandle
 
-class CommandObjectProcessHandle : public CommandObject
+class CommandObjectProcessHandle : public CommandObjectParsed
 {
 public:
 
@@ -1400,10 +1402,10 @@
 
 
     CommandObjectProcessHandle (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "process handle",
-                       "Show or update what the process and debugger should do with various signals received from the OS.",
-                       NULL),
+        CommandObjectParsed (interpreter,
+                             "process handle",
+                             "Show or update what the process and debugger should do with various signals received from the OS.",
+                             NULL),
         m_options (interpreter)
     {
         SetHelpLong ("If no signals are specified, update them all.  If no update option is specified, list the current values.\n");
@@ -1503,8 +1505,9 @@
         }
     }
 
+protected:
     bool
-    Execute (Args &signal_args, CommandReturnObject &result)
+    DoExecute (Args &signal_args, CommandReturnObject &result)
     {
         TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
         
@@ -1618,8 +1621,6 @@
         return result.Succeeded();
     }
 
-protected:
-
     CommandOptions m_options;
 };
 

Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Fri Jun  8 16:56:10 2012
@@ -24,7 +24,7 @@
 //-------------------------------------------------------------------------
 
 CommandObjectQuit::CommandObjectQuit (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, "quit", "Quit out of the LLDB debugger.", "quit")
+    CommandObjectParsed (interpreter, "quit", "Quit out of the LLDB debugger.", "quit")
 {
 }
 
@@ -33,11 +33,7 @@
 }
 
 bool
-CommandObjectQuit::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+CommandObjectQuit::DoExecute (Args& command, CommandReturnObject &result)
 {
     m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived);
     result.SetStatus (eReturnStatusQuit);

Modified: lldb/trunk/source/Commands/CommandObjectQuit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectQuit.h (original)
+++ lldb/trunk/source/Commands/CommandObjectQuit.h Fri Jun  8 16:56:10 2012
@@ -22,7 +22,7 @@
 // CommandObjectQuit
 //-------------------------------------------------------------------------
 
-class CommandObjectQuit : public CommandObject
+class CommandObjectQuit : public CommandObjectParsed
 {
 public:
 
@@ -31,8 +31,9 @@
     virtual
     ~CommandObjectQuit ();
 
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result);
 
 };

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Jun  8 16:56:10 2012
@@ -34,16 +34,15 @@
 //----------------------------------------------------------------------
 // "register read"
 //----------------------------------------------------------------------
-class CommandObjectRegisterRead : public CommandObject
+class CommandObjectRegisterRead : public CommandObjectParsed
 {
 public:
     CommandObjectRegisterRead (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "register read",
-                       "Dump the contents of one or more register values from the current frame.  If no register is specified, dumps them all.",
-                       //"register read [<reg-name1> [<reg-name2> [...]]]",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter, 
+                             "register read",
+                             "Dump the contents of one or more register values from the current frame.  If no register is specified, dumps them all.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_option_group (interpreter),
         m_format_options (eFormatDefault),
         m_command_options ()
@@ -158,12 +157,9 @@
         return available_count > 0;
     }
 
+protected:
     virtual bool
-    Execute 
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Stream &strm = result.GetOutputStream();
         ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
@@ -359,15 +355,15 @@
 //----------------------------------------------------------------------
 // "register write"
 //----------------------------------------------------------------------
-class CommandObjectRegisterWrite : public CommandObject
+class CommandObjectRegisterWrite : public CommandObjectParsed
 {
 public:
     CommandObjectRegisterWrite (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "register write",
-                       "Modify a single register value.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "register write",
+                             "Modify a single register value.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -398,12 +394,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute 
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute(Args& command, CommandReturnObject &result)
     {
         DataExtractor reg_data;
         ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Fri Jun  8 16:56:10 2012
@@ -19,67 +19,52 @@
 
 using namespace lldb;
 using namespace lldb_private;
+#include "llvm/ADT/StringRef.h"
 
-//-------------------------------------------------------------------------
-// CommandObjectMultiwordSettings
-//-------------------------------------------------------------------------
-
-CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) :
-    CommandObjectMultiword (interpreter,
-                            "settings",
-                            "A set of commands for manipulating internal settable debugger variables.",
-                            "settings <command> [<command-options>]")
-{
-    LoadSubCommand ("set",           CommandObjectSP (new CommandObjectSettingsSet (interpreter)));
-    LoadSubCommand ("show",          CommandObjectSP (new CommandObjectSettingsShow (interpreter)));
-    LoadSubCommand ("list",          CommandObjectSP (new CommandObjectSettingsList (interpreter)));
-    LoadSubCommand ("remove",        CommandObjectSP (new CommandObjectSettingsRemove (interpreter)));
-    LoadSubCommand ("replace",       CommandObjectSP (new CommandObjectSettingsReplace (interpreter)));
-    LoadSubCommand ("insert-before", CommandObjectSP (new CommandObjectSettingsInsertBefore (interpreter)));
-    LoadSubCommand ("insert-after",  CommandObjectSP (new CommandObjectSettingsInsertAfter (interpreter)));
-    LoadSubCommand ("append",        CommandObjectSP (new CommandObjectSettingsAppend (interpreter)));
-    LoadSubCommand ("clear",         CommandObjectSP (new CommandObjectSettingsClear (interpreter)));
-}
-
-CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings ()
+static inline void StripLeadingSpaces(llvm::StringRef &Str)
 {
+    while (!Str.empty() && isspace(Str[0]))
+        Str = Str.substr(1);
 }
 
 //-------------------------------------------------------------------------
 // CommandObjectSettingsSet
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsSet::CommandObjectSettingsSet (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings set",
-                   "Set or change the value of a single debugger setting variable.",
-                   NULL),
-    m_options (interpreter)
+class CommandObjectSettingsSet : public CommandObjectRaw
 {
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData value_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first (and only) variant of this arg.
-    value_arg.arg_type = eArgTypeValue;
-    value_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg2.push_back (value_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-    
-    SetHelpLong (
+public:
+    CommandObjectSettingsSet (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "settings set",
+                          "Set or change the value of a single debugger setting variable.",
+                          NULL),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData value_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first (and only) variant of this arg.
+        value_arg.arg_type = eArgTypeValue;
+        value_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg2.push_back (value_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+        
+        SetHelpLong (
 "When setting a dictionary or array variable, you can set multiple entries \n\
 at once by giving the values to the set command.  For example: \n\
 \n\
@@ -101,528 +86,374 @@
 the end), use one of the other settings sub-commands: append, replace, \n\
 insert-before or insert-after.\n");
 
-}
-
-CommandObjectSettingsSet::~CommandObjectSettingsSet()
-{
-}
-
+    }
 
-#include "llvm/ADT/StringRef.h"
-static inline void StripLeadingSpaces(llvm::StringRef &Str)
-{
-    while (!Str.empty() && isspace(Str[0]))
-        Str = Str.substr(1);
-}
-bool
-CommandObjectSettingsSet::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    Args cmd_args(raw_command);
+    virtual
+    ~CommandObjectSettingsSet () {}
 
-    // Process possible options.
-    if (!ParseOptions (cmd_args, result))
-        return false;
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
 
-    const int argc = cmd_args.GetArgumentCount ();
-    if ((argc < 2) && (!m_options.m_reset))
+    virtual Options *
+    GetOptions ()
     {
-        result.AppendError ("'settings set' takes more arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return &m_options;
     }
-
-    const char *var_name = cmd_args.GetArgumentAtIndex (0);
-    if ((var_name == NULL) || (var_name[0] == '\0'))
+    
+    class CommandOptions : public Options
     {
-        result.AppendError ("'settings set' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+    public:
 
-    // Split the raw command into var_name and value pair.
-    std::string var_name_string = var_name;
-    llvm::StringRef raw_str(raw_command);
-    llvm::StringRef var_value_str = raw_str.split(var_name).second;
-    StripLeadingSpaces(var_value_str);
-    std::string var_value_string = var_value_str.str();
-
-    if (!m_options.m_reset
-        && var_value_string.empty())
-    {
-        result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;"
-                            " No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-      Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                       var_value_string.c_str(), 
-                                       eVarSetOperationAssign, 
-                                       m_options.m_override, 
-                                       m_interpreter.GetDebugger().GetInstanceName().AsCString());
-        if (err.Fail ())
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_override (true),
+            m_reset (false)
         {
-            result.AppendError (err.AsCString());
-            result.SetStatus (eReturnStatusFailed);
         }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
 
-    return result.Succeeded();
-}
+        virtual
+        ~CommandOptions () {}
 
-int
-CommandObjectSettingsSet::HandleArgumentCompletion (Args &input,
-                                                    int &cursor_index,
-                                                    int &cursor_char_position,
-                                                    OptionElementVector &opt_element_vector,
-                                                    int match_start_point,
-                                                    int max_return_elements,
-                                                    bool &word_complete,
-                                                    StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
 
-    // Attempting to complete variable name
-    llvm::StringRef prev_str(cursor_index == 2 ? input.GetArgumentAtIndex(1) : "");
-    if (cursor_index == 1 ||
-        (cursor_index == 2 && prev_str.startswith("-")) // "settings set -r th", followed by Tab.
-        )
-    {
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        // If there is only 1 match which fulfills the completion request, do an early return.
-        if (matches.GetSize() == 1 && completion_str.compare(matches.GetStringAtIndex(0)) != 0)
-            return 1;
-    }
-
-    // Attempting to complete value
-    if ((cursor_index == 2)   // Partly into the variable's value
-        || (cursor_index == 1  // Or at the end of a completed valid variable name
-            && matches.GetSize() == 1
-            && completion_str.compare (matches.GetStringAtIndex(0)) == 0))
-    {
-        matches.Clear();
-        UserSettingsControllerSP usc_sp = Debugger::GetSettingsController();
-        if (cursor_index == 1)
-        {
-            // The user is at the end of the variable name, which is complete and valid.
-            UserSettingsController::CompleteSettingsValue (usc_sp,
-                                                           input.GetArgumentAtIndex (1), // variable name
-                                                           NULL,                         // empty value string
-                                                           word_complete,
-                                                           matches);
+            switch (short_option)
+            {
+                case 'n':
+                    m_override = false;
+                    break;
+                case 'r':
+                    m_reset = true;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized options '%c'", short_option);
+                    break;
+            }
+
+            return error;
         }
-        else
+
+        void
+        OptionParsingStarting ()
         {
-            // The user is partly into the variable value.
-            UserSettingsController::CompleteSettingsValue (usc_sp,
-                                                           input.GetArgumentAtIndex (1),  // variable name
-                                                           completion_str.c_str(),        // partial value string
-                                                           word_complete,
-                                                           matches);
+            m_override = true;
+            m_reset = false;
+        }
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
         }
-    }
 
-    return matches.GetSize();
-}
+        // Options table: Required for subclasses of Options.
 
-//-------------------------------------------------------------------------
-// CommandObjectSettingsSet::CommandOptions
-//-------------------------------------------------------------------------
+        static OptionDefinition g_option_table[];
 
-CommandObjectSettingsSet::CommandOptions::CommandOptions (CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_override (true),
-    m_reset (false)
-{
-}
+        // Instance variables to hold the values for command options.
 
-CommandObjectSettingsSet::CommandOptions::~CommandOptions ()
-{
-}
+        bool m_override;
+        bool m_reset;
 
-OptionDefinition
-CommandObjectSettingsSet::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, eArgTypeNone, "Prevents already existing instances and pending settings from being assigned this new value.  Using this option means that only the default or specified instance setting values will be updated." },
-    { LLDB_OPT_SET_2, false, "reset", 'r', no_argument,   NULL, NULL, eArgTypeNone, "Causes value to be reset to the original default for this variable.  No value needs to be specified when this option is used." },
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
-};
-
-const OptionDefinition*
-CommandObjectSettingsSet::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
+    };
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        llvm::StringRef prev_str(cursor_index == 2 ? input.GetArgumentAtIndex(1) : "");
+        if (cursor_index == 1 ||
+            (cursor_index == 2 && prev_str.startswith("-")) // "settings set -r th", followed by Tab.
+            )
+        {
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
+            // If there is only 1 match which fulfills the completion request, do an early return.
+            if (matches.GetSize() == 1 && completion_str.compare(matches.GetStringAtIndex(0)) != 0)
+                return 1;
+        }
 
-Error
-CommandObjectSettingsSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+        // Attempting to complete value
+        if ((cursor_index == 2)   // Partly into the variable's value
+            || (cursor_index == 1  // Or at the end of a completed valid variable name
+                && matches.GetSize() == 1
+                && completion_str.compare (matches.GetStringAtIndex(0)) == 0))
+        {
+            matches.Clear();
+            UserSettingsControllerSP usc_sp = Debugger::GetSettingsController();
+            if (cursor_index == 1)
+            {
+                // The user is at the end of the variable name, which is complete and valid.
+                UserSettingsController::CompleteSettingsValue (usc_sp,
+                                                               input.GetArgumentAtIndex (1), // variable name
+                                                               NULL,                         // empty value string
+                                                               word_complete,
+                                                               matches);
+            }
+            else
+            {
+                // The user is partly into the variable value.
+                UserSettingsController::CompleteSettingsValue (usc_sp,
+                                                               input.GetArgumentAtIndex (1),  // variable name
+                                                               completion_str.c_str(),        // partial value string
+                                                               word_complete,
+                                                               matches);
+            }
+        }
 
-    switch (short_option)
-    {
-        case 'n':
-            m_override = false;
-            break;
-        case 'r':
-            m_reset = true;
-            break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized options '%c'", short_option);
-            break;
+        return matches.GetSize();
     }
+    
+protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result)
+    {
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    return error;
-}
-
-void
-CommandObjectSettingsSet::CommandOptions::OptionParsingStarting ()
-{
-    m_override = true;
-    m_reset = false;
-}
-
-Options *
-CommandObjectSettingsSet::GetOptions ()
-{
-    return &m_options;
-}
-
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsShow -- Show current values
-//-------------------------------------------------------------------------
-
-CommandObjectSettingsShow::CommandObjectSettingsShow (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings show",
-                   "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.",
-                   NULL)
-{
-    CommandArgumentEntry arg1;
-    CommandArgumentData var_name_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatOptional;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-}
-
-CommandObjectSettingsShow::~CommandObjectSettingsShow()
-{
-}
-
-
-bool
-CommandObjectSettingsShow::Execute (Args& command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-    const char *current_prefix = usc_sp->GetLevelName().GetCString();
+        Args cmd_args(command);
 
-    Error err;
+        // Process possible options.
+        if (!ParseOptions (cmd_args, result))
+            return false;
 
-    if (command.GetArgumentCount())
-    {
-        // The user requested to see the value of a particular variable.
-        SettableVariableType var_type;
-        const char *variable_name = command.GetArgumentAtIndex (0);
-        StringList value = usc_sp->GetVariable (variable_name, 
-                                                var_type,
-                                                m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                                err);
-        
-        if (err.Fail ())
+        const int argc = cmd_args.GetArgumentCount ();
+        if ((argc < 2) && (!m_options.m_reset))
         {
-            result.AppendError (err.AsCString());
+            result.AppendError ("'settings set' takes more arguments");
             result.SetStatus (eReturnStatusFailed);
-              
+            return false;
         }
-        else
+
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
+        if ((var_name == NULL) || (var_name[0] == '\0'))
         {
-            UserSettingsController::DumpValue(m_interpreter, usc_sp, variable_name, result.GetOutputStream());
-            result.SetStatus (eReturnStatusSuccessFinishResult);
+            result.AppendError ("'settings set' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-    }
-    else
-    {
-        UserSettingsController::GetAllVariableValues (m_interpreter, 
-                                                      usc_sp, 
-                                                      current_prefix, 
-                                                      result.GetOutputStream(), 
-                                                      err);
-        if (err.Fail ())
+
+        // Split the raw command into var_name and value pair.
+        std::string var_name_string = var_name;
+        llvm::StringRef raw_str(command);
+        llvm::StringRef var_value_str = raw_str.split(var_name).second;
+        StripLeadingSpaces(var_value_str);
+        std::string var_value_string = var_value_str.str();
+
+        if (!m_options.m_reset
+            && var_value_string.empty())
         {
-            result.AppendError (err.AsCString());
+            result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;"
+                                " No value supplied");
             result.SetStatus (eReturnStatusFailed);
         }
         else
         {
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+          Error err = usc_sp->SetVariable (var_name_string.c_str(), 
+                                           var_value_string.c_str(), 
+                                           eVarSetOperationAssign, 
+                                           m_options.m_override, 
+                                           m_interpreter.GetDebugger().GetInstanceName().AsCString());
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
-    }
 
-    return result.Succeeded();
-}
+        return result.Succeeded();
+    }
+private:
+    CommandOptions m_options;
+};
 
-int
-CommandObjectSettingsShow::HandleArgumentCompletion (Args &input,
-                                                     int &cursor_index,
-                                                     int &cursor_char_position,
-                                                     OptionElementVector &opt_element_vector,
-                                                     int match_start_point,
-                                                     int max_return_elements,
-                                                     bool &word_complete,
-                                                     StringList &matches)
+OptionDefinition
+CommandObjectSettingsSet::CommandOptions::g_option_table[] =
 {
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+    { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, eArgTypeNone, "Prevents already existing instances and pending settings from being assigned this new value.  Using this option means that only the default or specified instance setting values will be updated." },
+    { LLDB_OPT_SET_2, false, "reset", 'r', no_argument,   NULL, NULL, eArgTypeNone, "Causes value to be reset to the original default for this variable.  No value needs to be specified when this option is used." },
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
 
-    CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                         CommandCompletions::eSettingsNameCompletion,
-                                                         completion_str.c_str(),
-                                                         match_start_point,
-                                                         max_return_elements,
-                                                         NULL,
-                                                         word_complete,
-                                                         matches);
-    return matches.GetSize();
-}
 
 //-------------------------------------------------------------------------
-// CommandObjectSettingsList
+// CommandObjectSettingsShow -- Show current values
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsList::CommandObjectSettingsList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "settings list",
-                   "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).",
-                   NULL)
+class CommandObjectSettingsShow : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData prefix_name_arg;
-
-    // Define the first variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatOptional;
-
-    // Define the second variant of this arg.
-    prefix_name_arg.arg_type = eArgTypeSettingPrefix;
-    prefix_name_arg.arg_repetition = eArgRepeatOptional;
-
-    arg.push_back (var_name_arg);
-    arg.push_back (prefix_name_arg);
+public:
+    CommandObjectSettingsShow (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "settings show",
+                             "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.",
+                             NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentData var_name_arg;
 
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatOptional;
 
-CommandObjectSettingsList::~CommandObjectSettingsList()
-{
-}
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
 
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+    }
 
-bool
-CommandObjectSettingsList::Execute (Args& command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-    const char *current_prefix = usc_sp->GetLevelName().GetCString();
+    virtual
+    ~CommandObjectSettingsShow () {}
 
-    Error err;
 
-    if (command.GetArgumentCount() == 0)
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
     {
-        UserSettingsController::FindAllSettingsDescriptions (m_interpreter, 
-                                                             usc_sp, 
-                                                             current_prefix, 
-                                                             result.GetOutputStream(), 
-                                                             err);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                             CommandCompletions::eSettingsNameCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
     }
-    else if (command.GetArgumentCount() == 1)
+
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        const char *search_name = command.GetArgumentAtIndex (0);
-        UserSettingsController::FindSettingsDescriptions (m_interpreter, 
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        const char *current_prefix = usc_sp->GetLevelName().GetCString();
+
+        Error err;
+
+        if (command.GetArgumentCount())
+        {
+            // The user requested to see the value of a particular variable.
+            SettableVariableType var_type;
+            const char *variable_name = command.GetArgumentAtIndex (0);
+            StringList value = usc_sp->GetVariable (variable_name, 
+                                                    var_type,
+                                                    m_interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                                    err);
+            
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+                  
+            }
+            else
+            {
+                UserSettingsController::DumpValue(m_interpreter, usc_sp, variable_name, result.GetOutputStream());
+                result.SetStatus (eReturnStatusSuccessFinishResult);
+            }
+        }
+        else
+        {
+            UserSettingsController::GetAllVariableValues (m_interpreter, 
                                                           usc_sp, 
-                                                          current_prefix,
-                                                          search_name, 
+                                                          current_prefix, 
                                                           result.GetOutputStream(), 
                                                           err);
-    }
-    else
-    {
-        result.AppendError ("Too many aguments for 'settings list' command.\n");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+            {
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            }
+        }
 
-    if (err.Fail ())
-    {
-        result.AppendError (err.AsCString());
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        return result.Succeeded();
     }
-
-    return result.Succeeded();
-}
-
-int
-CommandObjectSettingsList::HandleArgumentCompletion (Args &input,
-                                                     int &cursor_index,
-                                                     int &cursor_char_position,
-                                                     OptionElementVector &opt_element_vector,
-                                                     int match_start_point,
-                                                     int max_return_elements,
-                                                     bool &word_complete,
-                                                     StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
-
-    CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                         CommandCompletions::eSettingsNameCompletion,
-                                                         completion_str.c_str(),
-                                                         match_start_point,
-                                                         max_return_elements,
-                                                         NULL,
-                                                         word_complete,
-                                                         matches);
-    return matches.GetSize();
-}
+};
 
 //-------------------------------------------------------------------------
-// CommandObjectSettingsRemove
+// CommandObjectSettingsList -- List settable variables
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsRemove::CommandObjectSettingsRemove (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "settings remove",
-                   "Remove the specified element from an internal debugger settings array or dictionary variable.",
-                   NULL)
+class CommandObjectSettingsList : public CommandObjectParsed
 {
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData index_arg;
-    CommandArgumentData key_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first variant of this arg.
-    index_arg.arg_type = eArgTypeSettingIndex;
-    index_arg.arg_repetition = eArgRepeatPlain;
-
-    // Define the second variant of this arg.
-    key_arg.arg_type = eArgTypeSettingKey;
-    key_arg.arg_repetition = eArgRepeatPlain;
-
-    // Push both variants into this arg
-    arg2.push_back (index_arg);
-    arg2.push_back (key_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-}
-
-CommandObjectSettingsRemove::~CommandObjectSettingsRemove ()
-{
-}
-
-bool
-CommandObjectSettingsRemove::Execute (Args& command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
-    const int argc = command.GetArgumentCount ();
-
-    if (argc != 2)
-    {
-        result.AppendError ("'settings remove' takes two arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
-
-    const char *var_name = command.GetArgumentAtIndex (0);
-    std::string var_name_string;
-    if ((var_name == NULL) || (var_name[0] == '\0'))
+public: 
+    CommandObjectSettingsList (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "settings list",
+                             "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).",
+                             NULL)
     {
-        result.AppendError ("'settings remove' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        CommandArgumentEntry arg;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData prefix_name_arg;
 
-    var_name_string = var_name;
-    command.Shift();
+        // Define the first variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatOptional;
 
-    const char *index_value = command.GetArgumentAtIndex (0);
-    std::string index_value_string;
-    if ((index_value == NULL) || (index_value[0] == '\0'))
-    {
-        result.AppendError ("'settings remove' command requires an index or key value; no value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        // Define the second variant of this arg.
+        prefix_name_arg.arg_type = eArgTypeSettingPrefix;
+        prefix_name_arg.arg_repetition = eArgRepeatOptional;
 
-    index_value_string = index_value;
+        arg.push_back (var_name_arg);
+        arg.push_back (prefix_name_arg);
 
-    Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                     NULL, 
-                                     eVarSetOperationRemove,  
-                                     true, 
-                                     m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                     index_value_string.c_str());
-    if (err.Fail ())
-    {
-        result.AppendError (err.AsCString());
-        result.SetStatus (eReturnStatusFailed);
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
     }
-    else
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
-    return result.Succeeded();
-}
+    virtual
+    ~CommandObjectSettingsList () {}
 
-int
-CommandObjectSettingsRemove::HandleArgumentCompletion (Args &input,
-                                                       int &cursor_index,
-                                                       int &cursor_char_position,
-                                                       OptionElementVector &opt_element_vector,
-                                                       int match_start_point,
-                                                       int max_return_elements,
-                                                       bool &word_complete,
-                                                       StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
         CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
                                                              CommandCompletions::eSettingsNameCompletion,
                                                              completion_str.c_str(),
@@ -631,119 +462,171 @@
                                                              NULL,
                                                              word_complete,
                                                              matches);
+        return matches.GetSize();
+    }
 
-    return matches.GetSize();
-}
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
+    {
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        const char *current_prefix = usc_sp->GetLevelName().GetCString();
 
-//-------------------------------------------------------------------------
-// CommandObjectSettingsReplace
-//-------------------------------------------------------------------------
+        Error err;
 
-CommandObjectSettingsReplace::CommandObjectSettingsReplace (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings replace",
-                   "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.",
-                   NULL)
-{
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentEntry arg3;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData index_arg;
-    CommandArgumentData key_arg;
-    CommandArgumentData value_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first (variant of this arg.
-    index_arg.arg_type = eArgTypeSettingIndex;
-    index_arg.arg_repetition = eArgRepeatPlain;
-
-    // Define the second (variant of this arg.
-    key_arg.arg_type = eArgTypeSettingKey;
-    key_arg.arg_repetition = eArgRepeatPlain;
-
-    // Put both variants into this arg
-    arg2.push_back (index_arg);
-    arg2.push_back (key_arg);
-
-    // Define the first (and only) variant of this arg.
-    value_arg.arg_type = eArgTypeValue;
-    value_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg3.push_back (value_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-    m_arguments.push_back (arg3);
-}
+        if (command.GetArgumentCount() == 0)
+        {
+            UserSettingsController::FindAllSettingsDescriptions (m_interpreter, 
+                                                                 usc_sp, 
+                                                                 current_prefix, 
+                                                                 result.GetOutputStream(), 
+                                                                 err);
+        }
+        else if (command.GetArgumentCount() == 1)
+        {
+            const char *search_name = command.GetArgumentAtIndex (0);
+            UserSettingsController::FindSettingsDescriptions (m_interpreter, 
+                                                              usc_sp, 
+                                                              current_prefix,
+                                                              search_name, 
+                                                              result.GetOutputStream(), 
+                                                              err);
+        }
+        else
+        {
+            result.AppendError ("Too many aguments for 'settings list' command.\n");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-CommandObjectSettingsReplace::~CommandObjectSettingsReplace ()
-{
-}
+        if (err.Fail ())
+        {
+            result.AppendError (err.AsCString());
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-bool
-CommandObjectSettingsReplace::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        return result.Succeeded();
+    }
+};
 
-    Args cmd_args(raw_command);
-    const int argc = cmd_args.GetArgumentCount ();
+//-------------------------------------------------------------------------
+// CommandObjectSettingsRemove
+//-------------------------------------------------------------------------
 
-    if (argc < 3)
+class CommandObjectSettingsRemove : public CommandObjectParsed
+{
+public:
+    CommandObjectSettingsRemove (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "settings remove",
+                             "Remove the specified element from an internal debugger settings array or dictionary variable.",
+                             NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData index_arg;
+        CommandArgumentData key_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first variant of this arg.
+        index_arg.arg_type = eArgTypeSettingIndex;
+        index_arg.arg_repetition = eArgRepeatPlain;
+
+        // Define the second variant of this arg.
+        key_arg.arg_type = eArgTypeSettingKey;
+        key_arg.arg_repetition = eArgRepeatPlain;
+
+        // Push both variants into this arg
+        arg2.push_back (index_arg);
+        arg2.push_back (key_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+    }
+
+    virtual
+    ~CommandObjectSettingsRemove () {}
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
+
+        return matches.GetSize();
+    }
+
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("'settings replace' takes more arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    const char *var_name = cmd_args.GetArgumentAtIndex (0);
-    std::string var_name_string;
-    if ((var_name == NULL) || (var_name[0] == '\0'))
-    {
-        result.AppendError ("'settings replace' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        const int argc = command.GetArgumentCount ();
 
-    var_name_string = var_name;
-    cmd_args.Shift();
+        if (argc != 2)
+        {
+            result.AppendError ("'settings remove' takes two arguments");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    const char *index_value = cmd_args.GetArgumentAtIndex (0);
-    std::string index_value_string;
-    if ((index_value == NULL) || (index_value[0] == '\0'))
-    {
-        result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        const char *var_name = command.GetArgumentAtIndex (0);
+        std::string var_name_string;
+        if ((var_name == NULL) || (var_name[0] == '\0'))
+        {
+            result.AppendError ("'settings remove' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    index_value_string = index_value;
-    cmd_args.Shift();
+        var_name_string = var_name;
+        command.Shift();
 
-    // Split the raw command into var_name, index_value, and value triple.
-    llvm::StringRef raw_str(raw_command);
-    llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-    StripLeadingSpaces(var_value_str);
-    std::string var_value_string = var_value_str.str();
+        const char *index_value = command.GetArgumentAtIndex (0);
+        std::string index_value_string;
+        if ((index_value == NULL) || (index_value[0] == '\0'))
+        {
+            result.AppendError ("'settings remove' command requires an index or key value; no value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+
+        index_value_string = index_value;
 
-    if (var_value_string.empty())
-    {
-        result.AppendError ("'settings replace' command requires a valid variable value; no value supplied");
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
         Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                         var_value_string.c_str(), 
-                                         eVarSetOperationReplace, 
+                                         NULL, 
+                                         eVarSetOperationRemove,  
                                          true, 
                                          m_interpreter.GetDebugger().GetInstanceName().AsCString(),
                                          index_value_string.c_str());
@@ -754,548 +637,730 @@
         }
         else
             result.SetStatus (eReturnStatusSuccessFinishNoResult);
+
+        return result.Succeeded();
     }
+};
 
-    return result.Succeeded();
-}
+//-------------------------------------------------------------------------
+// CommandObjectSettingsReplace
+//-------------------------------------------------------------------------
 
-int
-CommandObjectSettingsReplace::HandleArgumentCompletion (Args &input,
-                                                        int &cursor_index,
-                                                        int &cursor_char_position,
-                                                        OptionElementVector &opt_element_vector,
-                                                        int match_start_point,
-                                                        int max_return_elements,
-                                                        bool &word_complete,
-                                                        StringList &matches)
+class CommandObjectSettingsReplace : public CommandObjectRaw
 {
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+public:
+    CommandObjectSettingsReplace (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "settings replace",
+                          "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.",
+                          NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentEntry arg3;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData index_arg;
+        CommandArgumentData key_arg;
+        CommandArgumentData value_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first (variant of this arg.
+        index_arg.arg_type = eArgTypeSettingIndex;
+        index_arg.arg_repetition = eArgRepeatPlain;
+
+        // Define the second (variant of this arg.
+        key_arg.arg_type = eArgTypeSettingKey;
+        key_arg.arg_repetition = eArgRepeatPlain;
+
+        // Put both variants into this arg
+        arg2.push_back (index_arg);
+        arg2.push_back (key_arg);
+
+        // Define the first (and only) variant of this arg.
+        value_arg.arg_type = eArgTypeValue;
+        value_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg3.push_back (value_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+        m_arguments.push_back (arg3);
+    }
+
+
+    virtual
+    ~CommandObjectSettingsReplace () {}
+
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
+
+        return matches.GetSize();
+    }
+
+protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result)
+    {
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
+        Args cmd_args(command);
+        const int argc = cmd_args.GetArgumentCount ();
 
-    return matches.GetSize();
-}
+        if (argc < 3)
+        {
+            result.AppendError ("'settings replace' takes more arguments");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-//-------------------------------------------------------------------------
-// CommandObjectSettingsInsertBefore
-//-------------------------------------------------------------------------
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
+        std::string var_name_string;
+        if ((var_name == NULL) || (var_name[0] == '\0'))
+        {
+            result.AppendError ("'settings replace' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings insert-before",
-                   "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.",
-                   NULL)
-{
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentEntry arg3;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData index_arg;
-    CommandArgumentData value_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first (variant of this arg.
-    index_arg.arg_type = eArgTypeSettingIndex;
-    index_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg2.push_back (index_arg);
-
-    // Define the first (and only) variant of this arg.
-    value_arg.arg_type = eArgTypeValue;
-    value_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg3.push_back (value_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-    m_arguments.push_back (arg3);
-}
+        var_name_string = var_name;
+        cmd_args.Shift();
 
-CommandObjectSettingsInsertBefore::~CommandObjectSettingsInsertBefore ()
-{
-}
+        const char *index_value = cmd_args.GetArgumentAtIndex (0);
+        std::string index_value_string;
+        if ((index_value == NULL) || (index_value[0] == '\0'))
+        {
+            result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-bool
-CommandObjectSettingsInsertBefore::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        index_value_string = index_value;
+        cmd_args.Shift();
 
-    Args cmd_args(raw_command);
-    const int argc = cmd_args.GetArgumentCount ();
+        // Split the raw command into var_name, index_value, and value triple.
+        llvm::StringRef raw_str(command);
+        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
+        StripLeadingSpaces(var_value_str);
+        std::string var_value_string = var_value_str.str();
 
-    if (argc < 3)
-    {
-        result.AppendError ("'settings insert-before' takes more arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        if (var_value_string.empty())
+        {
+            result.AppendError ("'settings replace' command requires a valid variable value; no value supplied");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
+                                             var_value_string.c_str(), 
+                                             eVarSetOperationReplace, 
+                                             true, 
+                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                             index_value_string.c_str());
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-    const char *var_name = cmd_args.GetArgumentAtIndex (0);
-    std::string var_name_string;
-    if ((var_name == NULL) || (var_name[0] == '\0'))
-    {
-        result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return result.Succeeded();
     }
+};
 
-    var_name_string = var_name;
-    cmd_args.Shift();
+//-------------------------------------------------------------------------
+// CommandObjectSettingsInsertBefore
+//-------------------------------------------------------------------------
 
-    const char *index_value = cmd_args.GetArgumentAtIndex (0);
-    std::string index_value_string;
-    if ((index_value == NULL) || (index_value[0] == '\0'))
+class CommandObjectSettingsInsertBefore : public CommandObjectRaw
+{
+public:
+    CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "settings insert-before",
+                          "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.",
+                          NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentEntry arg3;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData index_arg;
+        CommandArgumentData value_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first (variant of this arg.
+        index_arg.arg_type = eArgTypeSettingIndex;
+        index_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg2.push_back (index_arg);
+
+        // Define the first (and only) variant of this arg.
+        value_arg.arg_type = eArgTypeValue;
+        value_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg3.push_back (value_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+        m_arguments.push_back (arg3);
+    }
+
+    virtual
+    ~CommandObjectSettingsInsertBefore () {}
+
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
+
+        return matches.GetSize();
+    }
+
+protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result)
     {
-        result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    index_value_string = index_value;
-    cmd_args.Shift();
+        Args cmd_args(command);
+        const int argc = cmd_args.GetArgumentCount ();
 
-    // Split the raw command into var_name, index_value, and value triple.
-    llvm::StringRef raw_str(raw_command);
-    llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-    StripLeadingSpaces(var_value_str);
-    std::string var_value_string = var_value_str.str();
+        if (argc < 3)
+        {
+            result.AppendError ("'settings insert-before' takes more arguments");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    if (var_value_string.empty())
-    {
-        result.AppendError ("'settings insert-before' command requires a valid variable value;"
-                            " No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-        Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                         var_value_string.c_str(), 
-                                         eVarSetOperationInsertBefore,
-                                         true, 
-                                         m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                         index_value_string.c_str());
-        if (err.Fail ())
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
+        std::string var_name_string;
+        if ((var_name == NULL) || (var_name[0] == '\0'))
         {
-            result.AppendError (err.AsCString());
+            result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied");
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
 
-    return result.Succeeded();
-}
+        var_name_string = var_name;
+        cmd_args.Shift();
 
+        const char *index_value = cmd_args.GetArgumentAtIndex (0);
+        std::string index_value_string;
+        if ((index_value == NULL) || (index_value[0] == '\0'))
+        {
+            result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-int
-CommandObjectSettingsInsertBefore::HandleArgumentCompletion (Args &input,
-                                                             int &cursor_index,
-                                                             int &cursor_char_position,
-                                                             OptionElementVector &opt_element_vector,
-                                                             int match_start_point,
-                                                             int max_return_elements,
-                                                             bool &word_complete,
-                                                             StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+        index_value_string = index_value;
+        cmd_args.Shift();
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
+        // Split the raw command into var_name, index_value, and value triple.
+        llvm::StringRef raw_str(command);
+        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
+        StripLeadingSpaces(var_value_str);
+        std::string var_value_string = var_value_str.str();
 
-    return matches.GetSize();
-}
+        if (var_value_string.empty())
+        {
+            result.AppendError ("'settings insert-before' command requires a valid variable value;"
+                                " No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
+                                             var_value_string.c_str(), 
+                                             eVarSetOperationInsertBefore,
+                                             true, 
+                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                             index_value_string.c_str());
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+
+        return result.Succeeded();
+    }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectSettingInsertAfter
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings insert-after",
-                   "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.",
-                   NULL)
-{
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentEntry arg3;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData index_arg;
-    CommandArgumentData value_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first (variant of this arg.
-    index_arg.arg_type = eArgTypeSettingIndex;
-    index_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg2.push_back (index_arg);
-
-    // Define the first (and only) variant of this arg.
-    value_arg.arg_type = eArgTypeValue;
-    value_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg3.push_back (value_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-    m_arguments.push_back (arg3);
-}
-
-CommandObjectSettingsInsertAfter::~CommandObjectSettingsInsertAfter ()
-{
-}
-
-bool
-CommandObjectSettingsInsertAfter::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
+class CommandObjectSettingsInsertAfter : public CommandObjectRaw
 {
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+public:
+    CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "settings insert-after",
+                          "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.",
+                          NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentEntry arg3;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData index_arg;
+        CommandArgumentData value_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first (variant of this arg.
+        index_arg.arg_type = eArgTypeSettingIndex;
+        index_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg2.push_back (index_arg);
+
+        // Define the first (and only) variant of this arg.
+        value_arg.arg_type = eArgTypeValue;
+        value_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg3.push_back (value_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+        m_arguments.push_back (arg3);
+    }
+
+    virtual
+    ~CommandObjectSettingsInsertAfter () {}
+
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
 
-    Args cmd_args(raw_command);
-    const int argc = cmd_args.GetArgumentCount ();
-
-    if (argc < 3)
-    {
-        result.AppendError ("'settings insert-after' takes more arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return matches.GetSize();
     }
-
-    const char *var_name = cmd_args.GetArgumentAtIndex (0);
-    std::string var_name_string;
-    if ((var_name == NULL) || (var_name[0] == '\0'))
+    
+protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result)
     {
-        result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    var_name_string = var_name;
-    cmd_args.Shift();
+        Args cmd_args(command);
+        const int argc = cmd_args.GetArgumentCount ();
 
-    const char *index_value = cmd_args.GetArgumentAtIndex (0);
-    std::string index_value_string;
-    if ((index_value == NULL) || (index_value[0] == '\0'))
-    {
-        result.AppendError ("'settings insert-after' command requires an index value; no value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        if (argc < 3)
+        {
+            result.AppendError ("'settings insert-after' takes more arguments");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    index_value_string = index_value;
-    cmd_args.Shift();
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
+        std::string var_name_string;
+        if ((var_name == NULL) || (var_name[0] == '\0'))
+        {
+            result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    // Split the raw command into var_name, index_value, and value triple.
-    llvm::StringRef raw_str(raw_command);
-    llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-    StripLeadingSpaces(var_value_str);
-    std::string var_value_string = var_value_str.str();
+        var_name_string = var_name;
+        cmd_args.Shift();
 
-    if (var_value_string.empty())
-    {
-        result.AppendError ("'settings insert-after' command requires a valid variable value;"
-                            " No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-        Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                         var_value_string.c_str(), 
-                                         eVarSetOperationInsertAfter,
-                                         true, 
-                                         m_interpreter.GetDebugger().GetInstanceName().AsCString(), 
-                                         index_value_string.c_str());
-        if (err.Fail ())
+        const char *index_value = cmd_args.GetArgumentAtIndex (0);
+        std::string index_value_string;
+        if ((index_value == NULL) || (index_value[0] == '\0'))
         {
-            result.AppendError (err.AsCString());
+            result.AppendError ("'settings insert-after' command requires an index value; no value supplied");
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-
-    return result.Succeeded();
-}
 
+        index_value_string = index_value;
+        cmd_args.Shift();
 
-int
-CommandObjectSettingsInsertAfter::HandleArgumentCompletion (Args &input,
-                                                            int &cursor_index,
-                                                            int &cursor_char_position,
-                                                            OptionElementVector &opt_element_vector,
-                                                            int match_start_point,
-                                                            int max_return_elements,
-                                                            bool &word_complete,
-                                                            StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+        // Split the raw command into var_name, index_value, and value triple.
+        llvm::StringRef raw_str(command);
+        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
+        StripLeadingSpaces(var_value_str);
+        std::string var_value_string = var_value_str.str();
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
+        if (var_value_string.empty())
+        {
+            result.AppendError ("'settings insert-after' command requires a valid variable value;"
+                                " No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
+                                             var_value_string.c_str(), 
+                                             eVarSetOperationInsertAfter,
+                                             true, 
+                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(), 
+                                             index_value_string.c_str());
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-    return matches.GetSize();
-}
+        return result.Succeeded();
+    }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectSettingsAppend
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsAppend::CommandObjectSettingsAppend (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "settings append",
-                   "Append a new value to the end of an internal debugger settings array, dictionary or string variable.",
-                   NULL)
-{
-    CommandArgumentEntry arg1;
-    CommandArgumentEntry arg2;
-    CommandArgumentData var_name_arg;
-    CommandArgumentData value_arg;
-
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg1.push_back (var_name_arg);
-
-    // Define the first (and only) variant of this arg.
-    value_arg.arg_type = eArgTypeValue;
-    value_arg.arg_repetition = eArgRepeatPlain;
-
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg2.push_back (value_arg);
-
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg1);
-    m_arguments.push_back (arg2);
-}
-
-CommandObjectSettingsAppend::~CommandObjectSettingsAppend ()
+class CommandObjectSettingsAppend : public CommandObjectRaw
 {
-}
-
-bool
-CommandObjectSettingsAppend::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
-    Args cmd_args(raw_command);
-    const int argc = cmd_args.GetArgumentCount ();
-
-    if (argc < 2)
+public:
+    CommandObjectSettingsAppend (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "settings append",
+                          "Append a new value to the end of an internal debugger settings array, dictionary or string variable.",
+                          NULL)
+    {
+        CommandArgumentEntry arg1;
+        CommandArgumentEntry arg2;
+        CommandArgumentData var_name_arg;
+        CommandArgumentData value_arg;
+
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg1.push_back (var_name_arg);
+
+        // Define the first (and only) variant of this arg.
+        value_arg.arg_type = eArgTypeValue;
+        value_arg.arg_repetition = eArgRepeatPlain;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg2.push_back (value_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg1);
+        m_arguments.push_back (arg2);
+    }
+
+    virtual
+    ~CommandObjectSettingsAppend () {}
+
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
+
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
+
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
+
+        return matches.GetSize();
+    }
+
+protected:
+    virtual bool
+    DoExecute (const char *command, CommandReturnObject &result)
     {
-        result.AppendError ("'settings append' takes more arguments");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    const char *var_name = cmd_args.GetArgumentAtIndex (0);
-    std::string var_name_string;
-    if ((var_name == NULL) || (var_name[0] == '\0'))
-    {
-        result.AppendError ("'settings append' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        Args cmd_args(command);
+        const int argc = cmd_args.GetArgumentCount ();
 
-    var_name_string = var_name;
-    // Do not perform cmd_args.Shift() since StringRef is manipulating the
-    // raw character string later on.
-
-    // Split the raw command into var_name and value pair.
-    llvm::StringRef raw_str(raw_command);
-    llvm::StringRef var_value_str = raw_str.split(var_name).second;
-    StripLeadingSpaces(var_value_str);
-    std::string var_value_string = var_value_str.str();
-
-    if (var_value_string.empty())
-    {
-        result.AppendError ("'settings append' command requires a valid variable value;"
-                            " No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-        Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                         var_value_string.c_str(), 
-                                         eVarSetOperationAppend, 
-                                         true, 
-                                         m_interpreter.GetDebugger().GetInstanceName().AsCString());
-        if (err.Fail ())
+        if (argc < 2)
         {
-            result.AppendError (err.AsCString());
+            result.AppendError ("'settings append' takes more arguments");
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-
-    return result.Succeeded();
-}
 
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
+        std::string var_name_string;
+        if ((var_name == NULL) || (var_name[0] == '\0'))
+        {
+            result.AppendError ("'settings append' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-int
-CommandObjectSettingsAppend::HandleArgumentCompletion (Args &input,
-                                                       int &cursor_index,
-                                                       int &cursor_char_position,
-                                                       OptionElementVector &opt_element_vector,
-                                                       int match_start_point,
-                                                       int max_return_elements,
-                                                       bool &word_complete,
-                                                       StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+        var_name_string = var_name;
+        // Do not perform cmd_args.Shift() since StringRef is manipulating the
+        // raw character string later on.
+
+        // Split the raw command into var_name and value pair.
+        llvm::StringRef raw_str(command);
+        llvm::StringRef var_value_str = raw_str.split(var_name).second;
+        StripLeadingSpaces(var_value_str);
+        std::string var_value_string = var_value_str.str();
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
+        if (var_value_string.empty())
+        {
+            result.AppendError ("'settings append' command requires a valid variable value;"
+                                " No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
+                                             var_value_string.c_str(), 
+                                             eVarSetOperationAppend, 
+                                             true, 
+                                             m_interpreter.GetDebugger().GetInstanceName().AsCString());
+            if (err.Fail ())
+            {
+                result.AppendError (err.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-    return matches.GetSize();
-}
+        return result.Succeeded();
+    }
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectSettingsClear
 //-------------------------------------------------------------------------
 
-CommandObjectSettingsClear::CommandObjectSettingsClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "settings clear",
-                   "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.",
-                   NULL)
+class CommandObjectSettingsClear : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandArgumentData var_name_arg;
+public:
+    CommandObjectSettingsClear (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "settings clear",
+                             "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.",
+                             NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData var_name_arg;
 
-    // Define the first (and only) variant of this arg.
-    var_name_arg.arg_type = eArgTypeSettingVariableName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
+        // Define the first (and only) variant of this arg.
+        var_name_arg.arg_type = eArgTypeSettingVariableName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
 
-    // There is only one variant this argument could be; put it into the argument entry.
-    arg.push_back (var_name_arg);
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (var_name_arg);
 
-    // Push the data for the first argument into the m_arguments vector.
-    m_arguments.push_back (arg);
-}
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+    }
 
-CommandObjectSettingsClear::~CommandObjectSettingsClear ()
-{
-}
+    virtual
+    ~CommandObjectSettingsClear () {}
 
-bool
-CommandObjectSettingsClear::Execute (Args& command, CommandReturnObject &result)
-{
-    UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
+        completion_str.erase (cursor_char_position);
 
-    const int argc = command.GetArgumentCount ();
+        // Attempting to complete variable name
+        if (cursor_index < 2)
+            CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                 CommandCompletions::eSettingsNameCompletion,
+                                                                 completion_str.c_str(),
+                                                                 match_start_point,
+                                                                 max_return_elements,
+                                                                 NULL,
+                                                                 word_complete,
+                                                                 matches);
 
-    if (argc != 1)
-    {
-        result.AppendError ("'setttings clear' takes exactly one argument");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return matches.GetSize();
     }
 
-    const char *var_name = command.GetArgumentAtIndex (0);
-    if ((var_name == NULL) || (var_name[0] == '\0'))
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        result.AppendError ("'settings clear' command requires a valid variable name; No value supplied");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
 
-    Error err = usc_sp->SetVariable (var_name, 
-                                     NULL, 
-                                     eVarSetOperationClear, 
-                                     false, 
-                                     m_interpreter.GetDebugger().GetInstanceName().AsCString());
+        const int argc = command.GetArgumentCount ();
 
-    if (err.Fail ())
-    {
-        result.AppendError (err.AsCString());
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        if (argc != 1)
+        {
+            result.AppendError ("'setttings clear' takes exactly one argument");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    return result.Succeeded();
-}
+        const char *var_name = command.GetArgumentAtIndex (0);
+        if ((var_name == NULL) || (var_name[0] == '\0'))
+        {
+            result.AppendError ("'settings clear' command requires a valid variable name; No value supplied");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
+        Error err = usc_sp->SetVariable (var_name, 
+                                         NULL, 
+                                         eVarSetOperationClear, 
+                                         false, 
+                                         m_interpreter.GetDebugger().GetInstanceName().AsCString());
 
-int
-CommandObjectSettingsClear::HandleArgumentCompletion (Args &input,
-                                                      int &cursor_index,
-                                                      int &cursor_char_position,
-                                                      OptionElementVector &opt_element_vector,
-                                                      int match_start_point,
-                                                      int max_return_elements,
-                                                      bool &word_complete,
-                                                      StringList &matches)
-{
-    std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-    completion_str.erase (cursor_char_position);
+        if (err.Fail ())
+        {
+            result.AppendError (err.AsCString());
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
-    // Attempting to complete variable name
-    if (cursor_index < 2)
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                             CommandCompletions::eSettingsNameCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
+        return result.Succeeded();
+    }
+};
 
-    return matches.GetSize();
+//-------------------------------------------------------------------------
+// CommandObjectMultiwordSettings
+//-------------------------------------------------------------------------
+
+CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) :
+    CommandObjectMultiword (interpreter,
+                            "settings",
+                            "A set of commands for manipulating internal settable debugger variables.",
+                            "settings <command> [<command-options>]")
+{
+    LoadSubCommand ("set",           CommandObjectSP (new CommandObjectSettingsSet (interpreter)));
+    LoadSubCommand ("show",          CommandObjectSP (new CommandObjectSettingsShow (interpreter)));
+    LoadSubCommand ("list",          CommandObjectSP (new CommandObjectSettingsList (interpreter)));
+    LoadSubCommand ("remove",        CommandObjectSP (new CommandObjectSettingsRemove (interpreter)));
+    LoadSubCommand ("replace",       CommandObjectSP (new CommandObjectSettingsReplace (interpreter)));
+    LoadSubCommand ("insert-before", CommandObjectSP (new CommandObjectSettingsInsertBefore (interpreter)));
+    LoadSubCommand ("insert-after",  CommandObjectSP (new CommandObjectSettingsInsertAfter (interpreter)));
+    LoadSubCommand ("append",        CommandObjectSP (new CommandObjectSettingsAppend (interpreter)));
+    LoadSubCommand ("clear",         CommandObjectSP (new CommandObjectSettingsClear (interpreter)));
+}
+
+CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings ()
+{
 }

Modified: lldb/trunk/source/Commands/CommandObjectSettings.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.h Fri Jun  8 16:56:10 2012
@@ -36,361 +36,6 @@
 
 };
 
-//-------------------------------------------------------------------------
-// CommandObjectSettingsSet
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsSet : public CommandObject
-{
-public:
-    CommandObjectSettingsSet (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsSet ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        bool m_override;
-        bool m_reset;
-
-    };
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsShow -- Show current values
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsShow : public CommandObject
-{
-public:
-    CommandObjectSettingsShow (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsShow ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsList -- List settable variables
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsList : public CommandObject
-{
-public: 
-    CommandObjectSettingsList (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsList ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsRemove
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsRemove : public CommandObject
-{
-public:
-    CommandObjectSettingsRemove (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsRemove ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsReplace
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsReplace : public CommandObject
-{
-public:
-    CommandObjectSettingsReplace (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsReplace ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsInsertBefore
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsInsertBefore : public CommandObject
-{
-public:
-    CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsInsertBefore ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingInsertAfter
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsInsertAfter : public CommandObject
-{
-public:
-    CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsInsertAfter ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsAppend
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsAppend : public CommandObject
-{
-public:
-    CommandObjectSettingsAppend (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsAppend ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectSettingsClear
-//-------------------------------------------------------------------------
-
-class CommandObjectSettingsClear : public CommandObject
-{
-public:
-    CommandObjectSettingsClear (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectSettingsClear ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches);
-
-private:
-};
-
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectSettings_h_

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Fri Jun  8 16:56:10 2012
@@ -32,7 +32,7 @@
 // CommandObjectSourceInfo
 //-------------------------------------------------------------------------
 
-class CommandObjectSourceInfo : public CommandObject
+class CommandObjectSourceInfo : public CommandObjectParsed
 {
 
     class CommandOptions : public Options
@@ -96,10 +96,10 @@
  
 public:   
     CommandObjectSourceInfo(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "source info",
-                       "Display information about the source lines from the current executable's debug info.",
-                       "source info [<cmd-options>]"),
+        CommandObjectParsed (interpreter,
+                             "source info",
+                             "Display information about the source lines from the current executable's debug info.",
+                             "source info [<cmd-options>]"),
         m_options (interpreter)
     {
     }
@@ -115,19 +115,15 @@
         return &m_options;
     }
 
-
+protected:
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         result.AppendError ("Not yet implemented");
         result.SetStatus (eReturnStatusFailed);
         return false;
     }
-protected:
+
     CommandOptions m_options;
 };
 
@@ -144,7 +140,7 @@
 // CommandObjectSourceList
 //-------------------------------------------------------------------------
 
-class CommandObjectSourceList : public CommandObject
+class CommandObjectSourceList : public CommandObjectParsed
 {
 
     class CommandOptions : public Options
@@ -232,10 +228,10 @@
  
 public:   
     CommandObjectSourceList(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "source list",
-                       "Display source code (as specified) based on the current executable's debug info.",
-                        NULL),
+        CommandObjectParsed (interpreter,
+                             "source list",
+                             "Display source code (as specified) based on the current executable's debug info.",
+                             NULL),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -263,15 +259,17 @@
         return &m_options;
     }
 
+    virtual const char *
+    GetRepeatCommand (Args &current_command_args, uint32_t index)
+    {
+        return m_cmd_name.c_str();
+    }
 
+protected:
     bool
-    Execute
-    (
-        Args& args,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        const int argc = args.GetArgumentCount();
+        const int argc = command.GetArgumentCount();
 
         if (argc != 0)
         {
@@ -601,12 +599,6 @@
         return result.Succeeded();
     }
     
-    virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
-    {
-        return m_cmd_name.c_str();
-    }
-
-protected:
     const SymbolContextList *
     GetBreakpointLocations ()
     {

Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Fri Jun  8 16:56:10 2012
@@ -28,10 +28,10 @@
 //-------------------------------------------------------------------------
 
 CommandObjectSyntax::CommandObjectSyntax (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "syntax",
-                   "Shows the correct syntax for a given debugger command.",
-                   "syntax <command>")
+    CommandObjectParsed (interpreter,
+                         "syntax",
+                         "Shows the correct syntax for a given debugger command.",
+                         "syntax <command>")
 {
     CommandArgumentEntry arg;
     CommandArgumentData command_arg;
@@ -53,11 +53,7 @@
 
 
 bool
-CommandObjectSyntax::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
+CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result)
 {
     CommandObject::CommandMap::iterator pos;
     CommandObject *cmd_obj;

Modified: lldb/trunk/source/Commands/CommandObjectSyntax.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSyntax.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSyntax.h Fri Jun  8 16:56:10 2012
@@ -22,7 +22,7 @@
 // CommandObjectSyntax
 //-------------------------------------------------------------------------
 
-class CommandObjectSyntax : public CommandObject
+class CommandObjectSyntax : public CommandObjectParsed
 {
 public:
 
@@ -31,8 +31,9 @@
     virtual
     ~CommandObjectSyntax ();
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result);
 
 

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Jun  8 16:56:10 2012
@@ -138,14 +138,14 @@
 // "target create"
 //-------------------------------------------------------------------------
 
-class CommandObjectTargetCreate : public CommandObject
+class CommandObjectTargetCreate : public CommandObjectParsed
 {
 public:
     CommandObjectTargetCreate(CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target create",
-                       "Create a target using the argument as the main executable.",
-                       NULL),
+        CommandObjectParsed (interpreter,
+                             "target create",
+                             "Create a target using the argument as the main executable.",
+                             NULL),
         m_option_group (interpreter),
         m_arch_option (),
         m_platform_options(true), // Do include the "--platform" option in the platform settings by passing true
@@ -180,8 +180,33 @@
         return &m_option_group;
     }
 
+    int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
+                                                             CommandCompletions::eDiskFileCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
+    }
+
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const int argc = command.GetArgumentCount();
         FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
@@ -272,29 +297,6 @@
         
     }
 
-    int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
-                                                             CommandCompletions::eDiskFileCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        return matches.GetSize();
-    }
 private:
     OptionGroupOptions m_option_group;
     OptionGroupArchitecture m_arch_option;
@@ -309,15 +311,15 @@
 // "target list"
 //----------------------------------------------------------------------
 
-class CommandObjectTargetList : public CommandObject
+class CommandObjectTargetList : public CommandObjectParsed
 {
 public:
     CommandObjectTargetList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target list",
-                       "List all current targets in the current debug session.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "target list",
+                             "List all current targets in the current debug session.",
+                             NULL,
+                             0)
     {
     }
     
@@ -326,8 +328,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         if (args.GetArgumentCount() == 0)
         {
@@ -356,15 +359,15 @@
 // "target select"
 //----------------------------------------------------------------------
 
-class CommandObjectTargetSelect : public CommandObject
+class CommandObjectTargetSelect : public CommandObjectParsed
 {
 public:
     CommandObjectTargetSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target select",
-                       "Select a target as the current target by target index.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "target select",
+                             "Select a target as the current target by target index.",
+                             NULL,
+                             0)
     {
     }
     
@@ -373,8 +376,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         if (args.GetArgumentCount() == 1)
         {
@@ -431,15 +435,15 @@
 // "target delete"
 //----------------------------------------------------------------------
 
-class CommandObjectTargetDelete : public CommandObject
+class CommandObjectTargetDelete : public CommandObjectParsed
 {
 public:
     CommandObjectTargetDelete (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target delete",
-                       "Delete one or more targets by target index.",
-                       NULL,
-                       0),
+        CommandObjectParsed (interpreter,
+                             "target delete",
+                             "Delete one or more targets by target index.",
+                             NULL,
+                             0),
         m_option_group (interpreter),
         m_cleanup_option (LLDB_OPT_SET_1, false, "clean", 'c', 0, eArgTypeNone, "Perform extra cleanup to minimize memory consumption after deleting the target.", false)
     {
@@ -452,8 +456,15 @@
     {
     }
     
+    Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         const size_t argc = args.GetArgumentCount();
         std::vector<TargetSP> delete_target_list;
@@ -530,13 +541,6 @@
         return result.Succeeded();
     }
     
-    Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupBoolean m_cleanup_option;
 };
@@ -548,15 +552,15 @@
 // "target variable"
 //----------------------------------------------------------------------
 
-class CommandObjectTargetVariable : public CommandObject
+class CommandObjectTargetVariable : public CommandObjectParsed
 {
 public:
     CommandObjectTargetVariable (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target variable",
-                       "Read global variable(s) prior to running your binary.",
-                       NULL,
-                       0),
+        CommandObjectParsed (interpreter,
+                             "target variable",
+                             "Read global variable(s) prior to running your binary.",
+                             NULL,
+                             0),
         m_option_group (interpreter),
         m_option_variable (false), // Don't include frame options
         m_option_format (eFormatDefault),
@@ -670,8 +674,15 @@
     
 
 
+    Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
         Target *target = exe_ctx.GetTargetPtr();
@@ -811,13 +822,6 @@
         return result.Succeeded();
     }
     
-    Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-    
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupVariable m_option_variable;
     OptionGroupFormat m_option_format;
@@ -830,15 +834,15 @@
 
 #pragma mark CommandObjectTargetModulesSearchPathsAdd
 
-class CommandObjectTargetModulesSearchPathsAdd : public CommandObject
+class CommandObjectTargetModulesSearchPathsAdd : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetModulesSearchPathsAdd (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target modules search-paths add",
-                       "Add new image search paths substitution pairs to the current target.",
-                       NULL)
+        CommandObjectParsed (interpreter,
+                             "target modules search-paths add",
+                             "Add new image search paths substitution pairs to the current target.",
+                             NULL)
     {
         CommandArgumentEntry arg;
         CommandArgumentData old_prefix_arg;
@@ -866,8 +870,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -916,15 +921,15 @@
 
 #pragma mark CommandObjectTargetModulesSearchPathsClear
 
-class CommandObjectTargetModulesSearchPathsClear : public CommandObject
+class CommandObjectTargetModulesSearchPathsClear : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetModulesSearchPathsClear (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target modules search-paths clear",
-                       "Clear all current image search path substitution pairs from the current target.",
-                       "target modules search-paths clear")
+        CommandObjectParsed (interpreter,
+                             "target modules search-paths clear",
+                             "Clear all current image search path substitution pairs from the current target.",
+                             "target modules search-paths clear")
     {
     }
 
@@ -932,8 +937,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -954,15 +960,15 @@
 
 #pragma mark CommandObjectTargetModulesSearchPathsInsert
 
-class CommandObjectTargetModulesSearchPathsInsert : public CommandObject
+class CommandObjectTargetModulesSearchPathsInsert : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetModulesSearchPathsInsert (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target modules search-paths insert",
-                       "Insert a new image search path substitution pair into the current target at the specified index.",
-                       NULL)
+        CommandObjectParsed (interpreter,
+                             "target modules search-paths insert",
+                             "Insert a new image search path substitution pair into the current target at the specified index.",
+                             NULL)
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -1001,8 +1007,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -1073,15 +1080,15 @@
 #pragma mark CommandObjectTargetModulesSearchPathsList
 
 
-class CommandObjectTargetModulesSearchPathsList : public CommandObject
+class CommandObjectTargetModulesSearchPathsList : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetModulesSearchPathsList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target modules search-paths list",
-                       "List all current image search path substitution pairs in the current target.",
-                       "target modules search-paths list")
+        CommandObjectParsed (interpreter,
+                             "target modules search-paths list",
+                             "List all current image search path substitution pairs in the current target.",
+                             "target modules search-paths list")
     {
     }
 
@@ -1089,8 +1096,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -1117,15 +1125,15 @@
 
 #pragma mark CommandObjectTargetModulesSearchPathsQuery
 
-class CommandObjectTargetModulesSearchPathsQuery : public CommandObject
+class CommandObjectTargetModulesSearchPathsQuery : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetModulesSearchPathsQuery (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "target modules search-paths query",
-                   "Transform a path using the first applicable image search path.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "target modules search-paths query",
+                             "Transform a path using the first applicable image search path.",
+                             NULL)
     {
         CommandArgumentEntry arg;
         CommandArgumentData path_arg;
@@ -1145,8 +1153,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -1772,7 +1781,7 @@
 // paths
 //----------------------------------------------------------------------
 
-class CommandObjectTargetModulesModuleAutoComplete : public CommandObject
+class CommandObjectTargetModulesModuleAutoComplete : public CommandObjectParsed
 {
 public:
     
@@ -1780,7 +1789,7 @@
                                       const char *name,
                                       const char *help,
                                       const char *syntax) :
-    CommandObject (interpreter, name, help, syntax)
+        CommandObjectParsed (interpreter, name, help, syntax)
     {
         CommandArgumentEntry arg;
         CommandArgumentData file_arg;
@@ -1834,7 +1843,7 @@
 // file paths
 //----------------------------------------------------------------------
 
-class CommandObjectTargetModulesSourceFileAutoComplete : public CommandObject
+class CommandObjectTargetModulesSourceFileAutoComplete : public CommandObjectParsed
 {
 public:
     
@@ -1842,7 +1851,7 @@
                                           const char *name,
                                           const char *help,
                                           const char *syntax) :
-    CommandObject (interpreter, name, help, syntax)
+        CommandObjectParsed (interpreter, name, help, syntax)
     {
         CommandArgumentEntry arg;
         CommandArgumentData source_file_arg;
@@ -1910,8 +1919,71 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+        Options(interpreter),
+        m_sort_order (eSortOrderNone)
+        {
+        }
+        
+        virtual
+        ~CommandOptions ()
+        {
+        }
+        
+        virtual Error
+        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 's':
+                    m_sort_order = (SortOrder) Args::StringToOptionEnum (option_arg, 
+                                                                         g_option_table[option_idx].enum_values, 
+                                                                         eSortOrderNone,
+                                                                         error);
+                    break;
+                    
+                default:
+                    error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+                    break;
+                    
+            }
+            return error;
+        }
+        
+        void
+        OptionParsingStarting ()
+        {
+            m_sort_order = eSortOrderNone;
+        }
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        
+        // Options table: Required for subclasses of Options.
+        static OptionDefinition g_option_table[];
+        
+        SortOrder m_sort_order;
+    };
+    
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -1999,69 +2071,6 @@
         return result.Succeeded();
     }
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-    class CommandOptions : public Options
-    {
-    public:
-        
-        CommandOptions (CommandInterpreter &interpreter) :
-        Options(interpreter),
-        m_sort_order (eSortOrderNone)
-        {
-        }
-        
-        virtual
-        ~CommandOptions ()
-        {
-        }
-        
-        virtual Error
-        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 's':
-                    m_sort_order = (SortOrder) Args::StringToOptionEnum (option_arg, 
-                                                                         g_option_table[option_idx].enum_values, 
-                                                                         eSortOrderNone,
-                                                                         error);
-                    break;
-                    
-                default:
-                    error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
-                    break;
-                    
-            }
-            return error;
-        }
-        
-        void
-        OptionParsingStarting ()
-        {
-            m_sort_order = eSortOrderNone;
-        }
-        
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-        
-        // Options table: Required for subclasses of Options.
-        static OptionDefinition g_option_table[];
-        
-        SortOrder m_sort_order;
-    };
-    
-protected:
     
     CommandOptions m_options;
 };
@@ -2106,8 +2115,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2211,8 +2221,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2312,8 +2323,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2412,14 +2424,14 @@
     }
 };
 
-class CommandObjectTargetModulesAdd : public CommandObject
+class CommandObjectTargetModulesAdd : public CommandObjectParsed
 {
 public:
     CommandObjectTargetModulesAdd (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "target modules add",
-                   "Add a new module to the current target's modules.",
-                   "target modules add [<module>]")
+        CommandObjectParsed (interpreter,
+                             "target modules add",
+                             "Add a new module to the current target's modules.",
+                             "target modules add [<module>]")
     {
     }
     
@@ -2428,8 +2440,33 @@
     {
     }
     
+    int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
+                                                             CommandCompletions::eDiskFileCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
+    }
+
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2490,30 +2527,6 @@
         return result.Succeeded();
     }
 
-    int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
-                                                             CommandCompletions::eDiskFileCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        return matches.GetSize();
-    }
-
 };
 
 class CommandObjectTargetModulesLoad : public CommandObjectTargetModulesModuleAutoComplete
@@ -2539,8 +2552,15 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2733,13 +2753,6 @@
         return result.Succeeded();
     }    
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-    
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupUUID m_uuid_option_group;
     OptionGroupFile m_file_option;
@@ -2749,7 +2762,7 @@
 //----------------------------------------------------------------------
 // List images with associated information
 //----------------------------------------------------------------------
-class CommandObjectTargetModulesList : public CommandObject
+class CommandObjectTargetModulesList : public CommandObjectParsed
 {
 public:
     
@@ -2825,10 +2838,10 @@
     };
     
     CommandObjectTargetModulesList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "target modules list",
-                   "List current executable and dependent shared library images.",
-                   "target modules list [<cmd-options>]"),
+        CommandObjectParsed (interpreter,
+                             "target modules list",
+                             "List current executable and dependent shared library images.",
+                             "target modules list [<cmd-options>]"),
         m_options (interpreter)
     {
     }
@@ -2845,8 +2858,9 @@
         return &m_options;
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -2993,7 +3007,6 @@
         }
         return result.Succeeded();
     }
-protected:
 
     void
     PrintModule (Target *target, Module *module, uint32_t idx, int indent, Stream &strm)
@@ -3183,7 +3196,7 @@
 //----------------------------------------------------------------------
 // Lookup information in images
 //----------------------------------------------------------------------
-class CommandObjectTargetModulesLookup : public CommandObject
+class CommandObjectTargetModulesLookup : public CommandObjectParsed
 {
 public:
     
@@ -3328,11 +3341,11 @@
     };
     
     CommandObjectTargetModulesLookup (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "target modules lookup",
-                   "Look up information within executable and dependent shared library images.",
-                   NULL),
-    m_options (interpreter)
+        CommandObjectParsed (interpreter,
+                             "target modules lookup",
+                             "Look up information within executable and dependent shared library images.",
+                             NULL),
+        m_options (interpreter)
     {
         CommandArgumentEntry arg;
         CommandArgumentData file_arg;
@@ -3511,8 +3524,9 @@
         return false;
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
+    DoExecute (Args& command,
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -3611,7 +3625,6 @@
         }
         return result.Succeeded();
     }
-protected:
     
     CommandOptions m_options;
 };
@@ -3709,14 +3722,14 @@
 
 
 
-class CommandObjectTargetSymbolsAdd : public CommandObject
+class CommandObjectTargetSymbolsAdd : public CommandObjectParsed
 {
 public:
     CommandObjectTargetSymbolsAdd (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "target symbols add",
-                   "Add a debug symbol file to one of the target's current modules.",
-                   "target symbols add [<symfile>]")
+        CommandObjectParsed (interpreter,
+                             "target symbols add",
+                             "Add a debug symbol file to one of the target's current modules.",
+                             "target symbols add [<symfile>]")
     {
     }
     
@@ -3725,8 +3738,33 @@
     {
     }
     
+    int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
+                                                             CommandCompletions::eDiskFileCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result)
     {
         ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
@@ -3817,30 +3855,6 @@
         return result.Succeeded();
     }
     
-    int
-    HandleArgumentCompletion (Args &input,
-                              int &cursor_index,
-                              int &cursor_char_position,
-                              OptionElementVector &opt_element_vector,
-                              int match_start_point,
-                              int max_return_elements,
-                              bool &word_complete,
-                              StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, 
-                                                             CommandCompletions::eDiskFileCompletion,
-                                                             completion_str.c_str(),
-                                                             match_start_point,
-                                                             max_return_elements,
-                                                             NULL,
-                                                             word_complete,
-                                                             matches);
-        return matches.GetSize();
-    }
-    
 };
 
 
@@ -3884,7 +3898,7 @@
 // CommandObjectTargetStopHookAdd
 //-------------------------------------------------------------------------
 
-class CommandObjectTargetStopHookAdd : public CommandObject
+class CommandObjectTargetStopHookAdd : public CommandObjectParsed
 {
 public:
 
@@ -4050,10 +4064,10 @@
     }
 
     CommandObjectTargetStopHookAdd (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target stop-hook add ",
-                       "Add a hook to be executed when the target stops.",
-                       "target stop-hook add"),
+        CommandObjectParsed (interpreter,
+                             "target stop-hook add ",
+                             "Add a hook to be executed when the target stops.",
+                             "target stop-hook add"),
         m_options (interpreter)
     {
     }
@@ -4149,9 +4163,9 @@
         return bytes_len;
     }
 
+protected:
     bool
-    Execute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (target)
@@ -4304,15 +4318,15 @@
 // CommandObjectTargetStopHookDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTargetStopHookDelete : public CommandObject
+class CommandObjectTargetStopHookDelete : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetStopHookDelete (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target stop-hook delete",
-                       "Delete a stop-hook.",
-                       "target stop-hook delete [<idx>]")
+        CommandObjectParsed (interpreter,
+                             "target stop-hook delete",
+                             "Delete a stop-hook.",
+                             "target stop-hook delete [<idx>]")
     {
     }
 
@@ -4320,9 +4334,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (target)
@@ -4379,15 +4393,15 @@
 // CommandObjectTargetStopHookEnableDisable
 //-------------------------------------------------------------------------
 
-class CommandObjectTargetStopHookEnableDisable : public CommandObject
+class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetStopHookEnableDisable (CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax) :
-        CommandObject (interpreter,
-                       name,
-                       help,
-                       syntax),
+        CommandObjectParsed (interpreter,
+                             name,
+                             help,
+                             syntax),
         m_enable (enable)
     {
     }
@@ -4396,9 +4410,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (target)
@@ -4450,15 +4464,15 @@
 // CommandObjectTargetStopHookList
 //-------------------------------------------------------------------------
 
-class CommandObjectTargetStopHookList : public CommandObject
+class CommandObjectTargetStopHookList : public CommandObjectParsed
 {
 public:
 
     CommandObjectTargetStopHookList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "target stop-hook list",
-                       "List all stop-hooks.",
-                       "target stop-hook list [<type>]")
+        CommandObjectParsed (interpreter,
+                             "target stop-hook list",
+                             "List all stop-hooks.",
+                             "target stop-hook list [<type>]")
     {
     }
 
@@ -4466,9 +4480,9 @@
     {
     }
 
+protected:
     bool
-    Execute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (!target)

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Jun  8 16:56:10 2012
@@ -42,7 +42,7 @@
 // CommandObjectThreadBacktrace
 //-------------------------------------------------------------------------
 
-class CommandObjectThreadBacktrace : public CommandObject
+class CommandObjectThreadBacktrace : public CommandObjectParsed
 {
 public:
 
@@ -121,11 +121,11 @@
     };
 
     CommandObjectThreadBacktrace (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "thread backtrace",
-                       "Show the stack for one or more threads.  If no threads are specified, show the currently selected thread.  Use the thread-index \"all\" to see all threads.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter,
+                           "thread backtrace",
+                           "Show the stack for one or more threads.  If no threads are specified, show the currently selected thread.  Use the thread-index \"all\" to see all threads.",
+                           NULL,
+                           eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_options(interpreter)
     {
         CommandArgumentEntry arg;
@@ -152,8 +152,9 @@
         return &m_options;
     }
 
+protected:
     virtual bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {        
         result.SetStatus (eReturnStatusSuccessFinishResult);
         Stream &strm = result.GetOutputStream();
@@ -250,7 +251,7 @@
         }
         return result.Succeeded();
     }
-protected:
+
     CommandOptions m_options;
 };
 
@@ -268,7 +269,7 @@
     eStepScopeInstruction
 };
 
-class CommandObjectThreadStepWithTypeAndScope : public CommandObject
+class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed
 {
 public:
 
@@ -358,7 +359,7 @@
                                              uint32_t flags,
                                              StepType step_type,
                                              StepScope step_scope) :
-        CommandObject (interpreter, name, help, syntax, flags),
+        CommandObjectParsed (interpreter, name, help, syntax, flags),
         m_step_type (step_type),
         m_step_scope (step_scope),
         m_options (interpreter)
@@ -389,12 +390,9 @@
         return &m_options;
     }
 
+protected:
     virtual bool
-    Execute 
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
         bool synchronous_execution = m_interpreter.GetSynchronous();
@@ -594,16 +592,16 @@
 // CommandObjectThreadContinue
 //-------------------------------------------------------------------------
 
-class CommandObjectThreadContinue : public CommandObject
+class CommandObjectThreadContinue : public CommandObjectParsed
 {
 public:
 
     CommandObjectThreadContinue (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "thread continue",
-                       "Continue execution of one or more threads in an active process.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter, 
+                             "thread continue",
+                             "Continue execution of one or more threads in an active process.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
         CommandArgumentEntry arg;
         CommandArgumentData thread_idx_arg;
@@ -626,11 +624,7 @@
     }
 
     virtual bool
-    Execute
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         bool synchronous_execution = m_interpreter.GetSynchronous ();
 
@@ -782,7 +776,7 @@
 // CommandObjectThreadUntil
 //-------------------------------------------------------------------------
 
-class CommandObjectThreadUntil : public CommandObject
+class CommandObjectThreadUntil : public CommandObjectParsed
 {
 public:
 
@@ -879,11 +873,11 @@
     };
 
     CommandObjectThreadUntil (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "thread until",
-                       "Run the current or specified thread until it reaches a given line number or leaves the current function.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        CommandObjectParsed (interpreter, 
+                             "thread until",
+                             "Run the current or specified thread until it reaches a given line number or leaves the current function.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -913,12 +907,9 @@
         return &m_options;
     }
 
+protected:
     virtual bool
-    Execute 
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         bool synchronous_execution = m_interpreter.GetSynchronous ();
 
@@ -1100,7 +1091,7 @@
         }
         return result.Succeeded();
     }
-protected:
+
     CommandOptions m_options;
 
 };
@@ -1119,16 +1110,16 @@
 // CommandObjectThreadSelect
 //-------------------------------------------------------------------------
 
-class CommandObjectThreadSelect : public CommandObject
+class CommandObjectThreadSelect : public CommandObjectParsed
 {
 public:
 
     CommandObjectThreadSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "thread select",
-                       "Select a thread as the currently active thread.",
-                       NULL,
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "thread select",
+                             "Select a thread as the currently active thread.",
+                             NULL,
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
         CommandArgumentEntry arg;
         CommandArgumentData thread_idx_arg;
@@ -1150,12 +1141,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute 
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
         if (process == NULL)
@@ -1202,17 +1190,17 @@
 // CommandObjectThreadList
 //-------------------------------------------------------------------------
 
-class CommandObjectThreadList : public CommandObject
+class CommandObjectThreadList : public CommandObjectParsed
 {
 public:
 
 
     CommandObjectThreadList (CommandInterpreter &interpreter):
-        CommandObject (interpreter,
-                       "thread list",
-                       "Show a summary of all current threads in a process.",
-                       "thread list",
-                       eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+        CommandObjectParsed (interpreter,
+                             "thread list",
+                             "Show a summary of all current threads in a process.",
+                             "thread list",
+                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {
     }
 
@@ -1220,12 +1208,9 @@
     {
     }
 
+protected:
     bool
-    Execute
-    (
-        Args& command,
-        CommandReturnObject &result
-    )
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Fri Jun  8 16:56:10 2012
@@ -98,7 +98,7 @@
 
 
 
-class CommandObjectTypeSummaryAdd : public CommandObject
+class CommandObjectTypeSummaryAdd : public CommandObjectParsed
 {
     
 private:
@@ -176,18 +176,19 @@
     {
     }
     
-    bool
-    Execute (Args& command, CommandReturnObject &result);
-    
     static bool
     AddSummary(const ConstString& type_name,
                lldb::TypeSummaryImplSP entry,
                SummaryFormatType type,
                std::string category,
                Error* error = NULL);
+protected:
+    bool
+    DoExecute (Args& command, CommandReturnObject &result);
+    
 };
 
-class CommandObjectTypeSynthAdd : public CommandObject
+class CommandObjectTypeSynthAdd : public CommandObjectParsed
 {
     
 private:
@@ -297,13 +298,14 @@
     CollectPythonScript (SynthAddOptions *options,
                          CommandReturnObject &result);    
     bool
-    Execute_HandwritePython (Args& command, CommandReturnObject &result);    
+    Execute_HandwritePython (Args& command, CommandReturnObject &result);
     
     bool
     Execute_PythonClass (Args& command, CommandReturnObject &result);
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result);
+    DoExecute (Args& command, CommandReturnObject &result);
     
 public:
     
@@ -331,7 +333,7 @@
 // CommandObjectTypeFormatAdd
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFormatAdd : public CommandObject
+class CommandObjectTypeFormatAdd : public CommandObjectParsed
 {
     
 private:
@@ -419,10 +421,10 @@
     
 public:
     CommandObjectTypeFormatAdd (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type format add",
-                   "Add a new formatting style for a type.",
-                   NULL), 
+        CommandObjectParsed (interpreter,
+                             "type format add",
+                             "Add a new formatting style for a type.",
+                             NULL), 
         m_option_group (interpreter),
         m_format_options (eFormatInvalid),
         m_command_options ()
@@ -476,8 +478,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -544,14 +547,14 @@
 // CommandObjectTypeFormatDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFormatDelete : public CommandObject
+class CommandObjectTypeFormatDelete : public CommandObjectParsed
 {
 public:
     CommandObjectTypeFormatDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type format delete",
-                   "Delete an existing formatting style for a type.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type format delete",
+                             "Delete an existing formatting style for a type.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -569,8 +572,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -612,14 +616,14 @@
 // CommandObjectTypeFormatClear
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFormatClear : public CommandObject
+class CommandObjectTypeFormatClear : public CommandObjectParsed
 {
 public:
     CommandObjectTypeFormatClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type format clear",
-                   "Delete all existing format styles.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type format clear",
+                             "Delete all existing format styles.",
+                             NULL)
     {
     }
     
@@ -627,8 +631,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         DataVisualization::ValueFormats::Clear();
         result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -653,14 +658,14 @@
                                             RegularExpression* X = NULL) : self(S), result(R), regex(X) {}
 };
 
-class CommandObjectTypeFormatList : public CommandObject
+class CommandObjectTypeFormatList : public CommandObjectParsed
 {
 public:
     CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type format list",
-                   "Show a list of current formatting styles.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type format list",
+                             "Show a list of current formatting styles.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -677,8 +682,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -1230,10 +1236,11 @@
 }
 
 CommandObjectTypeSummaryAdd::CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter) :
-CommandObject (interpreter,
-               "type summary add",
-               "Add a new summary style for a type.",
-               NULL), m_options (interpreter)
+    CommandObjectParsed (interpreter,
+                         "type summary add",
+                         "Add a new summary style for a type.",
+                         NULL),
+    m_options (interpreter)
 {
     CommandArgumentEntry type_arg;
     CommandArgumentData type_style_arg;
@@ -1312,7 +1319,7 @@
 }
 
 bool
-CommandObjectTypeSummaryAdd::Execute (Args& command, CommandReturnObject &result)
+CommandObjectTypeSummaryAdd::DoExecute (Args& command, CommandReturnObject &result)
 {
     if (m_options.m_is_add_script)
     {
@@ -1391,7 +1398,7 @@
 // CommandObjectTypeSummaryDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeSummaryDelete : public CommandObject
+class CommandObjectTypeSummaryDelete : public CommandObjectParsed
 {
 private:
     class CommandOptions : public Options
@@ -1471,10 +1478,11 @@
 
 public:
     CommandObjectTypeSummaryDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type summary delete",
-                   "Delete an existing summary style for a type.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type summary delete",
+                             "Delete an existing summary style for a type.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -1492,8 +1500,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -1551,7 +1560,7 @@
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
-class CommandObjectTypeSummaryClear : public CommandObject
+class CommandObjectTypeSummaryClear : public CommandObjectParsed
 {
 private:
     
@@ -1628,10 +1637,11 @@
     
 public:
     CommandObjectTypeSummaryClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type summary clear",
-                   "Delete all existing summary styles.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type summary clear",
+                             "Delete all existing summary styles.",
+                             NULL),
+        m_options(interpreter)
     {
     }
     
@@ -1639,8 +1649,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         if (m_options.m_delete_all)
@@ -1694,7 +1705,7 @@
                                                   RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
 };
 
-class CommandObjectTypeSummaryList : public CommandObject
+class CommandObjectTypeSummaryList : public CommandObjectParsed
 {
     
     class CommandOptions : public Options
@@ -1760,10 +1771,11 @@
     
 public:
     CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type summary list",
-                   "Show a list of current summary styles.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type summary list",
+                             "Show a list of current summary styles.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -1780,8 +1792,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -1905,14 +1918,14 @@
 // CommandObjectTypeCategoryEnable
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeCategoryEnable : public CommandObject
+class CommandObjectTypeCategoryEnable : public CommandObjectParsed
 {
 public:
     CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type category enable",
-                   "Enable a category as a source of formatters.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type category enable",
+                             "Enable a category as a source of formatters.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -1930,8 +1943,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -1974,14 +1988,14 @@
 // CommandObjectTypeCategoryDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeCategoryDelete : public CommandObject
+class CommandObjectTypeCategoryDelete : public CommandObjectParsed
 {
 public:
     CommandObjectTypeCategoryDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type category delete",
-                   "Delete a category and all associated formatters.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type category delete",
+                             "Delete a category and all associated formatters.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -1999,8 +2013,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2046,14 +2061,14 @@
 // CommandObjectTypeCategoryDisable
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeCategoryDisable : public CommandObject
+class CommandObjectTypeCategoryDisable : public CommandObjectParsed
 {
 public:
     CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type category disable",
-                   "Disable a category as a source of formatters.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type category disable",
+                             "Disable a category as a source of formatters.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2071,8 +2086,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2122,7 +2138,7 @@
 // CommandObjectTypeCategoryList
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeCategoryList : public CommandObject
+class CommandObjectTypeCategoryList : public CommandObjectParsed
 {
 private:
     
@@ -2159,10 +2175,10 @@
     }
 public:
     CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type category list",
-                   "Provide a list of all existing categories.",
-                   NULL)
+        CommandObjectParsed (interpreter,
+                             "type category list",
+                             "Provide a list of all existing categories.",
+                             NULL)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2179,8 +2195,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         RegularExpression* regex = NULL;
@@ -2229,7 +2246,7 @@
                                                   RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
 };
 
-class CommandObjectTypeFilterList : public CommandObject
+class CommandObjectTypeFilterList : public CommandObjectParsed
 {
     
     class CommandOptions : public Options
@@ -2295,10 +2312,11 @@
     
 public:
     CommandObjectTypeFilterList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type filter list",
-                   "Show a list of current filters.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type filter list",
+                             "Show a list of current filters.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2315,8 +2333,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2441,7 +2460,7 @@
                                                  RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
 };
 
-class CommandObjectTypeSynthList : public CommandObject
+class CommandObjectTypeSynthList : public CommandObjectParsed
 {
     
     class CommandOptions : public Options
@@ -2507,10 +2526,11 @@
     
 public:
     CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type synthetic list",
-                   "Show a list of current synthetic providers.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type synthetic list",
+                             "Show a list of current synthetic providers.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2527,8 +2547,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2637,7 +2658,7 @@
 // CommandObjectTypeFilterDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFilterDelete : public CommandObject
+class CommandObjectTypeFilterDelete : public CommandObjectParsed
 {
 private:
     class CommandOptions : public Options
@@ -2716,10 +2737,11 @@
     
 public:
     CommandObjectTypeFilterDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type filter delete",
-                   "Delete an existing filter for a type.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type filter delete",
+                             "Delete an existing filter for a type.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2737,8 +2759,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2801,7 +2824,7 @@
 // CommandObjectTypeSynthDelete
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeSynthDelete : public CommandObject
+class CommandObjectTypeSynthDelete : public CommandObjectParsed
 {
 private:
     class CommandOptions : public Options
@@ -2880,10 +2903,11 @@
     
 public:
     CommandObjectTypeSynthDelete (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type synthetic delete",
-                   "Delete an existing synthetic provider for a type.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type synthetic delete",
+                             "Delete an existing synthetic provider for a type.",
+                             NULL),
+        m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -2901,8 +2925,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         
@@ -2965,7 +2990,7 @@
 // CommandObjectTypeFilterClear
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFilterClear : public CommandObject
+class CommandObjectTypeFilterClear : public CommandObjectParsed
 {
 private:
     
@@ -3041,10 +3066,11 @@
     
 public:
     CommandObjectTypeFilterClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type filter clear",
-                   "Delete all existing filters.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type filter clear",
+                             "Delete all existing filters.",
+                             NULL),
+        m_options(interpreter)
     {
     }
     
@@ -3052,8 +3078,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         if (m_options.m_delete_all)
@@ -3092,7 +3119,7 @@
 // CommandObjectTypeSynthClear
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeSynthClear : public CommandObject
+class CommandObjectTypeSynthClear : public CommandObjectParsed
 {
 private:
     
@@ -3168,10 +3195,11 @@
     
 public:
     CommandObjectTypeSynthClear (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type synthetic clear",
-                   "Delete all existing synthetic providers.",
-                   NULL), m_options(interpreter)
+        CommandObjectParsed (interpreter,
+                             "type synthetic clear",
+                             "Delete all existing synthetic providers.",
+                             NULL),
+        m_options(interpreter)
     {
     }
     
@@ -3179,8 +3207,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         
         if (m_options.m_delete_all)
@@ -3496,10 +3525,11 @@
 }
     
 CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd (CommandInterpreter &interpreter) :
-CommandObject (interpreter,
-               "type synthetic add",
-               "Add a new synthetic provider for a type.",
-               NULL), m_options (interpreter)
+    CommandObjectParsed (interpreter,
+                         "type synthetic add",
+                         "Add a new synthetic provider for a type.",
+                         NULL),
+    m_options (interpreter)
 {
     CommandArgumentEntry type_arg;
     CommandArgumentData type_style_arg;
@@ -3555,7 +3585,7 @@
 }
     
 bool
-CommandObjectTypeSynthAdd::Execute (Args& command, CommandReturnObject &result)
+CommandObjectTypeSynthAdd::DoExecute (Args& command, CommandReturnObject &result)
 {
     if (m_options.handwrite_python)
         return Execute_HandwritePython(command, result);
@@ -3584,7 +3614,7 @@
 
 #endif // #ifndef LLDB_DISABLE_PYTHON
 
-class CommandObjectTypeFilterAdd : public CommandObject
+class CommandObjectTypeFilterAdd : public CommandObjectParsed
 {
     
 private:
@@ -3737,11 +3767,11 @@
 public:
     
     CommandObjectTypeFilterAdd (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "type filter add",
-                   "Add a new filter for a type.",
-                   NULL),
-    m_options (interpreter)
+        CommandObjectParsed (interpreter,
+                             "type filter add",
+                             "Add a new filter for a type.",
+                             NULL),
+        m_options (interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -3785,8 +3815,9 @@
     {
     }
     
+protected:
     bool
-    Execute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         const size_t argc = command.GetArgumentCount();
         

Modified: lldb/trunk/source/Commands/CommandObjectVersion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectVersion.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectVersion.cpp Fri Jun  8 16:56:10 2012
@@ -25,7 +25,7 @@
 //-------------------------------------------------------------------------
 
 CommandObjectVersion::CommandObjectVersion (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, "version", "Show version of LLDB debugger.", "version")
+    CommandObjectParsed (interpreter, "version", "Show version of LLDB debugger.", "version")
 {
 }
 
@@ -34,11 +34,7 @@
 }
 
 bool
-CommandObjectVersion::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
+CommandObjectVersion::DoExecute (Args& args, CommandReturnObject &result)
 {
     result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion());
     result.SetStatus (eReturnStatusSuccessFinishResult);

Modified: lldb/trunk/source/Commands/CommandObjectVersion.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectVersion.h (original)
+++ lldb/trunk/source/Commands/CommandObjectVersion.h Fri Jun  8 16:56:10 2012
@@ -22,7 +22,7 @@
 // CommandObjectVersion
 //-------------------------------------------------------------------------
 
-class CommandObjectVersion : public CommandObject
+class CommandObjectVersion : public CommandObjectParsed
 {
 public:
 
@@ -31,8 +31,9 @@
     virtual
     ~CommandObjectVersion ();
 
+protected:
     virtual bool
-    Execute (Args& args,
+    DoExecute (Args& args,
              CommandReturnObject &result);
 
 };

Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Fri Jun  8 16:56:10 2012
@@ -59,7 +59,30 @@
     return true;
 }
 
+// FIXME: This doesn't seem to be the right place for this functionality.
 #include "llvm/ADT/StringRef.h"
+static inline void StripLeadingSpaces(llvm::StringRef &Str)
+{
+    while (!Str.empty() && isspace(Str[0]))
+        Str = Str.substr(1);
+}
+static inline llvm::StringRef StripOptionTerminator(llvm::StringRef &Str, bool with_dash_w, bool with_dash_x)
+{
+    llvm::StringRef ExprStr = Str;
+
+    // Get rid of the leading spaces first.
+    StripLeadingSpaces(ExprStr);
+
+    // If there's no '-w' and no '-x', we can just return.
+    if (!with_dash_w && !with_dash_x)
+        return ExprStr;
+
+    // Otherwise, split on the "--" option terminator string, and return the rest of the string.
+    ExprStr = ExprStr.split("--").second;
+    StripLeadingSpaces(ExprStr);
+    return ExprStr;
+}
+
 
 // Equivalent class: {"-", "to", "To", "TO"} of range specifier array.
 static const char* RSA[4] = { "-", "to", "To", "TO" };
@@ -143,1092 +166,1161 @@
 }
 
 //-------------------------------------------------------------------------
-// CommandObjectMultiwordWatchpoint
+// CommandObjectWatchpointList
 //-------------------------------------------------------------------------
-#pragma mark MultiwordWatchpoint
-
-CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterpreter &interpreter) :
-    CommandObjectMultiword (interpreter, 
-                            "watchpoint",
-                            "A set of commands for operating on watchpoints.",
-                            "watchpoint <command> [<command-options>]")
-{
-    bool status;
-
-    CommandObjectSP list_command_object (new CommandObjectWatchpointList (interpreter));
-    CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter));
-    CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter));
-    CommandObjectSP delete_command_object (new CommandObjectWatchpointDelete (interpreter));
-    CommandObjectSP ignore_command_object (new CommandObjectWatchpointIgnore (interpreter));
-    CommandObjectSP modify_command_object (new CommandObjectWatchpointModify (interpreter));
-    CommandObjectSP set_command_object (new CommandObjectWatchpointSet (interpreter));
-
-    list_command_object->SetCommandName ("watchpoint list");
-    enable_command_object->SetCommandName("watchpoint enable");
-    disable_command_object->SetCommandName("watchpoint disable");
-    delete_command_object->SetCommandName("watchpoint delete");
-    ignore_command_object->SetCommandName("watchpoint ignore");
-    modify_command_object->SetCommandName("watchpoint modify");
-    set_command_object->SetCommandName("watchpoint set");
-
-    status = LoadSubCommand ("list",       list_command_object);
-    status = LoadSubCommand ("enable",     enable_command_object);
-    status = LoadSubCommand ("disable",    disable_command_object);
-    status = LoadSubCommand ("delete",     delete_command_object);
-    status = LoadSubCommand ("ignore",     ignore_command_object);
-    status = LoadSubCommand ("modify",     modify_command_object);
-    status = LoadSubCommand ("set",        set_command_object);
-}
+#pragma mark List
 
-CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint()
+class CommandObjectWatchpointList : public CommandObjectParsed
 {
-}
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointList::Options
-//-------------------------------------------------------------------------
-#pragma mark List::CommandOptions
+public:
+    CommandObjectWatchpointList (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter, 
+                             "watchpoint list",
+                             "List all watchpoints at configurable levels of detail.",
+                             NULL),
+        m_options(interpreter)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back(arg);
+    }
 
-CommandObjectWatchpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options(interpreter),
-    m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to brief descriptions
-{
-}
+    virtual
+    ~CommandObjectWatchpointList () {}
 
-CommandObjectWatchpointList::CommandOptions::~CommandOptions()
-{
-}
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
 
-OptionDefinition
-CommandObjectWatchpointList::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_1, false, "brief",    'b', no_argument, NULL, 0, eArgTypeNone,
-        "Give a brief description of the watchpoint (no location info)."},
+    class CommandOptions : public Options
+    {
+    public:
 
-    { LLDB_OPT_SET_2, false, "full",    'f', no_argument, NULL, 0, eArgTypeNone,
-        "Give a full description of the watchpoint and its locations."},
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options(interpreter),
+            m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to brief descriptions
+        {
+        }
 
-    { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
-        "Explain everything we know about the watchpoint (for debugging debugger bugs)." },
+        virtual
+        ~CommandOptions () {}
 
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
-};
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
 
-const OptionDefinition*
-CommandObjectWatchpointList::CommandOptions::GetDefinitions()
-{
-    return g_option_table;
-}
+            switch (short_option)
+            {
+                case 'b':
+                    m_level = lldb::eDescriptionLevelBrief;
+                    break;
+                case 'f':
+                    m_level = lldb::eDescriptionLevelFull;
+                    break;
+                case 'v':
+                    m_level = lldb::eDescriptionLevelVerbose;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+                    break;
+            }
 
-Error
-CommandObjectWatchpointList::CommandOptions::SetOptionValue(uint32_t option_idx, const char *option_arg)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+            return error;
+        }
 
-    switch (short_option)
-    {
-        case 'b':
-            m_level = lldb::eDescriptionLevelBrief;
-            break;
-        case 'f':
+        void
+        OptionParsingStarting ()
+        {
             m_level = lldb::eDescriptionLevelFull;
-            break;
-        case 'v':
-            m_level = lldb::eDescriptionLevelVerbose;
-            break;
-        default:
-            error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
-            break;
-    }
-
-    return error;
-}
+        }
 
-void
-CommandObjectWatchpointList::CommandOptions::OptionParsingStarting()
-{
-    m_level = lldb::eDescriptionLevelFull;
-}
+        const OptionDefinition *
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointList
-//-------------------------------------------------------------------------
-#pragma mark List
 
-CommandObjectWatchpointList::CommandObjectWatchpointList(CommandInterpreter &interpreter) :
-    CommandObject(interpreter, 
-                  "watchpoint list",
-                  "List all watchpoints at configurable levels of detail.",
-                  NULL),
-    m_options(interpreter)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back(arg);
-}
+        // Options table: Required for subclasses of Options.
 
-CommandObjectWatchpointList::~CommandObjectWatchpointList()
-{
-}
+        static OptionDefinition g_option_table[];
 
-Options *
-CommandObjectWatchpointList::GetOptions()
-{
-    return &m_options;
-}
+        // Instance variables to hold the values for command options.
 
-bool
-CommandObjectWatchpointList::Execute(Args& args, CommandReturnObject &result)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (target == NULL)
-    {
-        result.AppendError ("Invalid target. No current target or watchpoints.");
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        return true;
-    }
+        lldb::DescriptionLevel m_level;
+    };
 
-    if (target->GetProcessSP() && target->GetProcessSP()->IsAlive())
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        uint32_t num_supported_hardware_watchpoints;
-        Error error = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-        if (error.Success())
-            result.AppendMessageWithFormat("Number of supported hardware watchpoints: %u\n",
-                                           num_supported_hardware_watchpoints);
-    }
-
-    const WatchpointList &watchpoints = target->GetWatchpointList();
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (target == NULL)
+        {
+            result.AppendError ("Invalid target. No current target or watchpoints.");
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return true;
+        }
 
-    size_t num_watchpoints = watchpoints.GetSize();
+        if (target->GetProcessSP() && target->GetProcessSP()->IsAlive())
+        {
+            uint32_t num_supported_hardware_watchpoints;
+            Error error = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
+            if (error.Success())
+                result.AppendMessageWithFormat("Number of supported hardware watchpoints: %u\n",
+                                               num_supported_hardware_watchpoints);
+        }
 
-    if (num_watchpoints == 0)
-    {
-        result.AppendMessage("No watchpoints currently set.");
-        result.SetStatus(eReturnStatusSuccessFinishNoResult);
-        return true;
-    }
+        const WatchpointList &watchpoints = target->GetWatchpointList();
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
 
-    Stream &output_stream = result.GetOutputStream();
+        size_t num_watchpoints = watchpoints.GetSize();
 
-    if (args.GetArgumentCount() == 0)
-    {
-        // No watchpoint selected; show info about all currently set watchpoints.
-        result.AppendMessage ("Current watchpoints:");
-        for (size_t i = 0; i < num_watchpoints; ++i)
-        {
-            Watchpoint *wp = watchpoints.GetByIndex(i).get();
-            AddWatchpointDescription(&output_stream, wp, m_options.m_level);
-        }
-        result.SetStatus(eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular watchpoints selected; enable them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+        if (num_watchpoints == 0)
         {
-            result.AppendError("Invalid watchpoints specification.");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            result.AppendMessage("No watchpoints currently set.");
+            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+            return true;
         }
 
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
+        Stream &output_stream = result.GetOutputStream();
+
+        if (command.GetArgumentCount() == 0)
         {
-            Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get();
-            if (wp)
+            // No watchpoint selected; show info about all currently set watchpoints.
+            result.AppendMessage ("Current watchpoints:");
+            for (size_t i = 0; i < num_watchpoints; ++i)
+            {
+                Watchpoint *wp = watchpoints.GetByIndex(i).get();
                 AddWatchpointDescription(&output_stream, wp, m_options.m_level);
+            }
             result.SetStatus(eReturnStatusSuccessFinishNoResult);
         }
+        else
+        {
+            // Particular watchpoints selected; enable them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+            {
+                Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get();
+                if (wp)
+                    AddWatchpointDescription(&output_stream, wp, m_options.m_level);
+                result.SetStatus(eReturnStatusSuccessFinishNoResult);
+            }
+        }
+
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+private:
+    CommandOptions m_options;
+};
 
 //-------------------------------------------------------------------------
-// CommandObjectWatchpointEnable
+// CommandObjectWatchpointList::Options
 //-------------------------------------------------------------------------
-#pragma mark Enable
-
-CommandObjectWatchpointEnable::CommandObjectWatchpointEnable(CommandInterpreter &interpreter) :
-    CommandObject(interpreter,
-                  "enable",
-                  "Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.",
-                  NULL)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back(arg);
-}
-
-CommandObjectWatchpointEnable::~CommandObjectWatchpointEnable()
+#pragma mark List::CommandOptions
+OptionDefinition
+CommandObjectWatchpointList::CommandOptions::g_option_table[] =
 {
-}
+    { LLDB_OPT_SET_1, false, "brief",    'b', no_argument, NULL, 0, eArgTypeNone,
+        "Give a brief description of the watchpoint (no location info)."},
 
-bool
-CommandObjectWatchpointEnable::Execute(Args& args, CommandReturnObject &result)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (!CheckTargetForWatchpointOperations(target, result))
-        return false;
+    { LLDB_OPT_SET_2, false, "full",    'f', no_argument, NULL, 0, eArgTypeNone,
+        "Give a full description of the watchpoint and its locations."},
 
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
+    { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
+        "Explain everything we know about the watchpoint (for debugging debugger bugs)." },
 
-    const WatchpointList &watchpoints = target->GetWatchpointList();
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
 
-    size_t num_watchpoints = watchpoints.GetSize();
+//-------------------------------------------------------------------------
+// CommandObjectWatchpointEnable
+//-------------------------------------------------------------------------
+#pragma mark Enable
 
-    if (num_watchpoints == 0)
+class CommandObjectWatchpointEnable : public CommandObjectParsed
+{
+public:
+    CommandObjectWatchpointEnable (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "enable",
+                             "Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.",
+                             NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back(arg);
+    }
+
+    virtual
+    ~CommandObjectWatchpointEnable () {}
+
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result)
     {
-        result.AppendError("No watchpoints exist to be enabled.");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (!CheckTargetForWatchpointOperations(target, result))
+            return false;
 
-    if (args.GetArgumentCount() == 0)
-    {
-        // No watchpoint selected; enable all currently set watchpoints.
-        target->EnableAllWatchpoints();
-        result.AppendMessageWithFormat("All watchpoints enabled. (%lu watchpoints)\n", num_watchpoints);
-        result.SetStatus(eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular watchpoints selected; enable them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
+
+        const WatchpointList &watchpoints = target->GetWatchpointList();
+
+        size_t num_watchpoints = watchpoints.GetSize();
+
+        if (num_watchpoints == 0)
         {
-            result.AppendError("Invalid watchpoints specification.");
+            result.AppendError("No watchpoints exist to be enabled.");
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
 
-        int count = 0;
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
-            if (target->EnableWatchpointByID(wp_ids[i]))
-                ++count;
-        result.AppendMessageWithFormat("%d watchpoints enabled.\n", count);
-        result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        if (command.GetArgumentCount() == 0)
+        {
+            // No watchpoint selected; enable all currently set watchpoints.
+            target->EnableAllWatchpoints();
+            result.AppendMessageWithFormat("All watchpoints enabled. (%lu watchpoints)\n", num_watchpoints);
+            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular watchpoints selected; enable them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+
+            int count = 0;
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+                if (target->EnableWatchpointByID(wp_ids[i]))
+                    ++count;
+            result.AppendMessageWithFormat("%d watchpoints enabled.\n", count);
+            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        }
+
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+private:
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectWatchpointDisable
 //-------------------------------------------------------------------------
 #pragma mark Disable
 
-CommandObjectWatchpointDisable::CommandObjectWatchpointDisable(CommandInterpreter &interpreter) :
-    CommandObject(interpreter,
-                  "watchpoint disable",
-                  "Disable the specified watchpoint(s) without removing it/them.  If no watchpoints are specified, disable them all.",
-                  NULL)
+class CommandObjectWatchpointDisable : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back(arg);
-}
+public:
+    CommandObjectWatchpointDisable (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "watchpoint disable",
+                             "Disable the specified watchpoint(s) without removing it/them.  If no watchpoints are specified, disable them all.",
+                             NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back(arg);
+    }
 
-CommandObjectWatchpointDisable::~CommandObjectWatchpointDisable()
-{
-}
 
-bool
-CommandObjectWatchpointDisable::Execute(Args& args, CommandReturnObject &result)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (!CheckTargetForWatchpointOperations(target, result))
-        return false;
+    virtual
+    ~CommandObjectWatchpointDisable () {}
 
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (!CheckTargetForWatchpointOperations(target, result))
+            return false;
 
-    const WatchpointList &watchpoints = target->GetWatchpointList();
-    size_t num_watchpoints = watchpoints.GetSize();
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
 
-    if (num_watchpoints == 0)
-    {
-        result.AppendError("No watchpoints exist to be disabled.");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+        const WatchpointList &watchpoints = target->GetWatchpointList();
+        size_t num_watchpoints = watchpoints.GetSize();
 
-    if (args.GetArgumentCount() == 0)
-    {
-        // No watchpoint selected; disable all currently set watchpoints.
-        if (target->DisableAllWatchpoints())
+        if (num_watchpoints == 0)
         {
-            result.AppendMessageWithFormat("All watchpoints disabled. (%lu watchpoints)\n", num_watchpoints);
-            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+            result.AppendError("No watchpoints exist to be disabled.");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
         }
-        else
+
+        if (command.GetArgumentCount() == 0)
         {
-            result.AppendError("Disable all watchpoints failed\n");
-            result.SetStatus(eReturnStatusFailed);
+            // No watchpoint selected; disable all currently set watchpoints.
+            if (target->DisableAllWatchpoints())
+            {
+                result.AppendMessageWithFormat("All watchpoints disabled. (%lu watchpoints)\n", num_watchpoints);
+                result.SetStatus(eReturnStatusSuccessFinishNoResult);
+            }
+            else
+            {
+                result.AppendError("Disable all watchpoints failed\n");
+                result.SetStatus(eReturnStatusFailed);
+            }
         }
-    }
-    else
-    {
-        // Particular watchpoints selected; disable them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+        else
         {
-            result.AppendError("Invalid watchpoints specification.");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            // Particular watchpoints selected; disable them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+
+            int count = 0;
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+                if (target->DisableWatchpointByID(wp_ids[i]))
+                    ++count;
+            result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
+            result.SetStatus(eReturnStatusSuccessFinishNoResult);
         }
 
-        int count = 0;
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
-            if (target->DisableWatchpointByID(wp_ids[i]))
-                ++count;
-        result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
-        result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectWatchpointDelete
 //-------------------------------------------------------------------------
 #pragma mark Delete
 
-CommandObjectWatchpointDelete::CommandObjectWatchpointDelete(CommandInterpreter &interpreter) :
-    CommandObject(interpreter,
-                  "watchpoint delete",
-                  "Delete the specified watchpoint(s).  If no watchpoints are specified, delete them all.",
-                  NULL)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back(arg);
-}
-
-CommandObjectWatchpointDelete::~CommandObjectWatchpointDelete()
-{
-}
-
-bool
-CommandObjectWatchpointDelete::Execute(Args& args, CommandReturnObject &result)
+class CommandObjectWatchpointDelete : public CommandObjectParsed
 {
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (!CheckTargetForWatchpointOperations(target, result))
-        return false;
-
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
-    
-    const WatchpointList &watchpoints = target->GetWatchpointList();
+public:
+    CommandObjectWatchpointDelete (CommandInterpreter &interpreter) :
+        CommandObjectParsed(interpreter,
+                            "watchpoint delete",
+                            "Delete the specified watchpoint(s).  If no watchpoints are specified, delete them all.",
+                            NULL)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back(arg);
+    }
+
+    virtual
+    ~CommandObjectWatchpointDelete () {}
+
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (!CheckTargetForWatchpointOperations(target, result))
+            return false;
 
-    size_t num_watchpoints = watchpoints.GetSize();
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
+        
+        const WatchpointList &watchpoints = target->GetWatchpointList();
 
-    if (num_watchpoints == 0)
-    {
-        result.AppendError("No watchpoints exist to be deleted.");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+        size_t num_watchpoints = watchpoints.GetSize();
 
-    if (args.GetArgumentCount() == 0)
-    {
-        if (!m_interpreter.Confirm("About to delete all watchpoints, do you want to do that?", true))
+        if (num_watchpoints == 0)
         {
-            result.AppendMessage("Operation cancelled...");
+            result.AppendError("No watchpoints exist to be deleted.");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
         }
-        else
+
+        if (command.GetArgumentCount() == 0)
         {
-            target->RemoveAllWatchpoints();
-            result.AppendMessageWithFormat("All watchpoints removed. (%lu watchpoints)\n", num_watchpoints);
-        }
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
-    {
-        // Particular watchpoints selected; delete them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+            if (!m_interpreter.Confirm("About to delete all watchpoints, do you want to do that?", true))
+            {
+                result.AppendMessage("Operation cancelled...");
+            }
+            else
+            {
+                target->RemoveAllWatchpoints();
+                result.AppendMessageWithFormat("All watchpoints removed. (%lu watchpoints)\n", num_watchpoints);
+            }
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
         {
-            result.AppendError("Invalid watchpoints specification.");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            // Particular watchpoints selected; delete them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+
+            int count = 0;
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+                if (target->RemoveWatchpointByID(wp_ids[i]))
+                    ++count;
+            result.AppendMessageWithFormat("%d watchpoints deleted.\n",count);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
 
-        int count = 0;
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
-            if (target->RemoveWatchpointByID(wp_ids[i]))
-                ++count;
-        result.AppendMessageWithFormat("%d watchpoints deleted.\n",count);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+};
 
 //-------------------------------------------------------------------------
-// CommandObjectWatchpointIgnore::CommandOptions
+// CommandObjectWatchpointIgnore
 //-------------------------------------------------------------------------
-#pragma mark Ignore::CommandOptions
 
-CommandObjectWatchpointIgnore::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_ignore_count (0)
+class CommandObjectWatchpointIgnore : public CommandObjectParsed
 {
-}
-
-CommandObjectWatchpointIgnore::CommandOptions::~CommandOptions ()
-{
-}
-
-OptionDefinition
-CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] =
-{
-    { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
-    { 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
-};
+public:
+    CommandObjectWatchpointIgnore (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "watchpoint ignore",
+                             "Set ignore count on the specified watchpoint(s).  If no watchpoints are specified, set them all.",
+                             NULL),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back(arg);
+    }
 
-const OptionDefinition*
-CommandObjectWatchpointIgnore::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
+    virtual
+    ~CommandObjectWatchpointIgnore () {}
 
-Error
-CommandObjectWatchpointIgnore::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
-{
-    Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
 
-    switch (short_option)
+    class CommandOptions : public Options
     {
-        case 'i':
+    public:
+
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_ignore_count (0)
         {
-            m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-            if (m_ignore_count == UINT32_MAX)
-               error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
         }
-        break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
 
-    return error;
-}
+        virtual
+        ~CommandOptions () {}
 
-void
-CommandObjectWatchpointIgnore::CommandOptions::OptionParsingStarting ()
-{
-    m_ignore_count = 0;
-}
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointIgnore
-//-------------------------------------------------------------------------
-#pragma mark Ignore
+            switch (short_option)
+            {
+                case 'i':
+                {
+                    m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_ignore_count == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
+                }
+                break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
 
-CommandObjectWatchpointIgnore::CommandObjectWatchpointIgnore(CommandInterpreter &interpreter) :
-    CommandObject(interpreter,
-                  "watchpoint ignore",
-                  "Set ignore count on the specified watchpoint(s).  If no watchpoints are specified, set them all.",
-                  NULL),
-    m_options (interpreter)
-{
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back(arg);
-}
+            return error;
+        }
 
-CommandObjectWatchpointIgnore::~CommandObjectWatchpointIgnore()
-{
-}
+        void
+        OptionParsingStarting ()
+        {
+            m_ignore_count = 0;
+        }
 
-Options *
-CommandObjectWatchpointIgnore::GetOptions ()
-{
-    return &m_options;
-}
+        const OptionDefinition *
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
 
-bool
-CommandObjectWatchpointIgnore::Execute(Args& args, CommandReturnObject &result)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (!CheckTargetForWatchpointOperations(target, result))
-        return false;
 
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
-    
-    const WatchpointList &watchpoints = target->GetWatchpointList();
+        // Options table: Required for subclasses of Options.
 
-    size_t num_watchpoints = watchpoints.GetSize();
+        static OptionDefinition g_option_table[];
 
-    if (num_watchpoints == 0)
-    {
-        result.AppendError("No watchpoints exist to be ignored.");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+        // Instance variables to hold the values for command options.
 
-    if (args.GetArgumentCount() == 0)
-    {
-        target->IgnoreAllWatchpoints(m_options.m_ignore_count);
-        result.AppendMessageWithFormat("All watchpoints ignored. (%lu watchpoints)\n", num_watchpoints);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-    else
+        uint32_t m_ignore_count;
+    };
+
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result)
     {
-        // Particular watchpoints selected; ignore them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (!CheckTargetForWatchpointOperations(target, result))
+            return false;
+
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
+        
+        const WatchpointList &watchpoints = target->GetWatchpointList();
+
+        size_t num_watchpoints = watchpoints.GetSize();
+
+        if (num_watchpoints == 0)
         {
-            result.AppendError("Invalid watchpoints specification.");
+            result.AppendError("No watchpoints exist to be ignored.");
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
 
-        int count = 0;
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
-            if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
-                ++count;
-        result.AppendMessageWithFormat("%d watchpoints ignored.\n",count);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
-
-    return result.Succeeded();
-}
+        if (command.GetArgumentCount() == 0)
+        {
+            target->IgnoreAllWatchpoints(m_options.m_ignore_count);
+            result.AppendMessageWithFormat("All watchpoints ignored. (%lu watchpoints)\n", num_watchpoints);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular watchpoints selected; ignore them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointModify::CommandOptions
-//-------------------------------------------------------------------------
-#pragma mark Modify::CommandOptions
+            int count = 0;
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+                if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
+                    ++count;
+            result.AppendMessageWithFormat("%d watchpoints ignored.\n",count);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-CommandObjectWatchpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
-    Options (interpreter),
-    m_condition (),
-    m_condition_passed (false)
-{
-}
+        return result.Succeeded();
+    }
 
-CommandObjectWatchpointModify::CommandOptions::~CommandOptions ()
-{
-}
+private:
+    CommandOptions m_options;
+};
 
+#pragma mark Ignore::CommandOptions
 OptionDefinition
-CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
+CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, NULL, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
-{ 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
+    { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
+    { 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
 };
 
-const OptionDefinition*
-CommandObjectWatchpointModify::CommandOptions::GetDefinitions ()
-{
-    return g_option_table;
-}
-
-Error
-CommandObjectWatchpointModify::CommandOptions::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 'c':
-            if (option_arg != NULL)
-                m_condition.assign (option_arg);
-            else
-                m_condition.clear();
-            m_condition_passed = true;
-            break;
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-
-    return error;
-}
-
-void
-CommandObjectWatchpointModify::CommandOptions::OptionParsingStarting ()
-{
-    m_condition.clear();
-    m_condition_passed = false;
-}
 
 //-------------------------------------------------------------------------
 // CommandObjectWatchpointModify
 //-------------------------------------------------------------------------
 #pragma mark Modify
 
-CommandObjectWatchpointModify::CommandObjectWatchpointModify (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "watchpoint modify", 
-                   "Modify the options on a watchpoint or set of watchpoints in the executable.  "
-                   "If no watchpoint is specified, act on the last created watchpoint.  "
-                   "Passing an empty argument clears the modification.", 
-                   NULL),
-    m_options (interpreter)
+class CommandObjectWatchpointModify : public CommandObjectParsed
 {
-    CommandArgumentEntry arg;
-    CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
-    // Add the entry for the first argument for this command to the object's arguments vector.
-    m_arguments.push_back (arg);   
-}
+public:
 
-CommandObjectWatchpointModify::~CommandObjectWatchpointModify ()
-{
-}
-
-Options *
-CommandObjectWatchpointModify::GetOptions ()
-{
-    return &m_options;
-}
-
-bool
-CommandObjectWatchpointModify::Execute
-(
-    Args& args,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    if (!CheckTargetForWatchpointOperations(target, result))
-        return false;
-
-    Mutex::Locker locker;
-    target->GetWatchpointList().GetListMutex(locker);
-    
-    const WatchpointList &watchpoints = target->GetWatchpointList();
-
-    size_t num_watchpoints = watchpoints.GetSize();
-
-    if (num_watchpoints == 0)
+    CommandObjectWatchpointModify (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "watchpoint modify", 
+                             "Modify the options on a watchpoint or set of watchpoints in the executable.  "
+                             "If no watchpoint is specified, act on the last created watchpoint.  "
+                             "Passing an empty argument clears the modification.", 
+                             NULL),
+        m_options (interpreter)
     {
-        result.AppendError("No watchpoints exist to be modified.");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
+        CommandArgumentEntry arg;
+        CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
+        // Add the entry for the first argument for this command to the object's arguments vector.
+        m_arguments.push_back (arg);   
     }
 
-    if (args.GetArgumentCount() == 0)
+    virtual
+    ~CommandObjectWatchpointModify () {}
+
+    virtual Options *
+    GetOptions ()
     {
-        WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
-        wp_sp->SetCondition(m_options.m_condition.c_str());
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        return &m_options;
     }
-    else
+
+    class CommandOptions : public Options
     {
-        // Particular watchpoints selected; set condition on them.
-        std::vector<uint32_t> wp_ids;
-        if (!VerifyWatchpointIDs(args, wp_ids))
+    public:
+
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_condition (),
+            m_condition_passed (false)
         {
-            result.AppendError("Invalid watchpoints specification.");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
         }
 
-        int count = 0;
-        const size_t size = wp_ids.size();
-        for (size_t i = 0; i < size; ++i)
+        virtual
+        ~CommandOptions () {}
+
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
-            WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
-            if (wp_sp)
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
+
+            switch (short_option)
             {
-                wp_sp->SetCondition(m_options.m_condition.c_str());
-                ++count;
+                case 'c':
+                    if (option_arg != NULL)
+                        m_condition.assign (option_arg);
+                    else
+                        m_condition.clear();
+                    m_condition_passed = true;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
             }
+
+            return error;
         }
-        result.AppendMessageWithFormat("%d watchpoints modified.\n",count);
-        result.SetStatus (eReturnStatusSuccessFinishNoResult);
-    }
 
-    return result.Succeeded();
-}
+        void
+        OptionParsingStarting ()
+        {
+            m_condition.clear();
+            m_condition_passed = false;
+        }
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointSet
-//-------------------------------------------------------------------------
+        // Options table: Required for subclasses of Options.
 
-CommandObjectWatchpointSet::CommandObjectWatchpointSet (CommandInterpreter &interpreter) :
-    CommandObjectMultiword (interpreter,
-                            "watchpoint set",
-                            "A set of commands for setting a watchpoint.",
-                            "watchpoint set <subcommand> [<subcommand-options>]")
-{
-    
-    LoadSubCommand ("variable",   CommandObjectSP (new CommandObjectWatchpointSetVariable (interpreter)));
-    LoadSubCommand ("expression", CommandObjectSP (new CommandObjectWatchpointSetExpression (interpreter)));
-}
+        static OptionDefinition g_option_table[];
 
-CommandObjectWatchpointSet::~CommandObjectWatchpointSet ()
-{
-}
+        // Instance variables to hold the values for command options.
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointSetVariable
-//-------------------------------------------------------------------------
-#pragma mark Set
+        std::string m_condition;
+        bool m_condition_passed;
+    };
 
-CommandObjectWatchpointSetVariable::CommandObjectWatchpointSetVariable (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "watchpoint set variable",
-                   "Set a watchpoint on a variable. "
-                   "Use the '-w' option to specify the type of watchpoint and "
-                   "the '-x' option to specify the byte size to watch for. "
-                   "If no '-w' option is specified, it defaults to read_write. "
-                   "If no '-x' option is specified, it defaults to the variable's "
-                   "byte size. "
-                   "Note that there are limited hardware resources for watchpoints. "
-                   "If watchpoint setting fails, consider disable/delete existing ones "
-                   "to free up resources.",
-                   NULL,
-                   eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
-    m_option_group (interpreter),
-    m_option_watchpoint ()
-{
-    SetHelpLong(
-"Examples: \n\
-\n\
-    watchpoint set variable -w read_wriate my_global_var \n\
-    # Watch my_global_var for read/write access, with the region to watch corresponding to the byte size of the data type.\n");
+protected:
+    virtual bool
+    DoExecute (Args& command, CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        if (!CheckTargetForWatchpointOperations(target, result))
+            return false;
 
-    CommandArgumentEntry arg;
-    CommandArgumentData var_name_arg;
+        Mutex::Locker locker;
+        target->GetWatchpointList().GetListMutex(locker);
         
-    // Define the only variant of this arg.
-    var_name_arg.arg_type = eArgTypeVarName;
-    var_name_arg.arg_repetition = eArgRepeatPlain;
+        const WatchpointList &watchpoints = target->GetWatchpointList();
 
-    // Push the variant into the argument entry.
-    arg.push_back (var_name_arg);
-        
-    // Push the data for the only argument into the m_arguments vector.
-    m_arguments.push_back (arg);
+        size_t num_watchpoints = watchpoints.GetSize();
 
-    // Absorb the '-w' and '-x' options into our option group.
-    m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-    m_option_group.Finalize();
-}
+        if (num_watchpoints == 0)
+        {
+            result.AppendError("No watchpoints exist to be modified.");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
 
-CommandObjectWatchpointSetVariable::~CommandObjectWatchpointSetVariable ()
-{
-}
+        if (command.GetArgumentCount() == 0)
+        {
+            WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
+            wp_sp->SetCondition(m_options.m_condition.c_str());
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
+        else
+        {
+            // Particular watchpoints selected; set condition on them.
+            std::vector<uint32_t> wp_ids;
+            if (!VerifyWatchpointIDs(command, wp_ids))
+            {
+                result.AppendError("Invalid watchpoints specification.");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
 
-Options *
-CommandObjectWatchpointSetVariable::GetOptions ()
-{
-    return &m_option_group;
-}
+            int count = 0;
+            const size_t size = wp_ids.size();
+            for (size_t i = 0; i < size; ++i)
+            {
+                WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
+                if (wp_sp)
+                {
+                    wp_sp->SetCondition(m_options.m_condition.c_str());
+                    ++count;
+                }
+            }
+            result.AppendMessageWithFormat("%d watchpoints modified.\n",count);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        }
 
-bool
-CommandObjectWatchpointSetVariable::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-    StackFrame *frame = exe_ctx.GetFramePtr();
-    if (frame == NULL)
-    {
-        result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        return result.Succeeded();
     }
 
-    // If no argument is present, issue an error message.  There's no way to set a watchpoint.
-    if (command.GetArgumentCount() <= 0)
-    {
-        result.GetErrorStream().Printf("error: required argument missing; specify your program variable to watch for\n");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+private:
+    CommandOptions m_options;
+};
 
-    // If no '-w' is specified, default to '-w read_write'.
-    if (!m_option_watchpoint.watch_type_specified)
-    {
-        m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchReadWrite;
-    }
+#pragma mark Modify::CommandOptions
+OptionDefinition
+CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, NULL, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
+{ 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
+};
 
-    // We passed the sanity check for the command.
-    // Proceed to set the watchpoint now.
-    lldb::addr_t addr = 0;
-    size_t size = 0;
+//-------------------------------------------------------------------------
+// CommandObjectWatchpointSetVariable
+//-------------------------------------------------------------------------
+#pragma mark SetVariable
 
-    VariableSP var_sp;
-    ValueObjectSP valobj_sp;
-    Stream &output_stream = result.GetOutputStream();
+class CommandObjectWatchpointSetVariable : public CommandObjectParsed
+{
+public:
 
-    // A simple watch variable gesture allows only one argument.
-    if (command.GetArgumentCount() != 1) {
-        result.GetErrorStream().Printf("error: specify exactly one variable to watch for\n");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+    CommandObjectWatchpointSetVariable (CommandInterpreter &interpreter) :
+        CommandObjectParsed (interpreter,
+                             "watchpoint set variable",
+                             "Set a watchpoint on a variable. "
+                             "Use the '-w' option to specify the type of watchpoint and "
+                             "the '-x' option to specify the byte size to watch for. "
+                             "If no '-w' option is specified, it defaults to read_write. "
+                             "If no '-x' option is specified, it defaults to the variable's "
+                             "byte size. "
+                             "Note that there are limited hardware resources for watchpoints. "
+                             "If watchpoint setting fails, consider disable/delete existing ones "
+                             "to free up resources.",
+                             NULL,
+                            eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        m_option_group (interpreter),
+        m_option_watchpoint ()
+    {
+        SetHelpLong(
+    "Examples: \n\
+    \n\
+        watchpoint set variable -w read_wriate my_global_var \n\
+        # Watch my_global_var for read/write access, with the region to watch corresponding to the byte size of the data type.\n");
+
+        CommandArgumentEntry arg;
+        CommandArgumentData var_name_arg;
+            
+        // Define the only variant of this arg.
+        var_name_arg.arg_type = eArgTypeVarName;
+        var_name_arg.arg_repetition = eArgRepeatPlain;
+
+        // Push the variant into the argument entry.
+        arg.push_back (var_name_arg);
+            
+        // Push the data for the only argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+
+        // Absorb the '-w' and '-x' options into our option group.
+        m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Finalize();
+    }
+
+    virtual
+    ~CommandObjectWatchpointSetVariable () {}
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+
+protected:
+    virtual bool
+    DoExecute (Args& command,
+             CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
+        StackFrame *frame = exe_ctx.GetFramePtr();
+        if (frame == NULL)
+        {
+            result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    // Things have checked out ok...
-    Error error;
-    uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember;
-    valobj_sp = frame->GetValueForVariableExpressionPath (command.GetArgumentAtIndex(0), 
-                                                          eNoDynamicValues, 
-                                                          expr_path_options,
-                                                          var_sp,
-                                                          error);
-    if (valobj_sp) {
-        AddressType addr_type;
-        addr = valobj_sp->GetAddressOf(false, &addr_type);
-        if (addr_type == eAddressTypeLoad) {
-            // We're in business.
-            // Find out the size of this variable.
-            size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
-                                                       : m_option_watchpoint.watch_size;
-        }
-    } else {
-        const char *error_cstr = error.AsCString(NULL);
-        if (error_cstr)
-            result.GetErrorStream().Printf("error: %s\n", error_cstr);
-        else
-            result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n",
-                                            command.GetArgumentAtIndex(0));
-        return false;
-    }
+        // If no argument is present, issue an error message.  There's no way to set a watchpoint.
+        if (command.GetArgumentCount() <= 0)
+        {
+            result.GetErrorStream().Printf("error: required argument missing; specify your program variable to watch for\n");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
 
-    // Now it's time to create the watchpoint.
-    uint32_t watch_type = m_option_watchpoint.watch_type;
-    error.Clear();
-    Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
-    if (wp) {
-        if (var_sp && var_sp->GetDeclaration().GetFile()) {
+        // If no '-w' is specified, default to '-w read_write'.
+        if (!m_option_watchpoint.watch_type_specified)
+        {
+            m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchReadWrite;
+        }
+
+        // We passed the sanity check for the command.
+        // Proceed to set the watchpoint now.
+        lldb::addr_t addr = 0;
+        size_t size = 0;
+
+        VariableSP var_sp;
+        ValueObjectSP valobj_sp;
+        Stream &output_stream = result.GetOutputStream();
+
+        // A simple watch variable gesture allows only one argument.
+        if (command.GetArgumentCount() != 1) {
+            result.GetErrorStream().Printf("error: specify exactly one variable to watch for\n");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
+
+        // Things have checked out ok...
+        Error error;
+        uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember;
+        valobj_sp = frame->GetValueForVariableExpressionPath (command.GetArgumentAtIndex(0), 
+                                                              eNoDynamicValues, 
+                                                              expr_path_options,
+                                                              var_sp,
+                                                              error);
+        if (valobj_sp) {
+            AddressType addr_type;
+            addr = valobj_sp->GetAddressOf(false, &addr_type);
+            if (addr_type == eAddressTypeLoad) {
+                // We're in business.
+                // Find out the size of this variable.
+                size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
+                                                           : m_option_watchpoint.watch_size;
+            }
+        } else {
+            const char *error_cstr = error.AsCString(NULL);
+            if (error_cstr)
+                result.GetErrorStream().Printf("error: %s\n", error_cstr);
+            else
+                result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n",
+                                                command.GetArgumentAtIndex(0));
+            return false;
+        }
+
+        // Now it's time to create the watchpoint.
+        uint32_t watch_type = m_option_watchpoint.watch_type;
+        error.Clear();
+        Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
+        if (wp) {
+            if (var_sp && var_sp->GetDeclaration().GetFile()) {
+                StreamString ss;
+                // True to show fullpath for declaration file.
+                var_sp->GetDeclaration().DumpStopContext(&ss, true);
+                wp->SetDeclInfo(ss.GetString());
+            }
             StreamString ss;
-            // True to show fullpath for declaration file.
-            var_sp->GetDeclaration().DumpStopContext(&ss, true);
-            wp->SetDeclInfo(ss.GetString());
-        }
-        StreamString ss;
-        output_stream.Printf("Watchpoint created: ");
-        wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
-        output_stream.EOL();
-        result.SetStatus(eReturnStatusSuccessFinishResult);
-    } else {
-        result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
-                                     addr, size);
-        if (error.AsCString(NULL))
-            result.AppendError(error.AsCString());
-        result.SetStatus(eReturnStatusFailed);
+            output_stream.Printf("Watchpoint created: ");
+            wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
+            output_stream.EOL();
+            result.SetStatus(eReturnStatusSuccessFinishResult);
+        } else {
+            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
+                                         addr, size);
+            if (error.AsCString(NULL))
+                result.AppendError(error.AsCString());
+            result.SetStatus(eReturnStatusFailed);
+        }
+
+        return result.Succeeded();
     }
 
-    return result.Succeeded();
-}
+private:
+    OptionGroupOptions m_option_group;
+    OptionGroupWatchpoint m_option_watchpoint;
+};
 
 //-------------------------------------------------------------------------
 // CommandObjectWatchpointSetExpression
 //-------------------------------------------------------------------------
 #pragma mark Set
 
-CommandObjectWatchpointSetExpression::CommandObjectWatchpointSetExpression (CommandInterpreter &interpreter) :
-    CommandObject (interpreter,
-                   "watchpoint set expression",
-                   "Set a watchpoint on an address by supplying an expression. "
-                   "Use the '-w' option to specify the type of watchpoint and "
-                   "the '-x' option to specify the byte size to watch for. "
-                   "If no '-w' option is specified, it defaults to read_write. "
-                   "If no '-x' option is specified, it defaults to the target's "
-                   "pointer byte size. "
-                   "Note that there are limited hardware resources for watchpoints. "
-                   "If watchpoint setting fails, consider disable/delete existing ones "
-                   "to free up resources.",
-                   NULL,
-                   eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
-    m_option_group (interpreter),
-    m_option_watchpoint ()
+class CommandObjectWatchpointSetExpression : public CommandObjectRaw
 {
-    SetHelpLong(
-"Examples: \n\
-\n\
-    watchpoint set expression -w write -x 1 -- foo + 32\n\
-    # Watch write access for the 1-byte region pointed to by the address 'foo + 32'.\n");
+public:
 
-    CommandArgumentEntry arg;
-    CommandArgumentData expression_arg;
-        
-    // Define the only variant of this arg.
-    expression_arg.arg_type = eArgTypeExpression;
-    expression_arg.arg_repetition = eArgRepeatPlain;
+    CommandObjectWatchpointSetExpression (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "watchpoint set expression",
+                          "Set a watchpoint on an address by supplying an expression. "
+                          "Use the '-w' option to specify the type of watchpoint and "
+                          "the '-x' option to specify the byte size to watch for. "
+                          "If no '-w' option is specified, it defaults to read_write. "
+                          "If no '-x' option is specified, it defaults to the target's "
+                          "pointer byte size. "
+                          "Note that there are limited hardware resources for watchpoints. "
+                          "If watchpoint setting fails, consider disable/delete existing ones "
+                          "to free up resources.",
+                          NULL,
+                          eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+        m_option_group (interpreter),
+        m_option_watchpoint ()
+    {
+        SetHelpLong(
+    "Examples: \n\
+    \n\
+        watchpoint set expression -w write -x 1 -- foo + 32\n\
+        # Watch write access for the 1-byte region pointed to by the address 'foo + 32'.\n");
+
+        CommandArgumentEntry arg;
+        CommandArgumentData expression_arg;
+            
+        // Define the only variant of this arg.
+        expression_arg.arg_type = eArgTypeExpression;
+        expression_arg.arg_repetition = eArgRepeatPlain;
+
+        // Push the only variant into the argument entry.
+        arg.push_back (expression_arg);
+            
+        // Push the data for the only argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+
+        // Absorb the '-w' and '-x' options into our option group.
+        m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Finalize();
+    }
+
+
+    virtual
+    ~CommandObjectWatchpointSetExpression () {}
+
+    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
+    virtual bool
+    WantsCompletion() { return true; }
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+
+protected:
+    virtual bool
+    DoExecute (const char *raw_command, CommandReturnObject &result)
+    {
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
+        StackFrame *frame = exe_ctx.GetFramePtr();
+        if (frame == NULL)
+        {
+            result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
 
-    // Push the only variant into the argument entry.
-    arg.push_back (expression_arg);
-        
-    // Push the data for the only argument into the m_arguments vector.
-    m_arguments.push_back (arg);
+        Args command(raw_command);
 
-    // Absorb the '-w' and '-x' options into our option group.
-    m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-    m_option_group.Finalize();
-}
+        // Process possible options.
+        if (!ParseOptions (command, result))
+            return false;
 
-CommandObjectWatchpointSetExpression::~CommandObjectWatchpointSetExpression ()
-{
-}
+        // If no argument is present, issue an error message.  There's no way to set a watchpoint.
+        if (command.GetArgumentCount() <= 0)
+        {
+            result.GetErrorStream().Printf("error: required argument missing; specify an expression to evaulate into the addres to watch for\n");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
 
-Options *
-CommandObjectWatchpointSetExpression::GetOptions ()
-{
-    return &m_option_group;
-}
+        bool with_dash_w = m_option_watchpoint.watch_type_specified;
+        bool with_dash_x = (m_option_watchpoint.watch_size != 0);
 
-#include "llvm/ADT/StringRef.h"
-static inline void StripLeadingSpaces(llvm::StringRef &Str)
-{
-    while (!Str.empty() && isspace(Str[0]))
-        Str = Str.substr(1);
-}
-static inline llvm::StringRef StripOptionTerminator(llvm::StringRef &Str, bool with_dash_w, bool with_dash_x)
-{
-    llvm::StringRef ExprStr = Str;
+        // If no '-w' is specified, default to '-w read_write'.
+        if (!with_dash_w)
+        {
+            m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchReadWrite;
+        }
 
-    // Get rid of the leading spaces first.
-    StripLeadingSpaces(ExprStr);
+        // We passed the sanity check for the command.
+        // Proceed to set the watchpoint now.
+        lldb::addr_t addr = 0;
+        size_t size = 0;
+
+        VariableSP var_sp;
+        ValueObjectSP valobj_sp;
+        Stream &output_stream = result.GetOutputStream();
+
+        // We will process the raw command string to rid of the '-w', '-x', or '--'
+        llvm::StringRef raw_expr_str(raw_command);
+        std::string expr_str = StripOptionTerminator(raw_expr_str, with_dash_w, with_dash_x).str();
 
-    // If there's no '-w' and no '-x', we can just return.
-    if (!with_dash_w && !with_dash_x)
-        return ExprStr;
+        // Sanity check for when the user forgets to terminate the option strings with a '--'.
+        if ((with_dash_w || with_dash_w) && expr_str.empty())
+        {
+            result.GetErrorStream().Printf("error: did you forget to enter the option terminator string \"--\"?\n");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
 
-    // Otherwise, split on the "--" option terminator string, and return the rest of the string.
-    ExprStr = ExprStr.split("--").second;
-    StripLeadingSpaces(ExprStr);
-    return ExprStr;
-}
-bool
-CommandObjectWatchpointSetExpression::ExecuteRawCommandString
-(
-    const char *raw_command,
-    CommandReturnObject &result
-)
-{
-    Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-    ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-    StackFrame *frame = exe_ctx.GetFramePtr();
-    if (frame == NULL)
-    {
-        result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
+        // Use expression evaluation to arrive at the address to watch.
+        const bool coerce_to_id = true;
+        const bool unwind_on_error = true;
+        const bool keep_in_memory = false;
+        ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(), 
+                                                                   frame, 
+                                                                   eExecutionPolicyOnlyWhenNeeded,
+                                                                   coerce_to_id,
+                                                                   unwind_on_error, 
+                                                                   keep_in_memory, 
+                                                                   eNoDynamicValues, 
+                                                                   valobj_sp);
+        if (expr_result != eExecutionCompleted) {
+            result.GetErrorStream().Printf("error: expression evaluation of address to watch failed\n");
+            result.GetErrorStream().Printf("expression evaluated: %s\n", expr_str.c_str());
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
 
-    Args command(raw_command);
+        // Get the address to watch.
+        bool success = false;
+        addr = valobj_sp->GetValueAsUnsigned(0, &success);
+        if (!success) {
+            result.GetErrorStream().Printf("error: expression did not evaluate to an address\n");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
+        size = with_dash_x ? m_option_watchpoint.watch_size
+                           : target->GetArchitecture().GetAddressByteSize();
 
-    // Process possible options.
-    if (!ParseOptions (command, result))
-        return false;
+        // Now it's time to create the watchpoint.
+        uint32_t watch_type = m_option_watchpoint.watch_type;
+        Error error;
+        Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
+        if (wp) {
+            if (var_sp && var_sp->GetDeclaration().GetFile()) {
+                StreamString ss;
+                // True to show fullpath for declaration file.
+                var_sp->GetDeclaration().DumpStopContext(&ss, true);
+                wp->SetDeclInfo(ss.GetString());
+            }
+            StreamString ss;
+            output_stream.Printf("Watchpoint created: ");
+            wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
+            output_stream.EOL();
+            result.SetStatus(eReturnStatusSuccessFinishResult);
+        } else {
+            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
+                                         addr, size);
+            if (error.AsCString(NULL))
+                result.AppendError(error.AsCString());
+            result.SetStatus(eReturnStatusFailed);
+        }
 
-    // If no argument is present, issue an error message.  There's no way to set a watchpoint.
-    if (command.GetArgumentCount() <= 0)
-    {
-        result.GetErrorStream().Printf("error: required argument missing; specify an expression to evaulate into the addres to watch for\n");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
+        return result.Succeeded();
     }
 
-    bool with_dash_w = m_option_watchpoint.watch_type_specified;
-    bool with_dash_x = (m_option_watchpoint.watch_size != 0);
+private:
+    OptionGroupOptions m_option_group;
+    OptionGroupWatchpoint m_option_watchpoint;
+};
 
-    // If no '-w' is specified, default to '-w read_write'.
-    if (!with_dash_w)
+//-------------------------------------------------------------------------
+// CommandObjectWatchpointSet
+//-------------------------------------------------------------------------
+#pragma mark Set
+
+class CommandObjectWatchpointSet : public CommandObjectMultiword
+{
+public:
+
+    CommandObjectWatchpointSet (CommandInterpreter &interpreter) :
+        CommandObjectMultiword (interpreter,
+                                "watchpoint set",
+                                "A set of commands for setting a watchpoint.",
+                                "watchpoint set <subcommand> [<subcommand-options>]")
     {
-        m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchReadWrite;
+        
+        LoadSubCommand ("variable",   CommandObjectSP (new CommandObjectWatchpointSetVariable (interpreter)));
+        LoadSubCommand ("expression", CommandObjectSP (new CommandObjectWatchpointSetExpression (interpreter)));
     }
 
-    // We passed the sanity check for the command.
-    // Proceed to set the watchpoint now.
-    lldb::addr_t addr = 0;
-    size_t size = 0;
 
-    VariableSP var_sp;
-    ValueObjectSP valobj_sp;
-    Stream &output_stream = result.GetOutputStream();
+    virtual
+    ~CommandObjectWatchpointSet () {}
 
-    // We will process the raw command string to rid of the '-w', '-x', or '--'
-    llvm::StringRef raw_expr_str(raw_command);
-    std::string expr_str = StripOptionTerminator(raw_expr_str, with_dash_w, with_dash_x).str();
+};
 
-    // Sanity check for when the user forgets to terminate the option strings with a '--'.
-    if ((with_dash_w || with_dash_w) && expr_str.empty())
-    {
-        result.GetErrorStream().Printf("error: did you forget to enter the option terminator string \"--\"?\n");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+//-------------------------------------------------------------------------
+// CommandObjectMultiwordWatchpoint
+//-------------------------------------------------------------------------
+#pragma mark MultiwordWatchpoint
 
-    // Use expression evaluation to arrive at the address to watch.
-    const bool coerce_to_id = true;
-    const bool unwind_on_error = true;
-    const bool keep_in_memory = false;
-    ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(), 
-                                                               frame, 
-                                                               eExecutionPolicyOnlyWhenNeeded,
-                                                               coerce_to_id,
-                                                               unwind_on_error, 
-                                                               keep_in_memory, 
-                                                               eNoDynamicValues, 
-                                                               valobj_sp);
-    if (expr_result != eExecutionCompleted) {
-        result.GetErrorStream().Printf("error: expression evaluation of address to watch failed\n");
-        result.GetErrorStream().Printf("expression evaluated: %s\n", expr_str.c_str());
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
+CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterpreter &interpreter) :
+    CommandObjectMultiword (interpreter, 
+                            "watchpoint",
+                            "A set of commands for operating on watchpoints.",
+                            "watchpoint <command> [<command-options>]")
+{
+    bool status;
 
-    // Get the address to watch.
-    bool success = false;
-    addr = valobj_sp->GetValueAsUnsigned(0, &success);
-    if (!success) {
-        result.GetErrorStream().Printf("error: expression did not evaluate to an address\n");
-        result.SetStatus(eReturnStatusFailed);
-        return false;
-    }
-    size = with_dash_x ? m_option_watchpoint.watch_size
-                       : target->GetArchitecture().GetAddressByteSize();
+    CommandObjectSP list_command_object (new CommandObjectWatchpointList (interpreter));
+    CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter));
+    CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter));
+    CommandObjectSP delete_command_object (new CommandObjectWatchpointDelete (interpreter));
+    CommandObjectSP ignore_command_object (new CommandObjectWatchpointIgnore (interpreter));
+    CommandObjectSP modify_command_object (new CommandObjectWatchpointModify (interpreter));
+    CommandObjectSP set_command_object (new CommandObjectWatchpointSet (interpreter));
 
-    // Now it's time to create the watchpoint.
-    uint32_t watch_type = m_option_watchpoint.watch_type;
-    Error error;
-    Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
-    if (wp) {
-        if (var_sp && var_sp->GetDeclaration().GetFile()) {
-            StreamString ss;
-            // True to show fullpath for declaration file.
-            var_sp->GetDeclaration().DumpStopContext(&ss, true);
-            wp->SetDeclInfo(ss.GetString());
-        }
-        StreamString ss;
-        output_stream.Printf("Watchpoint created: ");
-        wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
-        output_stream.EOL();
-        result.SetStatus(eReturnStatusSuccessFinishResult);
-    } else {
-        result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
-                                     addr, size);
-        if (error.AsCString(NULL))
-            result.AppendError(error.AsCString());
-        result.SetStatus(eReturnStatusFailed);
-    }
+    list_command_object->SetCommandName ("watchpoint list");
+    enable_command_object->SetCommandName("watchpoint enable");
+    disable_command_object->SetCommandName("watchpoint disable");
+    delete_command_object->SetCommandName("watchpoint delete");
+    ignore_command_object->SetCommandName("watchpoint ignore");
+    modify_command_object->SetCommandName("watchpoint modify");
+    set_command_object->SetCommandName("watchpoint set");
 
-    return result.Succeeded();
+    status = LoadSubCommand ("list",       list_command_object);
+    status = LoadSubCommand ("enable",     enable_command_object);
+    status = LoadSubCommand ("disable",    disable_command_object);
+    status = LoadSubCommand ("delete",     delete_command_object);
+    status = LoadSubCommand ("ignore",     ignore_command_object);
+    status = LoadSubCommand ("modify",     modify_command_object);
+    status = LoadSubCommand ("set",        set_command_object);
 }
+
+CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint()
+{
+}
+

Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.h (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.h Fri Jun  8 16:56:10 2012
@@ -34,285 +34,6 @@
     ~CommandObjectMultiwordWatchpoint ();
 };
 
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointList
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointList : public CommandObject
-{
-public:
-    CommandObjectWatchpointList (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointList ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition *
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        lldb::DescriptionLevel m_level;
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointEnable
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointEnable : public CommandObject
-{
-public:
-    CommandObjectWatchpointEnable (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointEnable ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointDisable
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointDisable : public CommandObject
-{
-public:
-    CommandObjectWatchpointDisable (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointDisable ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointDelete
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointDelete : public CommandObject
-{
-public:
-    CommandObjectWatchpointDelete (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointDelete ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-private:
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointIgnore
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointIgnore : public CommandObject
-{
-public:
-    CommandObjectWatchpointIgnore (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointIgnore ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition *
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        uint32_t m_ignore_count;
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointModify
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointModify : public CommandObject
-{
-public:
-
-    CommandObjectWatchpointModify (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointModify ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-    class CommandOptions : public Options
-    {
-    public:
-
-        CommandOptions (CommandInterpreter &interpreter);
-
-        virtual
-        ~CommandOptions ();
-
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
-        GetDefinitions ();
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-
-        std::string m_condition;
-        bool m_condition_passed;
-    };
-
-private:
-    CommandOptions m_options;
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectWatchpointSet
-//-------------------------------------------------------------------------
-
-class CommandObjectWatchpointSet : public CommandObjectMultiword
-{
-public:
-
-    CommandObjectWatchpointSet (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointSet ();
-
-
-};
-
-class CommandObjectWatchpointSetVariable : public CommandObject
-{
-public:
-
-    CommandObjectWatchpointSetVariable (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointSetVariable ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-private:
-    OptionGroupOptions m_option_group;
-    OptionGroupWatchpoint m_option_watchpoint;
-};
-
-class CommandObjectWatchpointSetExpression : public CommandObject
-{
-public:
-
-    CommandObjectWatchpointSetExpression (CommandInterpreter &interpreter);
-
-    virtual
-    ~CommandObjectWatchpointSetExpression ();
-
-    virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    { return false; }
-
-    virtual bool
-    WantsRawCommandString() { return true; }
-
-    // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
-    virtual bool
-    WantsCompletion() { return true; }
-
-    virtual bool
-    ExecuteRawCommandString (const char *raw_command,
-                             CommandReturnObject &result);
-
-    virtual Options *
-    GetOptions ();
-
-private:
-    OptionGroupOptions m_option_group;
-    OptionGroupWatchpoint m_option_watchpoint;
-};
-
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectWatchpoint_h_

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Jun  8 16:56:10 2012
@@ -1562,35 +1562,7 @@
         if (log)
             log->Printf ("HandleCommand, command line after removing command name(s): '%s'", remainder.c_str());
     
-
-        CommandOverrideCallback command_callback = cmd_obj->GetOverrideCallback();
-        bool handled = false;
-        if (wants_raw_input)
-        {
-            if (command_callback)
-            {
-                std::string full_command (cmd_obj->GetCommandName ());
-                full_command += ' ';
-                full_command += remainder;
-                const char *argv[2] = { NULL, NULL };
-                argv[0] = full_command.c_str();
-                handled = command_callback (cmd_obj->GetOverrideCallbackBaton(), argv);
-            }
-            if (!handled)
-                cmd_obj->ExecuteRawCommandString (remainder.c_str(), result);
-        }
-        else
-        {
-            Args cmd_args (remainder.c_str());
-            if (command_callback)
-            {
-                Args full_args (cmd_obj->GetCommandName ());
-                full_args.AppendArguments(cmd_args);
-                handled = command_callback (cmd_obj->GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
-            }
-            if (!handled)
-                cmd_obj->ExecuteWithOptions (cmd_args, result);
-        }
+        cmd_obj->Execute (remainder.c_str(), result);
     }
     else
     {

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Jun  8 16:56:10 2012
@@ -153,18 +153,6 @@
     return NULL;
 }
 
-Flags&
-CommandObject::GetFlags()
-{
-    return m_flags;
-}
-
-const Flags&
-CommandObject::GetFlags() const
-{
-    return m_flags;
-}
-
 bool
 CommandObject::ParseOptions
 (
@@ -214,16 +202,12 @@
     }
     return true;
 }
+
+
+
 bool
-CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result)
+CommandObject::CheckFlags (CommandReturnObject &result)
 {
-    for (size_t i = 0; i < args.GetArgumentCount();  ++i)
-    {
-        const char *tmp_str = args.GetArgumentAtIndex (i);
-        if (tmp_str[0] == '`')  // back-quote
-            args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str));
-    }
-
     if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
     {
         Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
@@ -274,12 +258,7 @@
             }
         }
     }
-    
-    if (!ParseOptions (args, result))
-        return false;
-
-    // Call the command-specific version of 'Execute', passing it the already processed arguments.
-    return Execute (args, result);
+    return true;
 }
 
 class CommandDictCommandPartialMatch
@@ -846,6 +825,63 @@
     return NULL;
 }
 
+bool
+CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
+{
+    CommandOverrideCallback command_callback = GetOverrideCallback();
+    bool handled = false;
+    Args cmd_args (args_string);
+    if (command_callback)
+    {
+        Args full_args (GetCommandName ());
+        full_args.AppendArguments(cmd_args);
+        handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
+    }
+    if (!handled)
+    {
+        for (size_t i = 0; i < cmd_args.GetArgumentCount();  ++i)
+        {
+            const char *tmp_str = cmd_args.GetArgumentAtIndex (i);
+            if (tmp_str[0] == '`')  // back-quote
+                cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str));
+        }
+
+        if (!CheckFlags(result))
+            return false;
+            
+        if (!ParseOptions (cmd_args, result))
+            return false;
+
+        // Call the command-specific version of 'Execute', passing it the already processed arguments.
+        handled = DoExecute (cmd_args, result);
+    }
+    return handled;
+}
+
+bool
+CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
+{
+    CommandOverrideCallback command_callback = GetOverrideCallback();
+    bool handled = false;
+    if (command_callback)
+    {
+        std::string full_command (GetCommandName ());
+        full_command += ' ';
+        full_command += args_string;
+        const char *argv[2] = { NULL, NULL };
+        argv[0] = full_command.c_str();
+        handled = command_callback (GetOverrideCallbackBaton(), argv);
+    }
+    if (!handled)
+    {
+        if (!CheckFlags(result))
+            return false;
+        else
+            handled = DoExecute (args_string, result);
+    }
+    return handled;
+}
+
 static
 const char *arch_helper()
 {

Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Fri Jun  8 16:56:10 2012
@@ -30,7 +30,7 @@
     const char *syntax,
     uint32_t max_matches
 ) :
-    CommandObject (interpreter, name, help, syntax),
+    CommandObjectRaw (interpreter, name, help, syntax),
     m_max_matches (max_matches),
     m_entries ()
 {
@@ -45,18 +45,7 @@
 
 
 bool
-CommandObjectRegexCommand::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    return false;
-}
-
-
-bool
-CommandObjectRegexCommand::ExecuteRawCommandString
+CommandObjectRegexCommand::DoExecute
 (
     const char *command,
     CommandReturnObject &result

Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Fri Jun  8 16:56:10 2012
@@ -30,10 +30,10 @@
 //-------------------------------------------------------------------------
 
 CommandObjectScript::CommandObjectScript (CommandInterpreter &interpreter, ScriptLanguage script_lang) :
-    CommandObject (interpreter, 
-                   "script",
-                   "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.",
-                   "script [<script-expression-for-evaluation>]"),
+    CommandObjectRaw (interpreter, 
+                      "script",
+                      "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.",
+                      "script [<script-expression-for-evaluation>]"),
     m_script_lang (script_lang)
 {
 }
@@ -43,7 +43,7 @@
 }
 
 bool
-CommandObjectScript::ExecuteRawCommandString
+CommandObjectScript::DoExecute
 (
     const char *command,
     CommandReturnObject &result
@@ -74,21 +74,3 @@
 
     return result.Succeeded();
 }
-
-bool
-CommandObjectScript::WantsRawCommandString()
-{
-    return true;
-}
-
-bool
-CommandObjectScript::Execute
-(
-    Args& command,
-    CommandReturnObject &result
-)
-{
-    // everything should be handled in ExecuteRawCommandString
-    return false;
-}
-

Modified: lldb/trunk/source/Interpreter/CommandObjectScript.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.h?rev=158235&r1=158234&r2=158235&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectScript.h (original)
+++ lldb/trunk/source/Interpreter/CommandObjectScript.h Fri Jun  8 16:56:10 2012
@@ -22,7 +22,7 @@
 // CommandObjectScript
 //-------------------------------------------------------------------------
 
-class CommandObjectScript : public CommandObject
+class CommandObjectScript : public CommandObjectRaw
 {
 public:
 
@@ -32,15 +32,9 @@
     virtual
     ~CommandObjectScript ();
 
-    bool WantsRawCommandString();
-
-    virtual bool
-    ExecuteRawCommandString (const char *command,
-                             CommandReturnObject &result);
-
+protected:
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result);
+    DoExecute (const char *command, CommandReturnObject &result);
 
 private:
     lldb::ScriptLanguage m_script_lang;





More information about the lldb-commits mailing list