<rdar://problem/10605072>

Added the ability to override command line commands. In some cases GUI interfaces
might want to intercept commands like "quit" or "process launch" (which might cause
the process to re-run). They can now do so by overriding/intercepting commands
by using functions added to SBCommandInterpreter using a callback function. If the
callback function returns true, the command is assumed to be handled. If false
is returned the command should be evaluated normally.

Adopted this up in the Driver.cpp for intercepting the "quit" command.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151708 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 8b4dc81..8c3d2d3 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1511,12 +1511,33 @@
             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)
-            cmd_obj->ExecuteRawCommandString (remainder.c_str(), result);
+        {
+            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());
-            cmd_obj->ExecuteWithOptions (cmd_args, result);
+            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);
         }
     }
     else