From: Tom Tromey Date: Mon, 28 Nov 2022 21:05:05 +0000 (-0700) Subject: Use ui_file_up in mi_interp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=016c606c66ce4b98c220130b9046545b04254a4a;p=binutils-gdb.git Use ui_file_up in mi_interp This changes mi_interp to use ui_file_up rather than explicit management. Approved-By: Simon Marchi --- diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 482166ea3a5..3cc2462f672 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -1276,7 +1276,7 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect, mi->saved_raw_stdout = mi->raw_stdout; ui_file *logfile_p = logfile.get (); - mi->saved_raw_file_to_delete = logfile.release (); + mi->logfile_holder = std::move (logfile); /* If something is not being redirected, then a tee containing both the logfile and stdout. */ @@ -1284,19 +1284,17 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect, if (!logging_redirect || !debug_redirect) { tee = new tee_file (mi->raw_stdout, logfile_p); - mi->saved_tee_to_delete = tee; + mi->stdout_holder.reset (tee); } mi->raw_stdout = logging_redirect ? logfile_p : tee; } else { - delete mi->saved_raw_file_to_delete; - delete mi->saved_tee_to_delete; + mi->logfile_holder.reset (); + mi->stdout_holder.reset (); mi->raw_stdout = mi->saved_raw_stdout; mi->saved_raw_stdout = nullptr; - mi->saved_raw_file_to_delete = nullptr; - mi->saved_tee_to_delete = nullptr; } mi->out->set_raw (mi->raw_stdout); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index d118ffb41e5..6b6e1f70220 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -56,8 +56,8 @@ public: file which we need to delete, so we can restore correctly when done. */ struct ui_file *saved_raw_stdout; - struct ui_file *saved_raw_file_to_delete; - struct ui_file *saved_tee_to_delete; + ui_file_up logfile_holder; + ui_file_up stdout_holder; /* MI's builder. */ struct ui_out *mi_uiout;