Problems with gdb pretty-printers

Victor Vicente de Carvalho victor.v.carvalho at gmail.com
Thu May 13 18:01:08 UTC 2010


Hi all,

I've made a pretty printer for some objects that we use here on my work, and
one of them is giving me a headache: It's just a wrapper for
boost::any, witch can store a bunch of basic types and a std::list and a
std::string. The problem is that my printer is doing everything fine, ie
making the correct casts, and on gdb in console mode everything is showed
as suspected. On KDevelop, in other hand, the std::list and std::string is
not being recognized, and it's being printed in old style. But passing over
a normal string shows up normally.

Here is the printer:

class AnyPrinter:
    "Print a Any"
    def __init__(self, val):
        self.val = val

    def to_string(self):
        wich = '%d' % self.val['m_any']['which_']

        if wich == '0':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('int'))
        elif wich == '1':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('char'))
        elif wich == '2':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('double'))
        elif wich == '3':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('std::list<Communication::Detail::GenericBean,
std::allocator<Communication::Detail::GenericBean> >'))
        elif wich == '4':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('bool'))
        elif wich == '5':
            return
self.val['m_any']['storage_']['data_'].cast(gdb.lookup_type('std::string'))

        return "Any"

Printing an Any on gdb witch contains strings returns a nicely formated
output. On KDevelop, it's show as it wasn't recognized.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100513/779becb5/attachment.html>


More information about the KDevelop-devel mailing list