[Interest] debugging: how to get meaningful QObject information in a command line session

Alejandro Exojo suy at badopi.org
Wed May 27 23:43:00 CEST 2015


El Tuesday 26 May 2015, René J.V. Bertin escribió:
> I have looked some more, haven't found anything in the Ubuntu repository. I
> presume that the debugger plugin (or however it was called) that can be
> installed through Qt Creator's toolchain preferences is strictly for use
> with that IDE?

I don't know about name the distro packagers chose, but see in the 
installation of the Qt SDK, in: path-to-
qt/Tools/QtCreator/share/qtcreator/debugger/ There is a README file with 
explanations on how to use those debugging helpers. I'm attaching it for 
convenience. Use apt-file search creatortypes.py for locating the name of the 
package in Ubuntu. In Debian is qtcreator-data, and you'll find it in 
/usr/share/qtcreator/debugger/.

HTH.

-- 
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net
-------------- next part --------------

While the primary intention of this pretty printing implementation is
to provide what Qt Creator needs, it can be used in a plain commandline
GDB session, too.

With

        python sys.path.insert(1, '<path/to/qtcreator>/share/qtcreator/debugger/')
        python from gdbbridge import *

in .gdbinit there is a new "GDB command", called "pp".

With code like

        int main(int argc, char *argv[])
        {
            QString ss = "Hello";
            QApplication app(argc, argv);
            app.setObjectName(ss);
            // break here
        }

    the "pp" command can be used as follows:

    (gdb) pp app
    app =
       [
          <QGuiApplication> = {"Hello"}
          staticMetaObject = <QMetaObject> = {""}
          [parent] = <QObject *> = {"0x0"}
          [children] = <QObjectList> = {"<3 items>"}
          [properties] = "<>0 items>"
          [methods] = "<6 items>"
          [signals] = "<1 items>"
       ],<QApplication> = {"Hello"}

    (gdb) pp app [properties],[children]
    app =
       [
          <QGuiApplication> = {"Hello"}
          staticMetaObject = <QMetaObject> = {""}
          [parent] = <QObject *> = {"0x0"}
          [children] = [
             <QObject> = {""}
             <QObject> = {""}
             <QObject> = {"fusion"}
          ],<QObjectList> = {"<3 items>"}
          [properties] = [
             windowIcon = <QVariant (QIcon)> = {""}
             cursorFlashTime = <QVariant (int)> = {"1000"}
             doubleClickInterval = <QVariant (int)> = {"400"}
             keyboardInputInterval = <QVariant (int)> = {"400"}
             wheelScrollLines = <QVariant (int)> = {"3"}
             globalStrut = <QVariant (QSize)> = {"(0, 0)"}
             startDragTime = <QVariant (int)> = {"500"}
             startDragDistance = <QVariant (int)> = {"10"}
             styleSheet = <QVariant (QString)> = {""}
             autoSipEnabled = <QVariant (bool)> = {"true"}
          ],"<10 items>"
          [methods] = "<6 items>"
          [signals] = "<1 items>"
       ],<QApplication> = {"Hello"}

    (gdb) pp ss
    ss =
       <QString> = {"Hello"}




More information about the Interest mailing list