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/API/SBValue.cpp b/source/API/SBValue.cpp
index ab622c7..e381246 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -33,12 +33,12 @@
 using namespace lldb_private;
 
 SBValue::SBValue () :
-    m_lldb_object_sp ()
+    m_opaque_sp ()
 {
 }
 
 SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
-    m_lldb_object_sp (value_sp)
+    m_opaque_sp (value_sp)
 {
 }
 
@@ -49,7 +49,7 @@
 bool
 SBValue::IsValid () const
 {
-    return  (m_lldb_object_sp.get() != NULL);
+    return  (m_opaque_sp.get() != NULL);
 }
 
 void
@@ -72,25 +72,25 @@
 
         lldb_private::StreamFile out_stream (out_file);
 
-        out_stream.Printf ("%s ", m_lldb_object_sp->GetName().AsCString (NULL));
-        if (! m_lldb_object_sp->IsInScope (lldb_frame))
+        out_stream.Printf ("%s ", m_opaque_sp->GetName().AsCString (NULL));
+        if (! m_opaque_sp->IsInScope (lldb_frame))
             out_stream.Printf ("[out-of-scope] ");
         if (print_type)
         {
-            out_stream.Printf ("(%s) ", m_lldb_object_sp->GetTypeName().AsCString ("<unknown-type>"));
+            out_stream.Printf ("(%s) ", m_opaque_sp->GetTypeName().AsCString ("<unknown-type>"));
         }
 
         if (print_value)
         {
             ExecutionContextScope *exe_scope = frame->get();
-            const char *val_cstr = m_lldb_object_sp->GetValueAsCString(exe_scope);
-            const char *err_cstr = m_lldb_object_sp->GetError().AsCString();
+            const char *val_cstr = m_opaque_sp->GetValueAsCString(exe_scope);
+            const char *err_cstr = m_opaque_sp->GetError().AsCString();
 
             if (!err_cstr)
             {
-                const char *sum_cstr = m_lldb_object_sp->GetSummaryAsCString(exe_scope);
+                const char *sum_cstr = m_opaque_sp->GetSummaryAsCString(exe_scope);
                 const bool is_aggregate =
-                ClangASTContext::IsAggregateType (m_lldb_object_sp->GetOpaqueClangQualType());
+                ClangASTContext::IsAggregateType (m_opaque_sp->GetOpaqueClangQualType());
                 if (val_cstr)
                     out_stream.Printf ("= %s ", val_cstr);
 
@@ -100,13 +100,13 @@
                 if (is_aggregate)
                 {
                     out_stream.PutChar ('{');
-                    const uint32_t num_children = m_lldb_object_sp->GetNumChildren();
+                    const uint32_t num_children = m_opaque_sp->GetNumChildren();
                     if (num_children)
                     {
                         out_stream.IndentMore();
                         for (uint32_t idx = 0; idx < num_children; ++idx)
                         {
-                            lldb::ValueObjectSP child_sp (m_lldb_object_sp->GetChildAtIndex (idx, true));
+                            lldb::ValueObjectSP child_sp (m_opaque_sp->GetChildAtIndex (idx, true));
                             if (child_sp.get())
                             {
                                 out_stream.EOL();
@@ -131,7 +131,7 @@
 SBValue::GetName()
 {
     if (IsValid())
-        return m_lldb_object_sp->GetName().AsCString();
+        return m_opaque_sp->GetName().AsCString();
     else
         return NULL;
 }
@@ -140,7 +140,7 @@
 SBValue::GetTypeName ()
 {
     if (IsValid())
-        return m_lldb_object_sp->GetTypeName().AsCString();
+        return m_opaque_sp->GetTypeName().AsCString();
     else
         return NULL;
 }
@@ -151,7 +151,7 @@
     size_t result = 0;
 
     if (IsValid())
-        result = m_lldb_object_sp->GetByteSize();
+        result = m_opaque_sp->GetByteSize();
 
     return result;
 }
@@ -162,7 +162,7 @@
     bool result = false;
 
     if (IsValid())
-        result = m_lldb_object_sp->IsInScope (frame.get());
+        result = m_opaque_sp->IsInScope (frame.get());
 
     return result;
 }
@@ -171,8 +171,8 @@
 SBValue::GetValue (const SBFrame &frame)
 {
     const char *value_string = NULL;
-    if ( m_lldb_object_sp)
-        value_string = m_lldb_object_sp->GetValueAsCString(frame.get());
+    if ( m_opaque_sp)
+        value_string = m_opaque_sp->GetValueAsCString(frame.get());
     return value_string;
 }
 
@@ -180,7 +180,7 @@
 SBValue::GetValueDidChange ()
 {
     if (IsValid())
-        return m_lldb_object_sp->GetValueDidChange();
+        return m_opaque_sp->GetValueDidChange();
     return false;
 }
 
@@ -188,8 +188,8 @@
 SBValue::GetSummary (const SBFrame &frame)
 {
     const char *value_string = NULL;
-    if ( m_lldb_object_sp)
-        value_string = m_lldb_object_sp->GetSummaryAsCString(frame.get());
+    if ( m_opaque_sp)
+        value_string = m_opaque_sp->GetSummaryAsCString(frame.get());
     return value_string;
 }
 
@@ -198,7 +198,7 @@
 {
     const char *value_string = NULL;
     if (IsValid())
-        value_string = m_lldb_object_sp->GetLocationAsCString(frame.get());
+        value_string = m_opaque_sp->GetLocationAsCString(frame.get());
     return value_string;
 }
 
@@ -207,7 +207,7 @@
 {
     bool success = false;
     if (IsValid())
-        success = m_lldb_object_sp->SetValueFromCString (frame.get(), value_str);
+        success = m_opaque_sp->SetValueFromCString (frame.get(), value_str);
     return success;
 }
 
@@ -218,7 +218,7 @@
 
     if (IsValid())
     {
-        child_sp = m_lldb_object_sp->GetChildAtIndex (idx, true);
+        child_sp = m_opaque_sp->GetChildAtIndex (idx, true);
     }
 
     SBValue sb_value (child_sp);
@@ -229,7 +229,7 @@
 SBValue::GetIndexOfChildWithName (const char *name)
 {
     if (IsValid())
-        return m_lldb_object_sp->GetIndexOfChildWithName (ConstString(name));
+        return m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
     return UINT32_MAX;
 }
 
@@ -241,7 +241,7 @@
 
     if (IsValid())
     {
-        child_sp = m_lldb_object_sp->GetChildMemberWithName (str_name, true);
+        child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
     }
 
     SBValue sb_value (child_sp);
@@ -256,7 +256,7 @@
 
     if (IsValid())
     {
-        num_children = m_lldb_object_sp->GetNumChildren();
+        num_children = m_opaque_sp->GetNumChildren();
     }
 
     return num_children;
@@ -269,7 +269,7 @@
 
     if (IsValid())
     {
-        result = m_lldb_object_sp->GetValueIsValid();
+        result = m_opaque_sp->GetValueIsValid();
     }
 
     return result;
@@ -281,7 +281,7 @@
 {
     if (IsValid())
     {
-        if (m_lldb_object_sp->IsPointerType())
+        if (m_opaque_sp->IsPointerType())
         {
             return GetChildAtIndex(0);
         }
@@ -296,53 +296,53 @@
 
     if (IsValid())
     {
-        is_ptr_type = m_lldb_object_sp->IsPointerType();
+        is_ptr_type = m_opaque_sp->IsPointerType();
     }
 
     return is_ptr_type;
 }
 
 
-lldb_private::ExecutionContext
-SBValue::GetCurrentExecutionContext ()
-{
-    lldb_private::Process *process = NULL;
-    lldb_private::Thread *thread = NULL;
-    lldb_private::StackFrame *frame = NULL;
-
-    SBTarget sb_target = SBDebugger::GetCurrentTarget();
-    if (sb_target.IsValid())
-    {
-        SBProcess sb_process = sb_target.GetProcess();
-        if (sb_process.IsValid())
-        {
-            process = sb_process.get();
-            SBThread sb_thread = sb_process.GetCurrentThread();
-            if (sb_thread.IsValid())
-            {
-                thread = sb_thread.GetLLDBObjectPtr();
-                frame = thread->GetStackFrameAtIndex(0).get();
-                lldb_private::ExecutionContext exe_context (process, thread, frame);
-                return exe_context;
-            }
-            else
-            {
-                lldb_private::ExecutionContext exe_context (process, NULL, NULL);
-                return exe_context;
-            }
-        }
-    }
-
-    lldb_private::ExecutionContext exe_context (NULL, NULL, NULL);
-    return exe_context;
-}
-
-
+//lldb_private::ExecutionContext
+//SBValue::GetCurrentExecutionContext ()
+//{
+//    lldb_private::Process *process = NULL;
+//    lldb_private::Thread *thread = NULL;
+//    lldb_private::StackFrame *frame = NULL;
+//
+//    SBTarget sb_target = SBDebugger::GetCurrentTarget();
+//    if (sb_target.IsValid())
+//    {
+//        SBProcess sb_process = sb_target.GetProcess();
+//        if (sb_process.IsValid())
+//        {
+//            process = sb_process.get();
+//            SBThread sb_thread = sb_process.GetCurrentThread();
+//            if (sb_thread.IsValid())
+//            {
+//                thread = sb_thread.GetLLDBObjectPtr();
+//                frame = thread->GetStackFrameAtIndex(0).get();
+//                lldb_private::ExecutionContext exe_context (process, thread, frame);
+//                return exe_context;
+//            }
+//            else
+//            {
+//                lldb_private::ExecutionContext exe_context (process, NULL, NULL);
+//                return exe_context;
+//            }
+//        }
+//    }
+//
+//    lldb_private::ExecutionContext exe_context (NULL, NULL, NULL);
+//    return exe_context;
+//}
+//
+//
 void *
 SBValue::GetOpaqueType()
 {
-    if (m_lldb_object_sp)
-        return m_lldb_object_sp->GetOpaqueClangQualType();
+    if (m_opaque_sp)
+        return m_opaque_sp->GetOpaqueClangQualType();
     return NULL;
 }
 
@@ -350,23 +350,23 @@
 lldb_private::ValueObject *
 SBValue::get() const
 {
-    return m_lldb_object_sp.get();
+    return m_opaque_sp.get();
 }
 
 lldb_private::ValueObject *
 SBValue::operator->() const
 {
-    return m_lldb_object_sp.get();
+    return m_opaque_sp.get();
 }
 
 lldb::ValueObjectSP &
 SBValue::operator*()
 {
-    return m_lldb_object_sp;
+    return m_opaque_sp;
 }
 
 const lldb::ValueObjectSP &
 SBValue::operator*() const
 {
-    return m_lldb_object_sp;
+    return m_opaque_sp;
 }