From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12567 invoked by alias); 27 Sep 2009 12:22:00 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 12519 invoked by uid 22791); 27 Sep 2009 12:21:57 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Date: Sun, 27 Sep 2009 12:22:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: Dragos Tatulea , keiths@redhat.com, archer@sourceware.org, cmoller@redhat.com Subject: set print objct pros/cons [Re: [Keith Seitz] Re: [tools-team] Status 2008-09-01] Message-ID: <20090927122147.GA15789@host0.dyn.jankratochvil.net> References: <6d1764b50909230708l60a4be26ocf3bf6aef198710@mail.gmail.com> <6d1764b50909251238i6471fcacreea5cfbab57cdd2d@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) X-SW-Source: 2009-q3/txt/msg00257.txt.bz2 --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1269 Hi, just found out `set print object on' is not such a clear win: (gdb) b 27 Breakpoint 1 at 0x40069b: file cxxinherit.C, line 27. (gdb) r Starting program: /home/jkratoch/t/cxxinherit derived::m base::m Breakpoint 1, main () at cxxinherit.C:27 27 return 0; (gdb) show print object Printing of object's derived type based on vtable info is off. (gdb) p derivedp->m $1 = {void (Derived *)} 0x4006c4 (gdb) p basep->m $2 = {void (Base *)} 0x4006a2 (gdb) call derivedp->m () derived::m (gdb) call basep->m () base::m (gdb) set print object on (gdb) p derivedp->m $3 = {void (Derived *)} 0x4006c4 (gdb) p basep->m $4 = {void (Derived *)} 0x4006c4 (gdb) call derivedp->m () derived::m (gdb) call basep->m () base::m (1) Last "call basep->m ()" should have printed "derived::m" because "p basep->m" prints "Derived::m()", shouldn't it? (2) A lookup can succeed in both "off" and "on" cases with different results. One should fix (1) as it looks just as a bug to me. Afterwards for (2) maybe any C++ print should be evaluated both ways and if the resulting `struct value' differs it should print both values with a warning? ("any C++ print" could be optimized somehow, not the point here.) Thanks, Jan --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="cxxinherit.C" Content-length: 396 #include class Base { public: void m () { puts ("base::m"); } virtual void stub () {} }; class Derived : public Base { public: virtual void m () { puts ("derived::m"); } virtual void stub () {} }; int main () { Derived derived_local; Derived *derivedp = &derived_local; Base *basep = &derived_local; derivedp->m (); basep->m (); return 0; } --uAKRQypu60I7Lcqm--