pr9065 patch

Chris Moller cmoller@redhat.com
Tue Mar 9 20:38:00 GMT 2010


This is the typeid thing.

This patch implements typeid in gdb, letting users do things like

    p typeid(<expression>)
    p typeid(<expression>).name()
    p typeid(<expression>).__name
    p typeid(<expression>).__is_pointer_()

and the same thing for types (i.e., p typeid(<type>).name())

FWIW, you can even do stuff like

    set tp = typeid(<expression>).name()

(assuming there's a "char *tp;" in your source...)

There are some differences, though, between the gdb typeid and the c++ 
typeid, the biggest is that the gdb version only partially implements 
the type_info class: it doesn't actually implement the methods, it just 
fakes them, and even though you can assign things like "set tp = 
typeid(<expression>).name()" you can't assign "set ti = 
typeid(<expression>)" where "type_info *ti;"

Another difference is that the real typeid returns mangled names, 
leaving it to the user to demangle.  This strikes me as a pain, so I 
just provide the demangled names.

The attached patch works as advertised--see pr9065.exp for more 
details--but I haven't done a full regression yet.

Feedback welcome,
Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr9065.patch
Type: text/x-patch
Size: 17771 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20100309/694092a9/attachment.bin>


More information about the Gdb-patches mailing list