From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10548 invoked by alias); 27 Apr 2019 12:42:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 10539 invoked by uid 89); 27 Apr 2019 12:42:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=styled X-HELO: mailsec105.isp.belgacom.be Received: from mailsec105.isp.belgacom.be (HELO mailsec105.isp.belgacom.be) (195.238.20.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Apr 2019 12:42:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1556368940; x=1587904940; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=TZs+B+2L82NcaC2lo2+vH95nRMPrLhSIwYh6sG/Hgac=; b=z6ApqTZ/9mIbNUUmujuyrs/+UlGmoUPlCEHC7Vxnqfzb3VQPQFTSiv7/ RnwxIwcLTXoIKfFmAr17fAabaSvF1g==; Received: from 59.151-129-109.adsl-dyn.isp.belgacom.be (HELO md) ([109.129.151.59]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 27 Apr 2019 14:42:18 +0200 Message-ID: <1556368938.22002.19.camel@skynet.be> Subject: Re: [RFA] Have 'thread|frame apply' style their output. From: Philippe Waroquiers To: Tom Tromey Cc: gdb-patches@sourceware.org Date: Sat, 27 Apr 2019 12:42:00 -0000 In-Reply-To: <874l6mcckt.fsf@tromey.com> References: <20190309225932.14568-1-philippe.waroquiers@skynet.be> <874l6mcckt.fsf@tromey.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00592.txt.bz2 On Thu, 2019-04-25 at 09:46 -0600, Tom Tromey wrote: > > > > > > "Philippe" == Philippe Waroquiers 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