From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30002 invoked by alias); 20 Jul 2012 20:14:01 -0000 Received: (qmail 29977 invoked by uid 22791); 20 Jul 2012 20:13:52 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jul 2012 20:13:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6KKDane023703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Jul 2012 16:13:36 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6KKDZEx004314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 20 Jul 2012 16:13:35 -0400 From: Tom Tromey To: Oliver Buchtala Cc: gdb@sourceware.org Subject: Re: Inconsistency between results of pretty-printing children References: <50092D6B.3040103@googlemail.com> <87629iusci.fsf@fleche.redhat.com> <5009B73B.2030702@googlemail.com> Date: Fri, 20 Jul 2012 20:14:00 -0000 In-Reply-To: <5009B73B.2030702@googlemail.com> (Oliver Buchtala's message of "Fri, 20 Jul 2012 21:53:31 +0200") Message-ID: <87txx2tcls.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00062.txt.bz2 >>>>> "Oliver" == Oliver Buchtala writes: Oliver> here the doc: Oliver> http://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html Oliver> under display_hint "map" Ok, I see. In the 'map' case, each item returned by the 'children' iterator must still be a 2-tuple of the form (NAME VALUE). What 'map' means is that the first item fetched from the iterator is considered to be a key in the map, and the second item fetched from the iterator is considered to be the corresponding value. Then the 3rd item is a key again, the 4th is a value again, and so on. In the CLI the NAME parts are omitted when printing, in this case, just because it makes the output prettier. In MI, nothing changes -- the hint is emitted and the MI client is expected to take whatever action it thinks appropriate. Here's an abbreviated example from the libstdc++ test suite: std::map mp; mp["zardoz"] = 23; // { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } } That last line means that 'print mp' here should show: std::map with 1 elements = {["zardoz"] = 23} If you dig into the libstdc++ StdMapPrinter code you see: def next(self): if self.count % 2 == 0: n = self.rbiter.next() n = n.cast(self.type).dereference()['_M_value_field'] self.pair = n item = n['first'] else: item = self.pair['second'] result = ('[%d]' % self.count, item) self.count = self.count + 1 return result So in the example above it returns a list like [ ('[0]', '"zardoz"'), ('[1]', 23) ] My question for you is: how can we improve the documentation to make this more clear? Right now they read: @item map Indicate that the object being printed is ``map-like'', and that the children of this value can be assumed to alternate between keys and values. Tom