C++ Q on types
Andrew Cagney
ac131313@cygnus.com
Mon Jan 15 04:14:00 GMT 2001
Via RMS:
> A user (haberg@matematik.su.se) sent me this explanation of a feature
> in some other debuggers:
>
> C++ has makes available various runtime information (RTTI). C++ has a
> single one form of a polymorphic variable, or an object which can change
> its type at runtime, namely the polymorphic pointer: If one has a class A
> and derives from it a class B, then one can write
> A* ap = new B();
> The static type pointer to an A named ap now points to a dynamically
> allocated B pointer. It means that in the C++ static typing, this is just
> an ap pointer, but C++ has mechanism for keeping track of the dynamic
> type B, for example, via "virtual functions", or by using C++ RTTI...
>
> Now to the debugging: If the debugger only handles C++ static typing, it
> will show that ap is an A, and will only display that structure of it
> (the names in that class and their values).
>
> But if the debugger handles C++ dynamic data, it will show that the ap is
> actually a B, and will show that (the names in that class B and their
> values).
>
> Does GDB have the ability to determine the actual type
> of *ap, and display it accordingly?
Something for TODO?
More information about the Gdb
mailing list