Commit 2721eb23 authored by ck's avatar ck
Browse files

Debugger: Added auto test to stay in sync with QObjectPrivate.

The compile-time solution introduced by 3a084ae8
was felt by some to be too intrusive, so I've integrated the check for
changes to QObjectPrivate into the auto test.
parent 90e7bac4
......@@ -62,7 +62,7 @@
#include <QtCore/QWeakPointer>
#endif
#include <QtCore/private/qobject_p.h>
#include "gdbmacros_p.h"
int qtGhVersion = QT_VERSION;
......@@ -174,76 +174,9 @@ int qtGhVersion = QT_VERSION;
QT_BEGIN_NAMESPACE
#endif
struct Sender { QObject *sender; int signal; int ref; };
const char *stdStringTypeC = "std::basic_string<char,std::char_traits<char>,std::allocator<char> >";
const char *stdWideStringTypeUShortC = "std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >";
#if QT_VERSION < 0x040600
struct Connection
{
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
};
typedef QList<Connection> ConnectionList;
typedef QList<Sender> SenderList;
const Connection &connectionAt(const ConnectionList &l, int i) { return l.at(i); }
const QObject *senderAt(const SenderList &l, int i) { return l.at(i).sender; }
int signalAt(const SenderList &l, int i) { return l.at(i).signal; }
#endif
#if QT_VERSION >= 0x040600
struct Connection
{
QObject *sender;
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
//senders linked list
Connection *next;
Connection **prev;
};
typedef QList<Connection *> ConnectionList;
typedef Connection *SenderList;
const Connection &connectionAt(const ConnectionList &l, int i) { return *l.at(i); }
#endif
class ObjectPrivate : public QObjectData
{
public:
ObjectPrivate() {}
virtual ~ObjectPrivate() {}
QList<QObject *> pendingChildInsertedEvents;
void *threadData;
void *currentSender;
void *currentChildBeingDeleted;
QList<QPointer<QObject> > eventFilters;
void *extraData;
#if QT_VERSION >= 0x040600
mutable quint32 connectedSignals[2];
#else
mutable quint32 connectedSignals;
#endif
QString objectName;
void *connectionLists;
SenderList senders;
int *deleteWatch;
#if QT_VERSION >= 0x040600
void *objectGuards;
#endif
};
#if defined(QT_BEGIN_NAMESPACE)
QT_END_NAMESPACE
#endif
......@@ -266,9 +199,6 @@ QT_END_NAMESPACE
namespace {
// Causes a compile error if QObjectPrivate goes out of sync.
int sanityCheck[(sizeof(ObjectPrivate) == sizeof(QObjectPrivate)) - 1];
static QByteArray strPtrConst = "* const";
static bool isPointerType(const QByteArray &type)
......
TEMPLATE = lib
CONFIG += shared
linux-* {
CONFIG -= release
CONFIG += debug
linux-* {
CONFIG -= release
CONFIG += debug
}
SOURCES=gdbmacros.cpp
false {
SOURCES = gdbmacros.cpp
false {
DEFINES += USE_QT_GUI=0
QT = core
} else {
DEFINES += USE_QT_GUI=1
QT = core gui
}
exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h) {
DEFINES+=HAS_QOBJECT_P_H
else {
DEFINES += USE_QT_GUI=1
QT = core \
gui
}
exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h):DEFINES += HAS_QOBJECT_P_H
HEADERS += gdbmacros_p.h
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef GDBMACROS_P_H
#define GDBMACROS_P_H
#include <QtCore/QObject>
#include <QtCore/private/qobject_p.h>
#if defined(QT_BEGIN_NAMESPACE)
QT_BEGIN_NAMESPACE
#endif
struct Sender { QObject *sender; int signal; int ref; };
#if QT_VERSION < 0x040600
struct Connection
{
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
};
typedef QList<Connection> ConnectionList;
typedef QList<Sender> SenderList;
static inline const Connection &connectionAt(const ConnectionList &l, int i) { return l.at(i); }
static inline const QObject *senderAt(const SenderList &l, int i) { return l.at(i).sender; }
static inline int signalAt(const SenderList &l, int i) { return l.at(i).signal; }
#else
struct Connection
{
QObject *sender;
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
//senders linked list
Connection *next;
Connection **prev;
};
typedef QList<Connection *> ConnectionList;
typedef Connection *SenderList;
static inline const Connection &connectionAt(const ConnectionList &l, int i) { return *l.at(i); }
#endif
class ObjectPrivate : public QObjectData
{
public:
ObjectPrivate() {}
virtual ~ObjectPrivate() {}
QList<QObject *> pendingChildInsertedEvents;
void *threadData;
void *currentSender;
void *currentChildBeingDeleted;
QList<QPointer<QObject> > eventFilters;
void *extraData;
#if QT_VERSION >= 0x040600
mutable quint32 connectedSignals[2];
#else
mutable quint32 connectedSignals;
#endif
QString objectName;
void *connectionLists;
SenderList senders;
int *deleteWatch;
#if QT_VERSION >= 0x040600
void *objectGuards;
#endif
};
#if defined(QT_BEGIN_NAMESPACE)
QT_END_NAMESPACE
#endif
#endif // GDBMACROS_P_H
......@@ -19,13 +19,12 @@
#include <QtGui/QStringListModel>
#include <QtTest/QtTest>
#include <QtCore/private/qobject_p.h>
//#include <QtTest/qtest_gui.h>
#include "gdb/gdbmi.h"
#include "tcf/json.h"
#include "gdbmacros.h"
#include "gdbmacros_p.h"
#undef NS
......@@ -173,6 +172,7 @@ private slots:
void dumpQVariant_QString();
void dumpQVariant_QStringList();
void dumpStdVector();
void initTestCase();
public slots:
void runQtc();
......@@ -204,7 +204,7 @@ private:
void dumpQPixmapHelper(QPixmap &p);
#if QT_VERSION >= 0x040500
template <typename T>
void dumpQSharedPointerHelper(QSharedPointer<T> &ptr, bool isSimple);
void dumpQSharedPointerHelper(QSharedPointer<T> &ptr);
#endif
void dumpQTextCodecHelper(QTextCodec *codec);
};
......@@ -1729,15 +1729,11 @@ void tst_Debugger::dumpQPixmap()
#if QT_VERSION >= 0x040500
template<typename T>
void tst_Debugger::dumpQSharedPointerHelper(QSharedPointer<T> &ptr, bool isSimple)
void tst_Debugger::dumpQSharedPointerHelper(QSharedPointer<T> &ptr)
{
// TODO: This works only for integer types at the moment.
#if 0
QByteArray expected("value = '");
QString val;
if (isSimple) {
val = QString::number(*ptr.data());
expected.append(val);
}
QString val = ptr.isNull() ? "<null>" : valToString(*ptr.data());
QAtomicInt *weakAddr;
QAtomicInt *strongAddr;
int weakValue;
......@@ -1760,12 +1756,16 @@ void tst_Debugger::dumpQSharedPointerHelper(QSharedPointer<T> &ptr, bool isSimpl
append("{name='strongref',value='").append(QString::number(strongValue)).
append("',type='int',addr='").append(ptrToBa(strongAddr)).append("',numchild='0'}]");
testDumper(expected, &ptr, NS"QSharedPointer", true);
#endif
}
void tst_Debugger::dumpQSharedPointer()
{
QSharedPointer<int> ptr(new int(99));
// dumpQSharedPointerHelper(ptr, 1, 0, true);
QSharedPointer<int> ptr;
dumpQSharedPointerHelper(ptr);
QSharedPointer<int> ptr2(new int(99));
dumpQSharedPointerHelper(ptr2);
}
#endif
......@@ -1862,6 +1862,11 @@ void tst_Debugger::dumpQTextCodec()
// Creator
//
void tst_Debugger::initTestCase()
{
QVERIFY(sizeof(QObjectPrivate) == sizeof(ObjectPrivate));
}
void tst_Debugger::readStandardOutput()
{
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment