From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WMz5C1dwtmf00DYAWB0awg (envelope-from ) for ; Wed, 19 Feb 2025 18:59:19 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YNwZPIS2; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 206071E105; Wed, 19 Feb 2025 18:59:19 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6F1B41E08E for ; Wed, 19 Feb 2025 18:59:18 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A83003858401 for ; Wed, 19 Feb 2025 23:59:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A83003858401 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YNwZPIS2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id E75383858C42 for ; Wed, 19 Feb 2025 23:58:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E75383858C42 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E75383858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740009518; cv=none; b=nMogjqaHLf94bA8PEMGSJbOaRuvQ5vU8/4bPof0GQg2MmkGqOci7t1bg8SIrjOR1cWNjZpPNUqiDuGhxy4pfE+FmVTrCxKayMclX2Z5AgplE5SO2c3OwePzYm3FE8Oh/I8Svsur0tbVjgHdoF+a4eqvrJ051BWO38FQ8S2S06n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740009518; c=relaxed/simple; bh=9U6VbDw9Fpd0H/9Db7MYodw6Wdp+zw6/rY0DR7Qy0Vw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Uf/g8LSQitEqtKQqcGkgeegeC1nEKxkNrneH420/NL3DL+rfu/mpxs+Fv/tweNoXEM9sQ4AI0d/xa4UeT9mL18KyH332EEGF8FdiZ+LWBYAFJ9703xwHvAGhkdA+/dqJQHrOJB0AW/+kV3xmxkGZFiZoshxJfTS9yQ7wdmH8xg8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E75383858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740009517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m4Hnmby4rpZmAqH9mAPiXF9fQjY61Wz7avewGQfJr4c=; b=YNwZPIS2+NQ431WcGAWVwZURB7MKwqfCGnAighY3BpK/QAl2MBRTJTXCSvZsBxmm/VkxZv aejcCzls344Vh3lj+jjOtC8YMxAAqaX76A7Ku2ycQu5rCTWkrQCR2EOZgPnQnUxXFJoK1T qSq1Wih6KazHVs6O2Sd40MsYhIH8ps8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-yvm2r61jNeeTHEcwNS7xpQ-1; Wed, 19 Feb 2025 18:58:33 -0500 X-MC-Unique: yvm2r61jNeeTHEcwNS7xpQ-1 X-Mimecast-MFC-AGG-ID: yvm2r61jNeeTHEcwNS7xpQ_1740009510 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D55AA19560B5 for ; Wed, 19 Feb 2025 23:58:29 +0000 (UTC) Received: from f41-zbm-amd (unknown [10.22.81.226]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 984061800877; Wed, 19 Feb 2025 23:58:28 +0000 (UTC) Date: Wed, 19 Feb 2025 16:58:26 -0700 From: Kevin Buettner To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/styling: only check TERM environment once, during initialisation Message-ID: <20250219165826.64dfe432@f41-zbm-amd> In-Reply-To: References: Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: O3k4D-EevvrZnR_fFFtnBVbk565a7ZBM_LJCODrg4zo_1740009510 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Wed, 19 Feb 2025 20:31:04 +0000 Andrew Burgess wrote: > We currently check the TERM environment variable any time we call one > of the ui_file::can_emit_style_escape() functions. This seems > excessive. >=20 > During GDB's startup we also check for the NO_COLOR environment > variable and disable styling if this is set. >=20 > I propose that we combine these two checks, and perform them just once > during startup (as the current NO_COLOR check is currently done). As > with the NO_COLOR check, if the TERM variable is set to "dumb" > indicating that styling is not supported then we should just set > cli_styling to false. >=20 > This does mean that the user can then 'set style enabled on', even for > a dumb terminal, which was not possible previously. Before this > commit the "dumb" terminal check was separate and would prevent > styling even if 'set style enabled on' was in effect. >=20 > Of course, trying to turn on styling in a dumb terminal might not give > the results that a user hope for. And so, I have implemented a check > in `set_style_enabled`, so in a dumb terminal a user will see this: >=20 > (gdb) set style enabled on > warning: The current terminal doesn't support styling. Styled output m= ight not appear as expected. >=20 > After which GDB will try to emit styling. We could, potentially, > prevent styling being enabled instead of emitting a warning, but I'm > inclined to let the user turn on styling if they really want to. This all makes sense to me.=20 I found one nit... > diff --git a/gdb/ui-file.c b/gdb/ui-file.c > index dd15ea427bc..14931f3aef9 100644 > --- a/gdb/ui-file.c > +++ b/gdb/ui-file.c > @@ -180,28 +180,12 @@ null_file::write_async_safe (const char *buf, long = sizeof_buf) > =20 > =0C > =20 > -/* true if the gdb terminal supports styling, and styling is enabled. *= / > +/* Return true styling is currently enabled. */ I think you should add an "if" to the comment, i.e. "Return true if ..." Approved-by: Kevin Buettner Kevin