This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: casting in gdb


David,

For ObjC, where getting to the real data of an object is sometimes highly non-trivial, we used method calls in the inferior. We insert a shared library into the inferior process when we launch it. This shared library has functions that produce a user-friendly view of the object passed to them and stuff it somewhere in inferior memory. Then a client (PB in our case) can read out this memory and show that to the user.

However, for STL classes the job is a little easier, since you can mostly get what you want from presenting various members of the class (or one of its sub-classes), perhaps with appropriate casts. For this case, we were planning to do something more like what Visual Studio or CodeWarrior do. Both of these allow users to associate some custom printing description with a given type. CW & VS use an XML description file giving what members to print - and what cast operation to apply to the members - for a given C++ type. This is faster than the ObjC method, since it does not involve inferior function calls, so where it is possible to use something like this it is preferable.

We haven't gotten past the investigation of what CW & VC++ do, and I am not sure yet whether we will implement this in gdb, or let PB drive. So what we end up doing may or may not be interesting to the gdb community. PB already has an XML parser, and the facilities to manage this sort of thing, so it is more natural for us to do it there.

Jim


On Thursday, January 16, 2003, at 04:54 AM, gdb-digest-help@sources.redhat.com wrote:

On Sat, 14 Dec 2002 23:47:42 -0600, Michael Elizabeth Chastain <mec@shout.net> said:

I'm playing with the idea that gdb should know more about the C++
standard library types, in the same spirit that gdb knows that a C
"char *" usually points to a string terminated with '\0'.  I would
like gdb to understood more about std::string, std::vector, std:map,
and so on.
I was going through my old messages, and I noticed this one.  For what
it's worth, Apple has implemented something like this for strings in
Objective C, where they actually print out the string in question, and
they say it works pretty well.  Apparently the implementation of
strings is complicated enough that they really didn't want to tie it
to the implementation; so GDB prints out Objective C strings by
actually doing the method call.

Of course, the above message was part of a thread that noted that, in
C++, the appropriate methods might not be compiled in.  That's a real
problem; I'm not sure what to do about that.

David Carlton
carlton@math.stanford.edu

--
Jim Ingham                                   jingham@apple.com
Developer Tools
Apple Computer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]