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".



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@158235 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index f9da370..54f2a54 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -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;
 };