From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/2] Use ui_file_up in mi_interp
Date: Mon, 28 Nov 2022 14:28:45 -0700 [thread overview]
Message-ID: <20221128212845.2397077-3-tromey@adacore.com> (raw)
In-Reply-To: <20221128212845.2397077-1-tromey@adacore.com>
This changes mi_interp to use ui_file_up rather than explicit
management.
---
gdb/mi/mi-interp.c | 10 ++++------
gdb/mi/mi-interp.h | 4 ++--
2 files changed, 6 insertions(+), 8 deletions(-)
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 @@ class mi_interp final : public interp
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;
--
2.34.3
next prev parent reply other threads:[~2022-11-28 21:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 21:28 [PATCH 0/2] Minor redirection changes Tom Tromey
2022-11-28 21:28 ` [PATCH 1/2] Rename fields of cli_interp_base::saved_output_files Tom Tromey
2022-11-28 21:28 ` Tom Tromey [this message]
2022-11-29 2:55 ` [PATCH 0/2] Minor redirection changes Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221128212845.2397077-3-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).