From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Have 'thread|frame apply' style their output.
Date: Sat, 27 Apr 2019 12:42:00 -0000 [thread overview]
Message-ID: <1556368938.22002.19.camel@skynet.be> (raw)
In-Reply-To: <874l6mcckt.fsf@tromey.com>
On Thu, 2019-04-25 at 09:46 -0600, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
>
> Philippe> 'thread|frame apply CMD' launches CMD so that CMD output goes to a string_file.
> Philippe> This patch ensures that string_file for such CMD output contains
> Philippe> style escape sequences that 'thread|frame apply' will later on
> Philippe> output on the real terminal, so as to have CMD output properly styled.
>
> Thanks for doing this.
>
> Other than some nits, enumerated below, this looks good to me.
Thanks for the review. Pushed after fixing (for the "const?" comment,
I have added an explanation to clarify).
Philippe
>
> Philippe> +/* true if the gdb terminal supports styling, and styling is enabled. */
> Philippe> +static bool
> Philippe> +term_cli_styling (void)
>
> No need for the "void" here.
>
> Philippe> +string_file::string_file ()
> Philippe> +{
> Philippe> + m_term_out = false;
> Philippe> +}
>
> I think this should just be an inline initializer in the header.
> Then this definition isn't needed at all.
>
> Philippe> +string_file::string_file (bool term_out)
> Philippe> +{
> Philippe> + m_term_out = term_out;
> Philippe> +}
>
> This can also be in the header file.
> Also it should use initializer syntax like
>
> : m_term_out (term_out)
>
> Philippe> +bool
> Philippe> +string_file::term_out ()
> Philippe> +{
> Philippe> + return m_term_out;
> Philippe> +}
> Philippe> +
> Philippe> +bool
> Philippe> +string_file::can_emit_style_escape ()
> Philippe> +{
> Philippe> + return m_term_out && term_cli_styling ();
> Philippe> +}
>
> This should have comments saying /* See ui-file.h. */
>
> Philippe> +bool
> Philippe> +stdio_file::can_emit_style_escape ()
>
> Likewise. There are some more instances.
>
> Philippe> + return this == gdb_stdout
> Philippe> + && this->isatty ()
> Philippe> + && term_cli_styling ();
>
> The expression needs parens and reindentation to GNU style.
>
> Philippe> +bool
> Philippe> +tee_file::can_emit_style_escape ()
> Philippe> +{
> Philippe> + return this == gdb_stdout
> Philippe> + && m_one->term_out ()
> Philippe> + && term_cli_styling ();
>
> Indentation.
>
> Philippe> + /* true indicates terminal output behaviour such as cli_styling. */
> Philippe> + virtual bool term_out ()
> Philippe> + { return isatty (); }
> Philippe> +
> Philippe> + /* true if ANSI escapes can be used on STREAM. */
> Philippe> + virtual bool can_emit_style_escape ()
> Philippe> + { return false; }
>
> Should these be const?
>
> Philippe> + /* If TERM_OUT, construct a string_file with terminal output behaviour
> Philippe> + such as cli_styling)
> Philippe> + else collect 'raw' output like the previous constructor. */
> Philippe> + string_file (bool term_out);
>
> Single-argument constructors should nearly always be "explicit".
>
> Tom
next prev parent reply other threads:[~2019-04-27 12:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 22:59 Philippe Waroquiers
2019-03-22 5:31 ` PING " Philippe Waroquiers
2019-03-29 8:01 ` PING^2 " Philippe Waroquiers
2019-04-18 4:12 ` PING^3 " Philippe Waroquiers
2019-04-25 15:46 ` Tom Tromey
2019-04-27 12:42 ` Philippe Waroquiers [this message]
2019-04-27 19:19 ` Simon Marchi
2019-04-28 5:19 ` Philippe Waroquiers
2019-04-28 14:59 ` 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=1556368938.22002.19.camel@skynet.be \
--to=philippe.waroquiers@skynet.be \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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