From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 648393857014 for ; Wed, 27 Jul 2022 16:40:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 648393857014 Received: by mail-ed1-x533.google.com with SMTP id o13so7197518edc.0 for ; Wed, 27 Jul 2022 09:40:25 -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:from:date:message-id:subject:to; bh=PeJ3UPmHOfToM4j+PeDnje55uBAWTVErYb/DlQ86gsc=; b=Ol2sLULFjfzNkIRMogG/VMG3m5nXTiGVjAVl+6VvYSxylOABSvt+8iN6ZAq3EGna3A blAg/6ESIfZUlc9ujuuDR1cR0gfI0DeVt9bzenIMiAuaxhKhaauZF0dlqTPQrB4JASk8 Je0UFsZ4mnbL4s07DQd1mcRBjJLx+Q65g/3bzFfFCY2H3+MToM5D9SLFCbpBui1Wxpro FvxsGaz7mVLRF8fUeYQJiTyh83Vghi9cKIsJAnQwMstbTd2+4TqL89L1JW2Cj7uSDm5C 8VKm4+JS8P021z6PRgFaMG5r/SIhYr+0pC8VcwukJY6It2/9WysXNHj8QCFUcJu4jlan N47w== X-Gm-Message-State: AJIora9wB6Raq4uDwukttCcMrPCjpeYzFvo+UI+paJDf417r0CqQbp9f xBrjgEnYZ8cyJ1k4NymmAC9agBl6lFHGd1Q7kj48o6s7SuQ= X-Google-Smtp-Source: AGRyM1teMM7KHJoio9Bxm2TnEPdlkWaU0etdd6yuqGbQZSApeWldTLDImezYTGMqZGsMChhkv3wTDBCw9asg3kgs+6k= X-Received: by 2002:aa7:d683:0:b0:43b:94f0:794 with SMTP id d3-20020aa7d683000000b0043b94f00794mr24241502edr.54.1658940023945; Wed, 27 Jul 2022 09:40:23 -0700 (PDT) MIME-Version: 1.0 From: Ulrich Drepper Date: Wed, 27 Jul 2022 18:40:12 +0200 Message-ID: Subject: tuple pretty printer To: libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Wed, 27 Jul 2022 16:40:35 -0000 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? --- 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)