[python][rfc] Attempt to print the base class if a there is no Python pretty-printer for a derived class.
Phil Muldoon
pmuldoon@redhat.com
Fri Mar 27 19:08:00 GMT 2009
Pedro Alves wrote:
> On Friday 27 March 2009 17:50:39, Tom Tromey wrote:
>
>> 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).
>>
>
> Okay, I was concerned if the pretty printer for Base would
> access Y::x instead of Base::x
It is a printer for Base, but that does not mean it will print out the
Base values. Take this example:
class Base : public std::tr1::unordered_map<int, char *>
{
public:
std::tr1::unordered_map<int, char *> map;
Base ()
{
map[1]="Base";
}
};
class Derived : public Base
{
public:
std::tr1::unordered_map<int, char *> map;
Derived ()
{
map[1]="Derived";
}
};
If you instantiate Derived and print it with the patch, you will get:
(pg-gdb) python import gdb.libstdcxx.v6.printers
(pg-gdb) p derived
$2 = {
<Base> = std::tr1::unordered_map with 0 elements,
members of Derived:
map = std::tr1::unordered_map with 1 elements = {
[1] = 0x403952 "Derived"
}
}
Regards
Phil
Phil
More information about the Archer
mailing list