From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1156 invoked by alias); 20 Jul 2012 20:20:35 -0000 Received: (qmail 1145 invoked by uid 22791); 20 Jul 2012 20:20:35 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-bk0-f41.google.com (HELO mail-bk0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jul 2012 20:20:21 +0000 Received: by bkcjc3 with SMTP id jc3so3771711bkc.0 for ; Fri, 20 Jul 2012 13:20:20 -0700 (PDT) Received: by 10.205.133.11 with SMTP id hw11mr3842067bkc.46.1342815620045; Fri, 20 Jul 2012 13:20:20 -0700 (PDT) Received: from [10.0.0.3] (d83-191-103-145.cust.tele2.at. [83.191.103.145]) by mx.google.com with ESMTPS id z19sm3383103bkw.10.2012.07.20.13.20.18 (version=SSLv3 cipher=OTHER); Fri, 20 Jul 2012 13:20:19 -0700 (PDT) Message-ID: <5009BD81.1080503@googlemail.com> Date: Fri, 20 Jul 2012 20:20:00 -0000 From: Oliver Buchtala User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Tom Tromey 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> <87txx2tcls.fsf@fleche.redhat.com> In-Reply-To: <87txx2tcls.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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/msg00063.txt.bz2 On 20.07.2012 22:13, Tom Tromey wrote: >>>>>> "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 thanks... Though, I have to state my problem using a python list: I expect from pure intuition and ignoring a bit the comment in the map hint docu: Need to return something like that: [("a", gdb.Value(1)), ("b", gdb.Value(2))] Am I wrong in that? To get my gdb (7.4.1) display this pretty I need to provide [("", "a"), ("", gbd.Value(1)), ("", "b"), ("", gdb.Value(2))] instead. Thanks in advance... Regards, Oliver