public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* automated cast to different data type possible?
@ 2011-05-11  9:09 Klaus Rudolph
  2011-05-11 21:00 ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Klaus Rudolph @ 2011-05-11  9:09 UTC (permalink / raw)
  To: gdb

Hi all,

I have the following data structures:

class Base
{
enum Type
{
TYPE_A,
TYPE_B,
...
} type;

public:
  Base(Type _type):type(_type){}
 };

class A: pubic Base {

   int x;
   int y;
   ptr ...

public:
   A():Base(TYPE_A){}

};

class B: public Base {
   B():Base(TYPE_B){}
   double a;
   double b;
   int c;
   ptr ...
   ptr ...
};

Base* ptr1=new A;
Base* ptr2=new B;

---------

Now I want to debug ptr1. print returns only the output for base. OK
But I want to see, the type is a object of class A.
Writing a pretty printer for Base is possible and could output
as a type of A or B which works fine.

BUT! and that is the my question:
The pretty printer only give an output which "looks like" a type of A or B.
In combination with ddd I am not able to dereference the ptr pointers in A or B, because the object of type Base contains no ptr element!

On command line:
graph display ptr1;
<double click on ptr1> -> 
graph display *ptr1
a new window in graph view is visible with type Base
if I have a pretty printer inserted, I get a output which looks like
an object of class A.
But: if I now do a <double click> on the ptr elements, I got:
no element ptr... in Base.

Is there any chance to handle that kind of automatism in a python script?
To make the classes virtual is no solution, the data structure is fixed and used for persistent storage.

Thanks
 Klaus









-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-05-24 13:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-11  9:09 automated cast to different data type possible? Klaus Rudolph
2011-05-11 21:00 ` Tom Tromey
2011-05-12  6:17   ` Klaus Rudolph
2011-05-12 16:06     ` Tom Tromey
2011-05-12 17:13       ` André Pönitz
2011-05-15 14:17         ` Klaus Rudolph
2011-05-16 11:43           ` André Pönitz
2011-05-16 17:15             ` Klaus Rudolph
2011-05-24 13:48               ` André Pönitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).