From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8850 invoked by alias); 27 Mar 2009 19:08:58 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 8840 invoked by uid 22791); 27 Mar 2009 19:08:58 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <49CD23C5.1000605@redhat.com> Date: Fri, 27 Mar 2009 19:08:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Pedro Alves CC: archer@sourceware.org, Tom Tromey Subject: Re: [python][rfc] Attempt to print the base class if a there is no Python pretty-printer for a derived class. References: <49CD0730.8070000@redhat.com> <200903271743.11238.alves.ped@gmail.com> <200903271805.09768.pedro@codesourcery.com> In-Reply-To: <200903271805.09768.pedro@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2009-q1/txt/msg00434.txt.bz2 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 { public: std::tr1::unordered_map map; Base () { map[1]="Base"; } }; class Derived : public Base { public: std::tr1::unordered_map 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 = { = std::tr1::unordered_map with 0 elements, members of Derived: map = std::tr1::unordered_map with 1 elements = { [1] = 0x403952 "Derived" } } Regards Phil Phil