Xref: utzoo comp.object:2445 comp.lang.pascal:5267 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!bellcore!bytor From: bytor@ctt.bellcore.com (Ross Huitt) Newsgroups: comp.object,comp.lang.pascal Subject: Re: Shouldn't debuggers be able to debug dynamic objects? Message-ID: <1991Jan28.151241.25449@bellcore.bellcore.com> Date: 28 Jan 91 15:12:41 GMT References: <1991Jan24.152256.24273@resam.dk> <1991Jan25.145947.16431@bellcore.bellcore.com> <1991Jan28.100213.1822@resam.dk> Sender: usenet@bellcore.bellcore.com (Poster of News) Distribution: comp Organization: Computer Technology Transfer, Bellcore Lines: 39 In article <1991Jan28.100213.1822@resam.dk> andrew@resam.dk (Leif Andrew Rump) writes: >In <1991Jan25.145947.16431@bellcore.bellcore.com> bytor@ctt.bellcore.com (Ross Huitt) writes: > >>When I _know_ which derived class a base class ptr is pointing to >>and I want to inspect or display the object as a derived class, a cast >>is usually sufficient to get the job done. > >But, but, but, ... Why can't the debugger that has _all_ the information >do this job! The main reason for me to write this letter was that one >of my programmes used a dynamic list of objects and if I was going to >use the debugger to show me the content of for example the first three >objects in a list a had to remember what type each object was and change >casts accordingly - then (as I wrote in my original letter) I surely >sill make mistakes and then the debugger only caused havoc!!! > >Leif Andrew > >UUCP: andrew@resam.dk, phone: +45 32 32 51 54 \ >> > Read oe as: o / (slash) and OE as O / (slash) < < The debugger does not necessarily have _all_ of the information for objects that are dyanmically allocated. If a derived object is later referenced by a base pointer the only piece of information I can think of that a debugger could use to determine the compile-time type of would be the pointer to the virtual function table. If the classes involved don't have a virtuals then even this won't work. (I know there are other cases, too, so don't bother flaming me.) To accomplish what you want would require support from the compiler such as embedding a class signature in each instance of a class. The debugger would then read this signature to determine the class of the object regardless of the class of the pointer. This level of meta-class support would be very welcome especially if we programmers had access to it. Its one aspect of Smalltalk that I miss very much in C++. BTW, there are programming techniques that you can use to determine the classes of your objects at run time. You would still have to use casts in the debugger, but at least you could execute a member function to determine the class of the object before you used a cast. -bytor@ctt.bellcore.com