From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A6C133857719 for ; Wed, 14 Jun 2023 12:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6C133857719 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686744716; 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: in-reply-to:in-reply-to:references:references; bh=kr3KSRj3Dc+JgLADUbg0GSUnH5zA7NBuQpTGc7DmVZU=; b=VCfzcEaKGKH2tu9XWAuFhYbKfIUcY2MZVFAZdxTXL4zZksA4yBAfdJLnHDLzGAMiI6gLnW JvUfDSFmew/ZYhO0x2TQPbv9uHAZ7dhAZc4eXUPu4uQ1xRqJP5JYyjMW02Vxnl//Up5aOx cjTkYe1mEAkHwwxJayO2wwnlMCVAgtc= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-cIB_stCNPaC46OBHPFi40Q-1; Wed, 14 Jun 2023 08:11:54 -0400 X-MC-Unique: cIB_stCNPaC46OBHPFi40Q-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2b1a7e31de7so5151601fa.1 for ; Wed, 14 Jun 2023 05:11:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686744713; x=1689336713; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kr3KSRj3Dc+JgLADUbg0GSUnH5zA7NBuQpTGc7DmVZU=; b=cfgjnm+SrzxA6VElj+1IkS6cAMuu6pN+z1iWnkgraOvDNjJ2VPBiN/OK+zexhRzbzC t71a5nVfCh2dLviGBJRQhcGbTxMxE44tLBY/Plh2I48EGnPErdhNcwYdP+LXvLpd/99J 9oT6V7FTOqGeFyBml8ebzYnTGNECPNEKr86v2yYaPyEPMVtthGI+2zRIQ9uq5sHtxXXN Xw7rt4ecCex+Lw+rcb41Y9jSs8o+Ub4tZgQr5n/obnVCOnpRcAffeaZ6vOAEBbStrBTd ehcvDIZ/YS8SJLYba/dv2nka8kzopH1/r28q++QLragRg/ufNzatO07UMHmzZBVKbICD RmYA== X-Gm-Message-State: AC+VfDxBr4C4LvfjLpk8tj43b+BiE0Vux51JdYxR/XO1Wiv0N8QrYVKG L6AtLbvtlHmxVlsaMSvMU4sMfinsPziiWQzrsE+qhVmjuxY2pfh/cfiDs8A0s4pQMgQEY1xKDlw CYj/tkkTNUvTF7/Ry+NwV57F1vfZkTw== X-Received: by 2002:a05:6512:3298:b0:4f7:6630:8373 with SMTP id p24-20020a056512329800b004f766308373mr888047lfe.19.1686744712985; Wed, 14 Jun 2023 05:11:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oddT5BXEja29g/o66+8K0isFGopexhvhWAFHY9NV/M59acBi2yHemb6laSJsT/Svjr5FVzg== X-Received: by 2002:a05:6512:3298:b0:4f7:6630:8373 with SMTP id p24-20020a056512329800b004f766308373mr888028lfe.19.1686744712593; Wed, 14 Jun 2023 05:11:52 -0700 (PDT) Received: from localhost (2.72.115.87.dyn.plus.net. [87.115.72.2]) by smtp.gmail.com with ESMTPSA id e3-20020a056000194300b0030ae901bc54sm18076868wry.62.2023.06.14.05.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 05:11:52 -0700 (PDT) From: Andrew Burgess To: Tom Tromey , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Style history variable output In-Reply-To: <20230612231100.18608-1-tom@tromey.com> References: <20230612231100.18608-1-tom@tromey.com> Date: Wed, 14 Jun 2023 13:11:51 +0100 Message-ID: <87jzw6w8e0.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tom Tromey writes: > When printing a value, I think the history reference -- the "$1" in > the output -- should be styled using the "variable" style. This patch > implements this. I'm still not 100% sold on the use of variable style, but I do agree that styling the $%d part is a good idea, and short of creating a new style (which feels like overkill), variable does seem like the best choice. > --- > gdb/printcmd.c | 3 ++- > gdb/testsuite/gdb.base/style.exp | 6 +++++- > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/gdb/printcmd.c b/gdb/printcmd.c > index d8d97493bab..204dbfc8219 100644 > --- a/gdb/printcmd.c > +++ b/gdb/printcmd.c > @@ -1253,7 +1253,8 @@ print_value (value *val, const value_print_options &opts) > > annotate_value_history_begin (histindex, val->type ()); > > - gdb_printf ("$%d = ", histindex); > + gdb_printf ("%p[$%d%p] = ", variable_name_style.style ().ptr (), > + histindex, nullptr); How about: std::string idx = string_printf ("$%d", histindex); gdb_printf ("%ps = ", styled_string (variable_name_style.style (), idx.c_str ())); Then the '$' and the '%d' part will be styled as one... > > annotate_value_history_value (); > > diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp > index 0370550d251..0e64ed35c2b 100644 > --- a/gdb/testsuite/gdb.base/style.exp > +++ b/gdb/testsuite/gdb.base/style.exp > @@ -196,8 +196,12 @@ proc run_style_tests { } { > set sfield [limited_style string_field variable] > set efield [limited_style e_field variable] > set evalue [limited_style VALUE_TWO variable] > + # The two parts of the left hand side are styled separately. > + # This is just an oddity of the current implementation. > + set lhs \ > + [limited_style "\\\$" variable][limited_style "$decimal" variable] ... and this can be simplified? Thanks, Andrew > gdb_test "print struct_value" \ > - "\{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*" > + "$lhs = \{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*" > > set ffield [limited_style field variable] > set cstart [string_to_regexp "/* XXX "] > -- > 2.39.2