Very large changes that were needed in order to allow multiple connections
to the debugger from GUI windows. Previously there was one global debugger
instance that could be accessed that had its own command interpreter and
current state (current target/process/thread/frame). When a GUI debugger
was attached, if it opened more than one window that each had a console
window, there were issues where the last one to setup the global debugger
object won and got control of the debugger.

To avoid this we now create instances of the lldb_private::Debugger that each 
has its own state:
- target list for targets the debugger instance owns
- current process/thread/frame
- its own command interpreter
- its own input, output and error file handles to avoid conflicts
- its own input reader stack

So now clients should call:

    SBDebugger::Initialize(); // (static function)

    SBDebugger debugger (SBDebugger::Create());
    // Use which ever file handles you wish
    debugger.SetErrorFileHandle (stderr, false);
    debugger.SetOutputFileHandle (stdout, false);
    debugger.SetInputFileHandle (stdin, true);

    // main loop
    
    SBDebugger::Terminate(); // (static function)
    
SBDebugger::Initialize() and SBDebugger::Terminate() are ref counted to
ensure nothing gets destroyed too early when multiple clients might be
attached.

Cleaned up the command interpreter and the CommandObject and all subclasses
to take more appropriate arguments.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@106615 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index eb8cdd2..384c03a 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -133,21 +133,20 @@
 bool
 CommandObject::ExecuteCommandString
 (
+    CommandInterpreter &interpreter,
     const char *command_line,
-    CommandContext *context,
-    CommandInterpreter *interpreter,
     CommandReturnObject &result
 )
 {
     Args command_args(command_line);
-    return ExecuteWithOptions (command_args, context, interpreter, result);
+    return ExecuteWithOptions (interpreter, command_args, result);
 }
 
 bool
 CommandObject::ParseOptions
 (
+    CommandInterpreter &interpreter,
     Args& args,
-    CommandInterpreter *interpreter,
     CommandReturnObject &result
 )
 {
@@ -189,9 +188,8 @@
 bool
 CommandObject::ExecuteWithOptions
 (
+    CommandInterpreter &interpreter,
     Args& args,
-    CommandContext *context,
-    CommandInterpreter *interpreter,
     CommandReturnObject &result
 )
 {
@@ -199,10 +197,10 @@
     {
         const char *tmp_str = args.GetArgumentAtIndex (i);
         if (tmp_str[0] == '`')  // back-quote
-            args.ReplaceArgumentAtIndex (i, interpreter->ProcessEmbeddedScriptCommands (tmp_str));
+            args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str));
     }
 
-    Process *process = context->GetExecutionContext().process;
+    Process *process = interpreter.GetDebugger().GetExecutionContext().process;
     if (process == NULL)
     {
         if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
@@ -248,11 +246,11 @@
         }
     }
     
-    if (!ParseOptions (args, interpreter, result))
+    if (!ParseOptions (interpreter, args, result))
         return false;
 
     // Call the command-specific version of 'Execute', passing it the already processed arguments.
-    return Execute (args, context, interpreter, result);
+    return Execute (interpreter, args, result);
 }
 
 class CommandDictCommandPartialMatch
@@ -300,12 +298,12 @@
 int
 CommandObject::HandleCompletion
 (
+    CommandInterpreter &interpreter,
     Args &input,
     int &cursor_index,
     int &cursor_char_position,
     int match_start_point,
     int max_return_elements,
-    CommandInterpreter *interpreter,
     StringList &matches
 )
 {
@@ -340,46 +338,30 @@
             input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1);
 
             bool handled_by_options;
-            handled_by_options = cur_options->HandleOptionCompletion(input,
-                                                                     opt_element_vector,
-                                                                     cursor_index,
-                                                                     cursor_char_position,
-                                                                     match_start_point,
-                                                                     max_return_elements,
-                                                                     interpreter,
-                                                                     matches);
+            handled_by_options = cur_options->HandleOptionCompletion (interpreter, 
+                                                                      input,
+                                                                      opt_element_vector,
+                                                                      cursor_index,
+                                                                      cursor_char_position,
+                                                                      match_start_point,
+                                                                      max_return_elements,
+                                                                      matches);
             if (handled_by_options)
                 return matches.GetSize();
         }
 
         // If we got here, the last word is not an option or an option argument.
-        return HandleArgumentCompletion(input,
-                                        cursor_index,
-                                        cursor_char_position,
-                                        opt_element_vector,
-                                        match_start_point,
-                                        max_return_elements,
-                                        interpreter,
-                                        matches);
+        return HandleArgumentCompletion (interpreter, 
+                                         input,
+                                         cursor_index,
+                                         cursor_char_position,
+                                         opt_element_vector,
+                                         match_start_point,
+                                         max_return_elements,
+                                         matches);
     }
 }
 
-int
-CommandObject::HandleArgumentCompletion
-(
-    Args &input,
-    int &cursor_index,
-    int &cursor_char_position,
-    OptionElementVector &opt_element_vector,
-    int match_start_point,
-    int max_return_elements,
-    CommandInterpreter *interpreter,
-    StringList &matches
-)
-{
-    return 0;
-}
-
 // Case insensitive version of ::strstr()
 // Returns true if s2 is contained within s1.