2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef DEBUGGER_WATCHHANDLER_H
|
|
|
|
|
#define DEBUGGER_WATCHHANDLER_H
|
|
|
|
|
|
2010-04-26 18:54:08 +02:00
|
|
|
#include "watchdata.h"
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QPointer>
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
#include <QtCore/QSet>
|
2009-12-09 16:27:34 +01:00
|
|
|
#include <QtCore/QAbstractItemModel>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtScript/QScriptValue>
|
|
|
|
|
|
2009-08-12 11:21:44 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QDebug;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Debugger {
|
2009-10-01 18:01:23 +02:00
|
|
|
|
|
|
|
|
class DebuggerManager;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
class WatchItem;
|
2009-06-17 16:00:03 +02:00
|
|
|
class WatchHandler;
|
2010-05-19 12:00:01 +02:00
|
|
|
enum WatchType { ReturnWatch, LocalsWatch, WatchersWatch, TooltipsWatch };
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2009-06-24 12:31:09 +02:00
|
|
|
enum WatchRoles
|
|
|
|
|
{
|
|
|
|
|
INameRole = Qt::UserRole,
|
|
|
|
|
ExpressionRole,
|
2010-03-12 11:14:50 +01:00
|
|
|
ExpandedRole, // Used to communicate preferred expanded state to the view.
|
2009-07-03 11:20:47 +02:00
|
|
|
TypeFormatListRole,
|
2010-03-12 11:14:50 +01:00
|
|
|
TypeFormatRole, // Used to communicate alternative formats to the view.
|
2009-08-12 10:51:25 +02:00
|
|
|
IndividualFormatRole,
|
2010-05-19 15:36:23 +02:00
|
|
|
AddressRole, // Address of the object.
|
2009-06-24 12:31:09 +02:00
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-06 10:44:08 +02:00
|
|
|
enum IntegerFormat
|
|
|
|
|
{
|
2010-03-12 11:14:50 +01:00
|
|
|
DecimalFormat = 0, // Keep that at 0 as default.
|
2009-07-06 10:44:08 +02:00
|
|
|
HexadecimalFormat,
|
|
|
|
|
BinaryFormat,
|
|
|
|
|
OctalFormat,
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
class WatchModel : public QAbstractItemModel
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2009-07-10 14:36:28 +02:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
private:
|
|
|
|
|
explicit WatchModel(WatchHandler *handler, WatchType type);
|
2009-11-04 17:11:35 +01:00
|
|
|
virtual ~WatchModel();
|
2009-07-13 09:11:07 +02:00
|
|
|
|
2010-03-22 13:41:10 +01:00
|
|
|
public:
|
|
|
|
|
int rowCount(const QModelIndex &idx) const;
|
|
|
|
|
int columnCount(const QModelIndex &idx) const;
|
|
|
|
|
|
|
|
|
|
private:
|
2009-07-13 09:11:07 +02:00
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
|
|
|
QModelIndex index(int, int, const QModelIndex &idx) const;
|
|
|
|
|
QModelIndex parent(const QModelIndex &idx) const;
|
|
|
|
|
bool hasChildren(const QModelIndex &idx) const;
|
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &idx) const;
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
bool canFetchMore(const QModelIndex &parent) const;
|
|
|
|
|
void fetchMore(const QModelIndex &parent);
|
|
|
|
|
|
|
|
|
|
friend class WatchHandler;
|
|
|
|
|
friend class GdbEngine;
|
2009-06-24 12:31:09 +02:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
WatchItem *watchItem(const QModelIndex &) const;
|
|
|
|
|
QModelIndex watchIndex(const WatchItem *needle) const;
|
|
|
|
|
QModelIndex watchIndexHelper(const WatchItem *needle,
|
|
|
|
|
const WatchItem *parentItem, const QModelIndex &parentIndex) const;
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void insertData(const WatchData &data);
|
2009-07-13 12:28:47 +02:00
|
|
|
void insertBulkData(const QList<WatchData> &data);
|
2010-01-05 16:51:55 +01:00
|
|
|
WatchItem *findItem(const QByteArray &iname, WatchItem *root) const;
|
2009-06-17 16:00:03 +02:00
|
|
|
void reinitialize();
|
2009-07-13 09:11:07 +02:00
|
|
|
void removeOutdated();
|
|
|
|
|
void removeOutdatedHelper(WatchItem *item);
|
2009-07-13 11:25:05 +02:00
|
|
|
WatchItem *rootItem() const;
|
2009-11-04 17:11:35 +01:00
|
|
|
void destroyItem(WatchItem *item);
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void emitDataChanged(int column,
|
|
|
|
|
const QModelIndex &parentIndex = QModelIndex());
|
2010-03-09 17:37:36 +01:00
|
|
|
void beginCycle(); // Called at begin of updateLocals() cycle.
|
|
|
|
|
void endCycle(); // Called after all results have been received.
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2009-08-12 11:21:44 +02:00
|
|
|
friend QDebug operator<<(QDebug d, const WatchModel &m);
|
2009-08-31 09:14:04 +02:00
|
|
|
|
|
|
|
|
void dump();
|
|
|
|
|
void dumpHelper(WatchItem *item);
|
2009-11-25 08:35:02 +01:00
|
|
|
void emitAllChanged();
|
|
|
|
|
|
2009-08-31 09:14:04 +02:00
|
|
|
signals:
|
|
|
|
|
void enableUpdates(bool);
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
private:
|
2009-11-25 08:35:02 +01:00
|
|
|
QString niceType(const QString &typeIn) const;
|
2010-03-11 18:55:52 +01:00
|
|
|
void formatRequests(QByteArray *out, const WatchItem *item) const;
|
2009-11-25 08:35:02 +01:00
|
|
|
|
2009-07-10 14:36:28 +02:00
|
|
|
WatchHandler *m_handler;
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchType m_type;
|
|
|
|
|
WatchItem *m_root;
|
2010-01-05 16:51:55 +01:00
|
|
|
QSet<QByteArray> m_fetchTriggered;
|
2009-06-17 16:00:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WatchHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2009-10-01 18:01:23 +02:00
|
|
|
explicit WatchHandler(DebuggerManager *manager);
|
2009-06-17 16:00:03 +02:00
|
|
|
WatchModel *model(WatchType type) const;
|
2010-01-05 16:51:55 +01:00
|
|
|
WatchModel *modelForIName(const QByteArray &iname) const;
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void cleanup();
|
2010-03-09 17:37:36 +01:00
|
|
|
Q_SLOT void watchExpression(); // Data passed in action->data().toString()
|
2009-03-19 09:32:09 +01:00
|
|
|
Q_SLOT void watchExpression(const QString &exp);
|
2009-03-19 12:53:58 +01:00
|
|
|
Q_SLOT void removeWatchExpression();
|
2009-03-19 09:32:09 +01:00
|
|
|
Q_SLOT void removeWatchExpression(const QString &exp);
|
2009-11-25 08:35:02 +01:00
|
|
|
Q_SLOT void emitAllChanged();
|
2010-02-04 16:23:51 +01:00
|
|
|
|
2010-03-09 17:37:36 +01:00
|
|
|
void beginCycle(); // Called at begin of updateLocals() cycle
|
|
|
|
|
void updateWatchers(); // Called after locals are fetched
|
|
|
|
|
void endCycle(); // Called after all results have been received
|
2009-06-17 16:00:03 +02:00
|
|
|
void showEditValue(const WatchData &data);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void insertData(const WatchData &data);
|
2009-07-13 12:28:47 +02:00
|
|
|
void insertBulkData(const QList<WatchData> &data);
|
2010-01-05 16:51:55 +01:00
|
|
|
void removeData(const QByteArray &iname);
|
|
|
|
|
WatchData *findItem(const QByteArray &iname) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
void loadSessionData();
|
|
|
|
|
void saveSessionData();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-05 16:51:55 +01:00
|
|
|
bool isExpandedIName(const QByteArray &iname) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return m_expandedINames.contains(iname); }
|
2010-01-05 16:51:55 +01:00
|
|
|
QSet<QByteArray> expandedINames() const
|
2009-05-12 14:28:27 +02:00
|
|
|
{ return m_expandedINames; }
|
2009-12-04 13:22:39 +01:00
|
|
|
QStringList watchedExpressions() const;
|
2010-01-05 16:51:55 +01:00
|
|
|
QHash<QByteArray, int> watcherNames() const
|
2009-12-04 13:36:14 +01:00
|
|
|
{ return m_watcherNames; }
|
2010-04-27 08:53:18 +02:00
|
|
|
|
|
|
|
|
QByteArray expansionRequests() const;
|
|
|
|
|
QByteArray typeFormatRequests() const;
|
|
|
|
|
QByteArray individualFormatRequests() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-18 10:34:53 +02:00
|
|
|
static QString watcherEditPlaceHolder();
|
2010-03-11 18:55:52 +01:00
|
|
|
int format(const QByteArray &iname) const;
|
2009-06-18 10:34:53 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2009-07-13 09:11:07 +02:00
|
|
|
friend class WatchModel;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-17 17:43:01 +01:00
|
|
|
void loadWatchers();
|
|
|
|
|
void saveWatchers();
|
|
|
|
|
|
2009-07-03 11:20:47 +02:00
|
|
|
void loadTypeFormats();
|
|
|
|
|
void saveTypeFormats();
|
|
|
|
|
void setFormat(const QString &type, int format);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool m_expandPointers;
|
|
|
|
|
bool m_inChange;
|
|
|
|
|
|
2010-03-15 17:44:56 +01:00
|
|
|
// QWidgets and QProcesses taking care of special displays.
|
|
|
|
|
typedef QMap<QString, QPointer<QObject> > EditHandlers;
|
|
|
|
|
EditHandlers m_editHandlers;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-05 16:51:55 +01:00
|
|
|
QHash<QByteArray, int> m_watcherNames;
|
|
|
|
|
QByteArray watcherName(const QByteArray &exp);
|
2009-07-03 11:20:47 +02:00
|
|
|
QHash<QString, int> m_typeFormats;
|
2010-03-17 12:38:37 +01:00
|
|
|
QHash<QByteArray, int> m_individualFormats;
|
2010-03-15 17:44:56 +01:00
|
|
|
|
|
|
|
|
// Items expanded in the Locals & Watchers view.
|
|
|
|
|
QSet<QByteArray> m_expandedINames;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-19 12:00:01 +02:00
|
|
|
WatchModel *m_return;
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchModel *m_locals;
|
|
|
|
|
WatchModel *m_watchers;
|
|
|
|
|
WatchModel *m_tooltips;
|
2009-10-01 18:01:23 +02:00
|
|
|
DebuggerManager *m_manager;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_WATCHHANDLER_H
|