From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] Don't let tee_file own a stream
Date: Mon, 28 Nov 2022 14:18:28 -0500 [thread overview]
Message-ID: <a22670c0-2bff-247c-0893-9139d2ed57ac@simark.ca> (raw)
In-Reply-To: <20221117182904.1291713-3-tromey@adacore.com>
On 11/17/22 13:29, Tom Tromey via Gdb-patches wrote:
> Right now, tee_file owns the second stream it writes to. This is done
> for the convenience of the users. In a subsequent patch, this will no
> longer be convenient, so this patch moves the responsibility for
> ownership to the users of tee_file.
I think the idea makes sense, from a software design / decoupling point
of view.
> diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
> index af242208a0b..482166ea3a5 100644
> --- a/gdb/mi/mi-interp.c
> +++ b/gdb/mi/mi-interp.c
> @@ -1275,21 +1275,16 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect,
> {
> mi->saved_raw_stdout = mi->raw_stdout;
>
> - /* If something is being redirected, then grab logfile. */
> - ui_file *logfile_p = nullptr;
> - if (logging_redirect || debug_redirect)
> - {
> - logfile_p = logfile.get ();
> - mi->saved_raw_file_to_delete = logfile_p;
> - }
> + ui_file *logfile_p = logfile.get ();
> + mi->saved_raw_file_to_delete = logfile.release ();
>
> /* If something is not being redirected, then a tee containing both the
> logfile and stdout. */
> ui_file *tee = nullptr;
> if (!logging_redirect || !debug_redirect)
> {
> - tee = new tee_file (mi->raw_stdout, std::move (logfile));
> - mi->saved_raw_file_to_delete = tee;
> + tee = new tee_file (mi->raw_stdout, logfile_p);
> + mi->saved_tee_to_delete = tee;
> }
>
> mi->raw_stdout = logging_redirect ? logfile_p : tee;
> @@ -1297,9 +1292,11 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect,
> else
> {
> delete mi->saved_raw_file_to_delete;
> + delete mi->saved_tee_to_delete;
> 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;
Should the two _to_delete ones be ui_file_ups?
Otherwise, everything related to logging / redirection confuse me, so I
can't really comment on the change itself.
Simon
next prev parent reply other threads:[~2022-11-28 19:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 18:29 [PATCH 0/3] Do not let logging use pager Tom Tromey
2022-11-17 18:29 ` [PATCH 1/3] Remove 'saved_output' global Tom Tromey
2022-11-17 18:29 ` [PATCH 2/3] Don't let tee_file own a stream Tom Tromey
2022-11-28 19:18 ` Simon Marchi [this message]
2022-11-28 20:29 ` Tom Tromey
2022-11-17 18:29 ` [PATCH 3/3] Don't let gdb_stdlog use pager Tom Tromey
2022-11-28 19:23 ` Simon Marchi
2022-11-28 20:34 ` Tom Tromey
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=a22670c0-2bff-247c-0893-9139d2ed57ac@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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).