Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make dumpObjectInfo to print debug info?

Tags:

c++

qt

I'd like to print dump of object information with dumpObjectInfo function but nothing is printed.

There is a following C++ program which uses Qt:

$ cat main1.cpp
#include <QObject>
#include <QString>
#include <QDebug>
#include "a.h"

int main() {
    A a;
    B b;
    QObject::connect(&b, SIGNAL(sendText(QString)), &a, SLOT(printText(QString)));
    b.sendSignal();
    qDebug() << "print object dump";
    a.dumpObjectInfo();
    return 0;
}

There is a following .pro file (there is set debug mode in CONFIG):

$ cat qt.pro
######################################################################
# Automatically generated by qmake (2.01a) Tue Aug 28 17:41:22 2012
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += . 

# Input
CONFIG += debug
HEADERS += a.h
SOURCES += main1.cpp 

Compilation:

$ qmake qt.pro && make clean && make
rm -f moc_a.cpp
rm -f main1.o moc_a.o
rm -f *~ core *.core
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main1.o main1.cpp
/usr/bin/moc-qt4 -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. a.h -o moc_a.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o moc_a.o moc_a.cpp
g++  -o qt main1.o moc_a.o    -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread 
{ test -n "" && DESTDIR="" || DESTDIR=.; } && test $(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 'qt' && test -f qt.gdb-index && objcopy --add-section '.gdb_index=qt.gdb-index' --set-section-flags '.gdb_index=readonly' 'qt' 'qt' && rm -f qt.gdb-index || true

Run of program:

$ ./qt
Signal text!

print object dump 
$

dumpObjectInfo doesn't print anything altough debug mode is set in .pro file. How to make function dumpObjectInfo to print object information?

like image 224
scdmb Avatar asked Aug 28 '12 16:08

scdmb


1 Answers

This is to be expected if the Qt library itself has not been compiled in debug mode. The doc says:

This function is useful for debugging, but does nothing if the library has been compiled in release mode (i.e. without debugging information).

To make this work, you may self-compile Qt from source instead of (or in addition to) using the precompiled packages.

like image 183
Daniel Vérité Avatar answered Nov 11 '22 23:11

Daniel Vérité