From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id EE6B93858D37 for ; Mon, 4 Apr 2022 22:02:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE6B93858D37 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 234M2eMC023577 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 4 Apr 2022 18:02:45 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 234M2eMC023577 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 614A51EFB9; Mon, 4 Apr 2022 18:02:40 -0400 (EDT) Message-ID: Date: Mon, 4 Apr 2022 18:02:40 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] gdb: make timestamped_file implement can_emit_style_escape Content-Language: en-US To: Tom Tromey , Simon Marchi via Gdb-patches References: <20220331173220.2536607-1-simon.marchi@polymtl.ca> <87czhwkczk.fsf@tromey.com> <58e348e8-8d76-eda8-dd70-eb4ee889b4fe@polymtl.ca> From: Simon Marchi In-Reply-To: <58e348e8-8d76-eda8-dd70-eb4ee889b4fe@polymtl.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 4 Apr 2022 22:02:40 +0000 X-Spam-Status: No, score=-3033.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2022 22:02:47 -0000 On 2022-04-04 17:58, Simon Marchi via Gdb-patches wrote: >> Simon> Making >> Simon> timestamped_file implement can_emit_style_escape (returning the value of >> Simon> the stream it wraps) fixes it. To show that it works, modify some >> Simon> logging statements in auto-load.c to output style filenames. You can >> Simon> see it in action by setting "set debug auto-load 1" and running a >> Simon> program. We can incrementally add styling to other debug statements >> Simon> throughout GDB, as needed. >> >> This looks good to me. > > Thanks, will push. > >> I've also wondered what it would take to style error() text. Maybe just >> checking the styling of gdb_stdout when creating the error would be good >> enough, it's not like gdb often stores exceptions and then later reuses >> them. > > Indeed. > >> Another thought was to have styling always be emitted, then optionally >> strip it out just before display. However, user 'printf's can also emit >> styles and one wouldn't want to strip those... > > Or the error string could be saved in an "unrendered" form that > includes the text and its styling. And only render it (with or without > style) when we print it. As an exercise, we can try to think how we > would do it if different uiouts in the same GDB had different methods > of styling, and the error had to be printed on all those uiouts. We > couldn't bake a styled string when emitting the error, we would have to > render it once for each uiout. > > Simon Also, the person who reported this to me suggested that timestamped_file should probably implement more methods to defer to m_stream. If we look at tee_file, it implements a bunch: bool isatty () override; bool term_out () override; bool can_emit_style_escape () override; void flush () override; I'm thinking that isatty and flush should be implemented, since their default behavior from ui_file is probably not adequate? Simon