- Changed all the places where CommandObjectReturn was exporting a StreamString to just exporting
a Stream, and then added GetOutputData & GetErrorData to get the accumulated data.
- Added a StreamTee that will tee output to two provided lldb::StreamSP's.
- Made the CommandObjectReturn use this so you can Tee the results immediately to
the debuggers output file, as well as saving up the results to return when the command
is done executing.
- HandleCommands now uses this so that if you have a set of commands that continue the target
you will see the commands come out as they are processed.
- The Driver now uses this to output the command results as you go, which makes the interface
more reactive seeming.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126015 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 4dff142..e291d93 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -34,7 +34,7 @@
 using namespace lldb_private;
 
 static void
-AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level)
+AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level)
 {
     s->IndentMore();
     bp->GetDescription (s, level, true);
@@ -370,8 +370,8 @@
                                                        m_options.m_check_inlines).get();
                         if (bp)
                         {
-                            StreamString &output_stream = result.GetOutputStream();
-                            output_stream.Printf ("Breakpoint created: ");
+                            Stream &output_stream = result.GetOutputStream();
+                            result.AppendMessage ("Breakpoint created: ");
                             bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
                             output_stream.EOL();
                             if (bp->GetNumLocations() == 0)
@@ -417,7 +417,7 @@
                                                        Breakpoint::Exact).get();
                         if (bp)
                         {
-                            StreamString &output_stream = result.GetOutputStream();
+                            Stream &output_stream = result.GetOutputStream();
                             output_stream.Printf ("Breakpoint created: ");
                             bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
                             output_stream.EOL();
@@ -450,7 +450,7 @@
                         bp = target->CreateBreakpoint (&module_spec, regexp).get();
                         if (bp)
                         {
-                            StreamString &output_stream = result.GetOutputStream();
+                            Stream &output_stream = result.GetOutputStream();
                             output_stream.Printf ("Breakpoint created: ");
                             bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
                             output_stream.EOL();
@@ -497,7 +497,7 @@
     
     if (bp && !use_module)
     {
-        StreamString &output_stream = result.GetOutputStream();
+        Stream &output_stream = result.GetOutputStream();
         output_stream.Printf ("Breakpoint created: ");
         bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
         output_stream.EOL();
@@ -775,7 +775,7 @@
         return true;
     }
 
-    StreamString &output_stream = result.GetOutputStream();
+    Stream &output_stream = result.GetOutputStream();
 
     if (args.GetArgumentCount() == 0)
     {
@@ -1212,7 +1212,7 @@
 
     if (num_cleared > 0)
     {
-        StreamString &output_stream = result.GetOutputStream();
+        Stream &output_stream = result.GetOutputStream();
         output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
         output_stream << ss.GetData();
         output_stream.EOL();
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index edca869..f88264b 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -790,15 +790,19 @@
     
     BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton;
     StringList &commands = data->user_source;
-
+    
     if (commands.GetSize() > 0)
     {
-        CommandReturnObject result;
         if (context->exe_ctx.target)
         {
-        
+            CommandReturnObject result;
             Debugger &debugger = context->exe_ctx.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.
+                
+            result.SetImmediateOutputFile (debugger.GetOutputFile().GetStream());
+            result.SetImmediateErrorFile (debugger.GetErrorFile().GetStream());
+
             bool stop_on_continue = true;
             bool echo_commands    = false;
             bool print_results    = true;
@@ -810,14 +814,6 @@
                                                              echo_commands, 
                                                              print_results, 
                                                              result);
-            // Now dump the commands to the debugger's output:
-            if (!result.Succeeded())
-            {
-                debugger.GetErrorFile().Printf ("%s", result.GetErrorStream().GetData());
-            }
-            
-            debugger.GetOutputFile().Printf ("%s", result.GetOutputStream().GetData());
-
         }
     }
     return ret_value;
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index db500a7..e5435fc 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -187,7 +187,7 @@
     // First time through here, generate the help text for the object and
     // push it to the return result object as well
 
-    StreamString &output_stream = result.GetOutputStream();
+    Stream &output_stream = result.GetOutputStream();
     output_stream.PutCString ("The following subcommands are supported:\n\n");
 
     CommandMap::iterator pos;
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 7329ccb..22fd6c2 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -1483,7 +1483,7 @@
         CommandReturnObject &result
     )
     {
-        StreamString &output_stream = result.GetOutputStream();
+        Stream &output_stream = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
         ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
         if (exe_ctx.process)
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index 4bcf681..d9cb5de 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -65,7 +65,7 @@
         CommandReturnObject &result
     )
     {
-        StreamString &output_stream = result.GetOutputStream();
+        Stream &output_stream = result.GetOutputStream();
         DataExtractor reg_data;
         ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
         RegisterContext *reg_context = exe_ctx.GetRegisterContext ();
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index af11fa7..487cfc9 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -131,7 +131,7 @@
         if (num_thread_infos_dumped < num_threads)
             result.GetOutputStream().Printf("%u of %u threads stopped with reasons:\n", num_thread_infos_dumped, num_threads);
 
-        result.GetOutputStream().GetString().append(strm.GetString());
+        result.AppendMessage (strm.GetString().c_str());
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
     }
     return num_thread_infos_dumped;
@@ -1379,7 +1379,7 @@
         CommandReturnObject &result
     )
     {
-        StreamString &strm = result.GetOutputStream();
+        Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
         ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
         if (exe_ctx.process)
diff --git a/source/Commands/CommandObjectVersion.cpp b/source/Commands/CommandObjectVersion.cpp
index 5e159e1..99b92e7 100644
--- a/source/Commands/CommandObjectVersion.cpp
+++ b/source/Commands/CommandObjectVersion.cpp
@@ -40,8 +40,7 @@
     CommandReturnObject &result
 )
 {
-    StreamString &output_stream = result.GetOutputStream();
-    output_stream.Printf ("%s\n", lldb_private::GetVersion());
+    result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion());
     result.SetStatus (eReturnStatusSuccessFinishResult);
     return true;
 }