From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48742 invoked by alias); 25 Apr 2019 15:46:31 -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 48676 invoked by uid 89); 25 Apr 2019 15:46:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=ANSI, ansi X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Apr 2019 15:46:28 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 359DC2E57 for ; Thu, 25 Apr 2019 10:46:27 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id JgZvhtSHJ2PzOJgZvhOxqF; Thu, 25 Apr 2019 10:46:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=F1vqnr+oqzJH3mfrf4corGwPT/hzyKxMPMpZ0iX+ONg=; b=Vnmd8KGQ8IghfVBnCgSjH+Q8ot OIS4ILvYhpdRjeV5hT3yuzXSqbvweLEBVguI9zXHE9etH9IU6YZjVftDlEL1FLlN9xcU3sdspX306 ypzt8wX5UK8bVmsEb4BNBDBsD; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:56926 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hJgZu-000nJb-Vo; Thu, 25 Apr 2019 10:46:27 -0500 From: Tom Tromey To: Philippe Waroquiers Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Have 'thread|frame apply' style their output. References: <20190309225932.14568-1-philippe.waroquiers@skynet.be> Date: Thu, 25 Apr 2019 15:46:00 -0000 In-Reply-To: <20190309225932.14568-1-philippe.waroquiers@skynet.be> (Philippe Waroquiers's message of "Sat, 9 Mar 2019 23:59:32 +0100") Message-ID: <874l6mcckt.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-04/txt/msg00528.txt.bz2 >>>>> "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. 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