Rename common to gdbsupport
[deliverable/binutils-gdb.git] / gdb / mi / mi-interp.c
index 6a19bf02476d56a2c2e29da5cf57ddf34b577bd4..ab1f9138876ad00a1d487ea7f4d486e7543c9a91 100644 (file)
@@ -38,7 +38,7 @@
 #include "cli-out.h"
 #include "thread-fsm.h"
 #include "cli/cli-interp.h"
-#include "common/scope-exit.h"
+#include "gdbsupport/scope-exit.h"
 
 /* These are the interpreter setup, etc. functions for the MI
    interpreter.  */
@@ -1279,7 +1279,8 @@ mi_interp::interp_ui_out ()
    the consoles to use the supplied ui-file(s).  */
 
 void
-mi_interp::set_logging (ui_file_up logfile, bool logging_redirect)
+mi_interp::set_logging (ui_file_up logfile, bool logging_redirect,
+                       bool debug_redirect)
 {
   struct mi_interp *mi = this;
 
@@ -1289,22 +1290,30 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect)
 
       /* If something is being redirected, then grab logfile.  */
       ui_file *logfile_p = nullptr;
-      if (logging_redirect)
-       logfile_p = logfile.release ();
+      if (logging_redirect || debug_redirect)
+       {
+         logfile_p = logfile.get ();
+         mi->saved_raw_file_to_delete = logfile_p;
+       }
 
       /* If something is not being redirected, then a tee containing both the
         logfile and stdout.  */
       ui_file *tee = nullptr;
-      if (!logging_redirect)
-       tee = new tee_file (mi->raw_stdout, std::move (logfile));
+      if (!logging_redirect || !debug_redirect)
+       {
+         tee = new tee_file (mi->raw_stdout, std::move (logfile));
+         mi->saved_raw_file_to_delete = tee;
+       }
 
       mi->raw_stdout = logging_redirect ? logfile_p : tee;
+      mi->raw_stdlog = debug_redirect ? logfile_p : tee;
     }
   else
     {
-      delete mi->raw_stdout;
+      delete mi->saved_raw_file_to_delete;
       mi->raw_stdout = mi->saved_raw_stdout;
       mi->saved_raw_stdout = nullptr;
+      mi->saved_raw_file_to_delete = nullptr;
     }
 
   mi->out->set_raw (mi->raw_stdout);
This page took 0.024637 seconds and 4 git commands to generate.