public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Pedro Alves <alves.ped@gmail.com>,
	archer@sourceware.org, Paul Pluzhnikov <ppluzhnikov@google.com>
Subject: Re: [python][rfc] Attempt to print the base class if a there is no Python pretty-printer for a derived class.
Date: Fri, 27 Mar 2009 18:05:00 -0000	[thread overview]
Message-ID: <49CD14F9.7070703@redhat.com> (raw)
In-Reply-To: <m3vdpusvm8.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <alves.ped@gmail.com> writes:
>>>>>>             
>
> Pedro> Does this do sensible things if class Y has some
> Pedro> fields that mask the Base class's ones, when you only have a
> Pedro> pretty printer for Base?
>
> Yeah... it pretty-prints Base, then goes on to print the subclass
> fields as usual (perhaps pretty-printing them as well).
>
> Phil, could you post the before- and after- results of your example?
> I think that would clear things up.
>   
Here (attached) is a file I was using today to test some scenarios. They 
do not directly address Pedro's questions (I think your explanation 
does). But they do address on of Paul's.

[pmuldoon@localhost gdb]$ ./gdb ~/derived

(pg-gdb) b 45
Reading in symbols for /home/pmuldoon/derived.cpp...
Breakpoint 1 at 0x400b40: file /home/pmuldoon/derived.cpp, line 45.
(pg-gdb) python import gdb.libstdcxx.v6.printers
(pg-gdb) r

Breakpoint 1, main () at /home/pmuldoon/derived.cpp:45
45 return 0;

(pg-gdb) info locals

map = std::map with 1 elements = {
[0x40363d "one"] = 1
}
uomap = std::tr1::unordered_map with 1 elements = {
[21] = 0x403645 "twenty one"
}
nest = {
<Z> = std::map with 1 elements = {
[0x403650 "twenty-two"] = 22
},
members of X:
map = std::tr1::unordered_map with 1 elements = {
[23] = 0x403638 "test"
},
i = 0
}
base = std::map with 1 elements = {
[0x403641 "two"] = 2
}


[-- Attachment #2: derived.cpp --]
[-- Type: text/x-c++src, Size: 489 bytes --]

#include <map>
#include <tr1/unordered_map>

class Y : public std::tr1::unordered_map<int, char *>
{
public:
  Y()
  {
  }
};

class Z : public std::map<const char *, int>
{
public:
  Z()
  {
  }
};


class X : public Z
{
public:

  Y map;
  int i;
  X ()
  {
    i=0;
    map[23] = "test";
  }
};

int main()
{
  Z map;
  Y uomap;
  X nest;    
  std::map<const char *, int> base;

  map["one"] = 1;
  base["two"] = 2;
  uomap[21] = "twenty one";
  nest["twenty-two"] = 22;
  return 0;
}

      parent reply	other threads:[~2009-03-27 18:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-27 17:05 Phil Muldoon
2009-03-27 17:34 ` Tom Tromey
2009-03-27 17:43   ` Phil Muldoon
2009-03-27 17:47     ` Tom Tromey
2009-03-27 17:46   ` Paul Pluzhnikov
2009-03-27 18:00     ` Tom Tromey
2009-03-27 18:28     ` Phil Muldoon
2009-03-27 17:43 ` Pedro Alves
2009-03-27 17:50   ` Tom Tromey
2009-03-27 18:05     ` Pedro Alves
2009-03-27 18:36       ` Tom Tromey
2009-03-27 19:08       ` Phil Muldoon
2009-03-27 19:25         ` Pedro Alves
2009-03-27 18:05     ` Phil Muldoon [this message]

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=49CD14F9.7070703@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=alves.ped@gmail.com \
    --cc=archer@sourceware.org \
    --cc=ppluzhnikov@google.com \
    --cc=tromey@redhat.com \
    /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).