This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: automated cast to different data type possible?
On Monday 16 May 2011 19:18:35 ext Klaus Rudolph wrote:
> André Pönitz schrieb:
>
> >> please give me an idea who is calling qdump_KRBase and what is parameter
> >> d? I actually have no idea how to add that to the printer script... or
> >> maybe any other python script to gdb.
> >
> > The code would be called from a Python script that creates the full
> > display for an local variable including all expanded children in one go.
>
> Is there any interface defined for that purpose? Or you think that I
> should create a new gdb command? If I handle that from a new gdb
> command, there is really no problem, but that fits not in the
> integration to ddd without changing sources of it.
The necessary basic interface is gdb's python module, i.e.
http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html#Python-API
The script on top of that would be something similar to
https://qt.gitorious.org/qt-creator/qt-creator/blobs/master/share/qtcreator/gdbmacros/dumper.py
This also contains definitions of convenience functions that uses that scheme.
Some example pretty-printer implementations using that scheme are in
https://qt.gitorious.org/qt-creator/qt-creator/blobs/master/share/qtcreator/gdbmacros/gdbmacros.py
The qdump__KRBase() function I mentioned is currently at the end of that file.
The main script produces gdb/MI-style output. I am not sure whether ddd
can digest that, if not, producing "human readable" output by "fixing" the
put*() methods in the Dumper class should be straightforward.
> > 'd' is an object that accumulates output that's finally 'printed', and
> > takes care of properly closing nested items in case of exceptions.
>
> Is there any description which can handle such idea? Maybe you already
> have such a solution finsihed?
I have, Qt Creator uses this approach. There are some hints on what it does
and how it works (I wouldn't call it "documentation", though) at
http://doc.qt.nokia.com/qtcreator-snapshot/creator-debugging-helpers.html
> Maybe there is also an official one but not known by me?
I don't think so.
Regards,
Andre'