c++/2152: set print object on does not work

Daniel Jacobowitz drow@false.org
Fri Aug 4 14:48:00 GMT 2006


The following reply was made to PR c++/2152; it has been noted by GNATS.

From: Daniel Jacobowitz <drow@false.org>
To: cbarbe@obj-sys.com
Cc: gdb-gnats@sources.redhat.com, christophe@cattlegrid.net
Subject: Re: c++/2152: set print object on does not work
Date: Fri, 4 Aug 2006 10:41:03 -0400

 On Fri, Aug 04, 2006 at 02:22:34PM -0000, cbarbe@obj-sys.com wrote:
 > "set print object on" does not work. See below gdb session running the attached test case. 
 
 This is, actually, not a bug.  However, the documentation could be
 clearer.  GDB can only use RTTI type information when it is available;
 in this example, it is not.
 
 Not every type has RTTI.  It's only emitted for types which need it,
 for instance types with virtual functions.  In general, if there's no
 way to get different behavior from an A* because it's really a B*, then
 there's no way to determine the runtime type.
 
 Take a look at this:
 
 (gdb) ptype A
 type = class A {
   public:
     int a1;
   protected:
     int a2;
 
   public:
     A(void);
 }
 (gdb) p sizeof(A)
 $3 = 8
 
 No extra data in the object, so there's nowhere to stash an RTTI
 pointer.
 
 
 -- 
 Daniel Jacobowitz
 CodeSourcery



More information about the Gdb-prs mailing list