public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Oliver Buchtala <oliver.buchtala@googlemail.com>
To: gdb@sourceware.org
Subject: Re: Inconsistency between results of pretty-printing children
Date: Fri, 20 Jul 2012 20:58:00 -0000	[thread overview]
Message-ID: <5009C666.8020403@googlemail.com> (raw)
In-Reply-To: <5009C148.70400@googlemail.com>

On 20.07.2012 22:36, Oliver Buchtala wrote:
> On 20.07.2012 22:13, Tom Tromey wrote:
>>>>>>> "Oliver" == Oliver Buchtala <oliver.buchtala@googlemail.com> 
>>>>>>> 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<std::string, int> 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
> I file an issue... with example...
>
>
which is here:
http://sourceware.org/bugzilla/show_bug.cgi?id=14380



  reply	other threads:[~2012-07-20 20:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 10:05 Oliver Buchtala
2012-07-20 12:42 ` Oliver Buchtala
2012-07-20 19:49   ` Tom Tromey
2012-07-20 20:11     ` Oliver Buchtala
2012-07-20 19:48 ` Tom Tromey
     [not found]   ` <5009B73B.2030702@googlemail.com>
2012-07-20 20:14     ` Tom Tromey
2012-07-20 20:20       ` Oliver Buchtala
2012-07-20 20:36       ` Oliver Buchtala
2012-07-20 20:58         ` Oliver Buchtala [this message]
2012-07-20 21:20       ` Oliver Buchtala
2012-07-21  0:12       ` Oliver Buchtala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5009C666.8020403@googlemail.com \
    --to=oliver.buchtala@googlemail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).