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.129.124]) by sourceware.org (Postfix) with ESMTPS id 28C6738582AE for ; Thu, 4 Aug 2022 11:03:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 28C6738582AE Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-KSerReDAPSKWrys1DSIChQ-1; Thu, 04 Aug 2022 07:03:39 -0400 X-MC-Unique: KSerReDAPSKWrys1DSIChQ-1 Received: by mail-qt1-f199.google.com with SMTP id k3-20020ac86043000000b0033cab47c483so3885945qtm.4 for ; Thu, 04 Aug 2022 04:03:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6SsPMpGle+6L5l6vvdVg+21k4ZdPU09o/PyGoZjadaE=; b=YTnptp+aeGMX1UxCEe5kOJ9N3ocy/1A5kDbsc3LHLWU+3E4sxfXe+QmH5PMyIAr47O A57aeLdb1Jq2hBtKQCAjYAznyzag69yIK6j1OCneKQel4SWu+ZCQYE25Sd9DzH1IqSVe OsfRtFBB0X5tVayg4Wztf9VA7YgkzQv2dmyGAEjWb2KuSfFXjUKG8bUZh9JkX7xWnZ0F XBneN2rMo+LM8LkUwS1v/P1OsqIvUw7IybgqkQJ+03QIxO1Pyp9vntnq2e7LWUuAnIVq zBIBzpA0aryovQ54/pLt1UOCo3dOBq0x90Y7j6yEel52SjD5PVSmy1A7c/6jozOz9dIi O29w== X-Gm-Message-State: ACgBeo3uAFvVlSMbhM2DnzH2R5OMg8zSrXYyhuBdE/rfZtqB1P66LyBJ 2wg5A0rSMC4bcEWAKgs8bGKAPJSRjTSnndGyD97FFfXZ2ZghTzyNRmW3sOmKI5Yxr2GYFsa5k2O jwp8SOv036bL5AOG786/DTPcISaXLyPA= X-Received: by 2002:a05:6214:2a84:b0:476:feb2:f436 with SMTP id jr4-20020a0562142a8400b00476feb2f436mr807767qvb.43.1659611018391; Thu, 04 Aug 2022 04:03:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5b5mUQU1rHSe+Eg7xdnnpkYHp2p94HzKshtnDmDCavex2JdAo7SaOfPujzaMKGy4JuQNkXI/M9aR7q0OMj7cg= X-Received: by 2002:a05:6214:2a84:b0:476:feb2:f436 with SMTP id jr4-20020a0562142a8400b00476feb2f436mr807731qvb.43.1659611018036; Thu, 04 Aug 2022 04:03:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 4 Aug 2022 12:03:27 +0100 Message-ID: Subject: Re: tuple pretty printer To: Ulrich Drepper Cc: libstdc++@gcc.gnu.org, gcc Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2022 11:03:46 -0000 CC gcc-patches On Wed, 27 Jul 2022 at 17:40, Ulrich Drepper via Libstdc++ wrote: > > The current tuple pretty printer shows for this variable > > std::tuple a{1,2,3}; > > the following output: > > (gdb) p a > $1 = std::tuple containing = {[1] = 1, [2] = 2, [3] = 3} > > I find this quite irritating because the indices don't match the > std::get template parameters. In a large tuple or arrays of tuples > which are less readable than this simple example this becomes an even > larger problem. How about the following simple patch which brings the > indices in line? I think this makes sense, want to push it? > > --- a/libstdc++-v3/python/libstdcxx/v6/printers.py > +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py > @@ -611,9 +611,9 @@ class StdTuplePrinter: > # the value "as is". > fields = impl.type.fields () > if len (fields) < 1 or fields[0].name != "_M_head_impl": > - return ('[%d]' % self.count, impl) > + return ('[%d]' % (self.count - 1), impl) > else: > - return ('[%d]' % self.count, impl['_M_head_impl']) > + return ('[%d]' % (self.count - 1), impl['_M_head_impl']) > > def __init__ (self, typename, val): > self.typename = strip_versioned_namespace(typename) >