This is a very early version of a patch I'm working on for http://sourceware.org/bugzilla/show_bug.cgi?id=9065 to provide a typeid capability in gdb. It's nowhere near done, but I'd like to put it out there in case anyone objects wildly to what I'm doing or how I'm doing it. What it does: If you have some code from the source: #include #include using namespace std; struct A { virtual ~A() { } }; struct B : A { }; struct C { }; struct D : C { }; int main() { B bobj; A* ap = &bobj; A& ar = bobj; cout << "ap: " << typeid(*ap).name() << endl; cout << "ar: " << typeid(ar).name() << endl; D dobj; C* cp = &dobj; C& cr = dobj; cout << "cp: " << typeid(*cp).name() << endl; cout << "cr: " << typeid(cr).name() << endl; } this patch will let you do stuff like: (gdb) p typeid(dobj) $1 = "D" (gdb) p typeid(dobj).name() $2 = "D" (gdb) p typeid(*ap).name() $3 = "A" (gdb) In C++, typeid returns a reference to a class type_info, which contains a member ".name()." Just for consistency with that, I've made this implementation accept both a complete C++-like form of typeid().name(), or the abbreviated form of typeid(). [Question: Internally, this patch is based on "sizeof" which actually creates an int type that, in addition to just being printed, can be used for stuff like "set = sizeof()". The gdb typeid doesn't even try to create an analogue to a type_info class, it just extracts the name from the appropriate type struct and creates a cstring type from it. Would it be good/essential for the implementation to instantiate a real type_info class? (That, I suspect, will be a lot more work...)] Anyway, feedback welcome. Chris