Add 'batch_mode' to CommandInterpreter.  Modify InputReaders to
not write output (prompts, instructions,etc.) if the CommandInterpreter
is in batch_mode.

Also, finish updating InputReaders to write to the asynchronous stream,
rather than using the Debugger's output file directly.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@133162 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 1399fb0..3245dbb 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -3075,17 +3075,21 @@
                                   const char *bytes, 
                                   size_t bytes_len)
     {
-        File &out_file = reader.GetDebugger().GetOutputFile();
+        StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
         Target::StopHook *new_stop_hook = ((Target::StopHook *) baton);
         static bool got_interrupted;
+        bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode();
 
         switch (notification)
         {
         case eInputReaderActivate:
-            out_file.Printf ("%s\n", "Enter your stop hook command(s).  Type 'DONE' to end.");
-            if (reader.GetPrompt())
-                out_file.Printf ("%s", reader.GetPrompt());
-            out_file.Flush();
+            if (!batch_mode)
+            {
+                out_stream->Printf ("%s\n", "Enter your stop hook command(s).  Type 'DONE' to end.");
+                if (reader.GetPrompt())
+                    out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
+            }
             got_interrupted = false;
             break;
 
@@ -3093,10 +3097,10 @@
             break;
 
         case eInputReaderReactivate:
-            if (reader.GetPrompt())
+            if (reader.GetPrompt() && !batch_mode)
             {
-                out_file.Printf ("%s", reader.GetPrompt());
-                out_file.Flush();
+                out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
             }
             got_interrupted = false;
             break;
@@ -3113,10 +3117,10 @@
                     commands->AppendString (bytes, bytes_len); 
                 }
             }
-            if (!reader.IsDone() && reader.GetPrompt())
+            if (!reader.IsDone() && reader.GetPrompt() && !batch_mode)
             {
-                out_file.Printf ("%s", reader.GetPrompt());
-                out_file.Flush();
+                out_stream->Printf ("%s", reader.GetPrompt());
+                out_stream->Flush();
             }
             break;
             
@@ -3124,8 +3128,12 @@
             {
                 // Finish, and cancel the stop hook.
                 new_stop_hook->GetTarget()->RemoveStopHookByID(new_stop_hook->GetID());
-                out_file.Printf ("Stop hook cancelled.\n");
-
+                if (!batch_mode)
+                {
+                    out_stream->Printf ("Stop hook cancelled.\n");
+                    out_stream->Flush();
+                }
+                
                 reader.SetIsDone (true);
             }
             got_interrupted = true;
@@ -3136,8 +3144,11 @@
             break;
             
         case eInputReaderDone:
-            if (!got_interrupted)
-                out_file.Printf ("Stop hook #%d added.\n", new_stop_hook->GetID());
+            if (!got_interrupted && !batch_mode)
+            {
+                out_stream->Printf ("Stop hook #%d added.\n", new_stop_hook->GetID());
+                out_stream->Flush();
+            }
             break;
         }