From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28633 invoked by alias); 11 May 2011 09:09:14 -0000 Received: (qmail 28623 invoked by uid 22791); 11 May 2011 09:09:13 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Wed, 11 May 2011 09:08:55 +0000 Received: (qmail 25982 invoked by uid 0); 11 May 2011 09:08:53 -0000 Received: from 199.64.72.252 by www185.gmx.net with HTTP; Wed, 11 May 2011 11:08:50 +0200 (CEST) Content-Type: text/plain; charset="utf-8" Date: Wed, 11 May 2011 09:09:00 -0000 From: "Klaus Rudolph" Message-ID: <20110511090850.28500@gmx.net> MIME-Version: 1.0 Subject: automated cast to different data type possible? To: gdb@sourceware.org Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00040.txt.bz2 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; -> 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 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