2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 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
|
|
|
|
|
|
|
|
|
|
#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;
|
2009-07-13 09:11:07 +02:00
|
|
|
enum WatchType { LocalsWatch, WatchersWatch, TooltipsWatch };
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class WatchData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
WatchData();
|
|
|
|
|
|
|
|
|
|
enum State
|
|
|
|
|
{
|
|
|
|
|
Complete = 0,
|
2009-06-22 11:35:08 +02:00
|
|
|
HasChildrenNeeded = 1,
|
2008-12-02 12:01:29 +01:00
|
|
|
ValueNeeded = 2,
|
|
|
|
|
TypeNeeded = 4,
|
|
|
|
|
ChildrenNeeded = 8,
|
|
|
|
|
|
|
|
|
|
NeededMask = ValueNeeded
|
|
|
|
|
| TypeNeeded
|
|
|
|
|
| ChildrenNeeded
|
2009-06-22 11:35:08 +02:00
|
|
|
| HasChildrenNeeded,
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
InitialState = ValueNeeded
|
|
|
|
|
| TypeNeeded
|
|
|
|
|
| ChildrenNeeded
|
2009-06-22 11:35:08 +02:00
|
|
|
| HasChildrenNeeded
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2009-04-02 10:54:22 +02:00
|
|
|
void setValue(const QString &);
|
2009-10-13 14:16:50 +02:00
|
|
|
void setType(const QString &, bool guessChildrenFromType = true);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setValueToolTip(const QString &);
|
|
|
|
|
void setError(const QString &);
|
|
|
|
|
void setAddress(const QString &address);
|
|
|
|
|
|
|
|
|
|
bool isSomethingNeeded() const { return state & NeededMask; }
|
|
|
|
|
void setAllNeeded() { state = NeededMask; }
|
|
|
|
|
void setAllUnneeded() { state = State(0); }
|
|
|
|
|
|
|
|
|
|
bool isTypeNeeded() const { return state & TypeNeeded; }
|
|
|
|
|
bool isTypeKnown() const { return !(state & TypeNeeded); }
|
|
|
|
|
void setTypeNeeded() { state = State(state | TypeNeeded); }
|
|
|
|
|
void setTypeUnneeded() { state = State(state & ~TypeNeeded); }
|
|
|
|
|
|
|
|
|
|
bool isValueNeeded() const { return state & ValueNeeded; }
|
|
|
|
|
bool isValueKnown() const { return !(state & ValueNeeded); }
|
|
|
|
|
void setValueNeeded() { state = State(state | ValueNeeded); }
|
|
|
|
|
void setValueUnneeded() { state = State(state & ~ValueNeeded); }
|
|
|
|
|
|
|
|
|
|
bool isChildrenNeeded() const { return state & ChildrenNeeded; }
|
|
|
|
|
bool isChildrenKnown() const { return !(state & ChildrenNeeded); }
|
|
|
|
|
void setChildrenNeeded() { state = State(state | ChildrenNeeded); }
|
|
|
|
|
void setChildrenUnneeded() { state = State(state & ~ChildrenNeeded); }
|
|
|
|
|
|
2009-06-22 11:35:08 +02:00
|
|
|
bool isHasChildrenNeeded() const { return state & HasChildrenNeeded; }
|
|
|
|
|
bool isHasChildrenKnown() const { return !(state & HasChildrenNeeded); }
|
|
|
|
|
void setHasChildrenNeeded() { state = State(state | HasChildrenNeeded); }
|
|
|
|
|
void setHasChildrenUnneeded() { state = State(state & ~HasChildrenNeeded); }
|
|
|
|
|
void setHasChildren(bool c) { hasChildren = c; setHasChildrenUnneeded();
|
|
|
|
|
if (!c) setChildrenUnneeded(); }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QString toString() const;
|
2009-05-13 14:39:55 +02:00
|
|
|
QString toToolTip() const;
|
2010-01-05 16:51:55 +01:00
|
|
|
bool isLocal() const { return iname.startsWith("local."); }
|
|
|
|
|
bool isWatcher() const { return iname.startsWith("watch."); }
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isValid() const { return !iname.isEmpty(); }
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2009-08-31 09:14:04 +02:00
|
|
|
bool isEqual(const WatchData &other) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-16 16:26:28 +02:00
|
|
|
static QString msgNotInScope();
|
|
|
|
|
static QString shadowedName(const QString &name, int seen);
|
2010-02-04 13:19:49 +01:00
|
|
|
static const QString &shadowedNameFormat();
|
2009-10-16 16:26:28 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-01-05 16:51:55 +01:00
|
|
|
QByteArray iname; // internal name sth like 'local.baz.public.a'
|
|
|
|
|
QByteArray exp; // the expression
|
2008-12-02 12:01:29 +01:00
|
|
|
QString name; // displayed name
|
|
|
|
|
QString value; // displayed value
|
|
|
|
|
QByteArray editvalue; // displayed value
|
|
|
|
|
QString valuetooltip; // tooltip in value column
|
2009-08-12 11:21:44 +02:00
|
|
|
QString type; // type for further processing
|
2010-01-05 16:51:55 +01:00
|
|
|
QString displayedType;// displayed type (optional)
|
|
|
|
|
QByteArray variable; // name of internal Gdb variable if created
|
2010-01-11 10:22:55 +01:00
|
|
|
QByteArray addr; // displayed address
|
2010-01-05 16:51:55 +01:00
|
|
|
QByteArray saddr; // stored address (pointer in container)
|
2008-12-02 12:01:29 +01:00
|
|
|
QString framekey; // key for type cache
|
|
|
|
|
QScriptValue scriptValue; // if needed...
|
2009-06-22 11:35:08 +02:00
|
|
|
bool hasChildren;
|
2009-06-17 16:00:03 +02:00
|
|
|
int generation; // when updated?
|
2009-08-31 09:14:04 +02:00
|
|
|
bool valueEnabled; // value will be greyed out or not
|
|
|
|
|
bool valueEditable; // value will be editable
|
2009-10-16 16:26:28 +02:00
|
|
|
bool error;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
2009-04-29 14:15:09 +02:00
|
|
|
int source; // Used by some debuggers (CDB) to tell where it originates from (dumper or symbol evaluation)
|
2008-12-02 12:01:29 +01:00
|
|
|
int state;
|
|
|
|
|
bool changed;
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-24 12:31:09 +02:00
|
|
|
enum WatchRoles
|
|
|
|
|
{
|
|
|
|
|
INameRole = Qt::UserRole,
|
|
|
|
|
ExpressionRole,
|
2010-01-11 10:22:55 +01:00
|
|
|
ExpandedRole, // used to communicate preferred expanded state to the view
|
2009-06-24 12:31:09 +02:00
|
|
|
ActiveDataRole, // used for tooltip
|
2009-07-03 11:20:47 +02:00
|
|
|
TypeFormatListRole,
|
|
|
|
|
TypeFormatRole, // used to communicate alternative formats to the view
|
2009-08-12 10:51:25 +02:00
|
|
|
IndividualFormatRole,
|
|
|
|
|
AddressRole, // some memory address related to 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
|
|
|
|
|
{
|
|
|
|
|
DecimalFormat = 0, // keep that at 0 as default
|
|
|
|
|
HexadecimalFormat,
|
|
|
|
|
BinaryFormat,
|
|
|
|
|
OctalFormat,
|
|
|
|
|
};
|
|
|
|
|
|
2009-12-08 16:00:06 +01:00
|
|
|
|
|
|
|
|
enum PointerFomat
|
|
|
|
|
{
|
|
|
|
|
BaldPointerFormat = 0, // keep that at 0 as default
|
|
|
|
|
Latin1StringFormat,
|
|
|
|
|
Local8BitStringFormat,
|
|
|
|
|
Utf8StringFormat,
|
|
|
|
|
Utf16StringFormat,
|
|
|
|
|
Ucs4StringFormat,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-07-06 10:44:08 +02:00
|
|
|
enum DumpableFormat
|
|
|
|
|
{
|
|
|
|
|
PrettyFormat = 0, // keep that at 0 as default
|
2010-01-29 21:33:57 +01:00
|
|
|
PlainFomat,
|
2009-07-06 10:44:08 +02:00
|
|
|
};
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
int rowCount(const QModelIndex &idx) const;
|
|
|
|
|
int columnCount(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-02-04 16:23:51 +01:00
|
|
|
void beginCycle(bool clearFetchTriggered); // called at begin of updateLocals() cycle
|
2009-08-31 09:14:04 +02:00
|
|
|
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-11-26 14:11:57 +01:00
|
|
|
Q_SLOT void resetExtraLayoutChanged();
|
2009-11-25 08:35:02 +01:00
|
|
|
|
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;
|
|
|
|
|
|
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-11-26 14:11:57 +01:00
|
|
|
// Part of the workaround to update the [+] marker when items
|
|
|
|
|
// are added to a container.
|
|
|
|
|
bool m_inExtraLayoutChanged;
|
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
|
|
|
//public slots:
|
|
|
|
|
void cleanup();
|
2009-03-19 12:53:58 +01:00
|
|
|
Q_SLOT void watchExpression(); // data 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
|
|
|
|
|
|
|
|
// called at begin of updateLocals() cycle
|
|
|
|
|
void beginCycle(bool clearFetchTriggered = true);
|
2009-07-13 09:11:07 +02:00
|
|
|
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 isDisplayedIName(const QByteArray &iname) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return m_displayedINames.contains(iname); }
|
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; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-18 10:34:53 +02:00
|
|
|
static QString watcherEditPlaceHolder();
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
typedef QMap<QString, QPointer<QWidget> > EditWindows;
|
|
|
|
|
EditWindows m_editWindows;
|
|
|
|
|
|
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;
|
|
|
|
|
QHash<QString, int> m_individualFormats;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void setDisplayedIName(const QString &iname, bool on);
|
2010-01-05 16:51:55 +01:00
|
|
|
QSet<QByteArray> m_expandedINames; // those expanded in the treeview
|
|
|
|
|
QSet<QByteArray> m_displayedINames; // those with "external" viewers
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Debugger::Internal::WatchData);
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_WATCHHANDLER_H
|