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-06-17 00:01:27 +10:00
|
|
|
** contact the sales department at http://www.qtsoftware.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-07-13 09:11:07 +02:00
|
|
|
#include <QtGui/QStandardItem>
|
|
|
|
|
#include <QtGui/QStandardItemModel>
|
|
|
|
|
#include <QtGui/QTreeView>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtScript/QScriptValue>
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
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 &);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setType(const QString &);
|
|
|
|
|
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;
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isLocal() const { return iname.startsWith(QLatin1String("local.")); }
|
2009-03-25 17:33:49 +01:00
|
|
|
bool isWatcher() const { return iname.startsWith(QLatin1String("watch.")); }
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isValid() const { return !iname.isEmpty(); }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QString iname; // internal name sth like 'local.baz.public.a'
|
|
|
|
|
QString exp; // the expression
|
|
|
|
|
QString name; // displayed name
|
|
|
|
|
QString value; // displayed value
|
|
|
|
|
QByteArray editvalue; // displayed value
|
|
|
|
|
QString valuetooltip; // tooltip in value column
|
|
|
|
|
QString type; // displayed type
|
|
|
|
|
QString variable; // name of internal Gdb variable if created
|
|
|
|
|
QString addr; // displayed adress
|
2009-03-11 15:09:33 +01:00
|
|
|
QString 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?
|
2008-12-02 12:01:29 +01:00
|
|
|
bool valuedisabled; // value will be greyed out
|
|
|
|
|
|
|
|
|
|
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,
|
2009-07-03 11:20:47 +02:00
|
|
|
ExpandedRole, // used to communicate prefered 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
|
|
|
|
|
IndividualFormatRole
|
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,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum DumpableFormat
|
|
|
|
|
{
|
|
|
|
|
PrettyFormat = 0, // keep that at 0 as default
|
|
|
|
|
PlainFomat,
|
|
|
|
|
};
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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);
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchItem *findItem(const QString &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-07-13 09:11:07 +02:00
|
|
|
void removeItem(WatchItem *item);
|
|
|
|
|
void setActiveData(const QString &data) { m_activeData = data; }
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void emitDataChanged(int column,
|
|
|
|
|
const QModelIndex &parentIndex = QModelIndex());
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
private:
|
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;
|
|
|
|
|
QString m_activeData;
|
2009-06-17 16:00:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WatchHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
WatchHandler();
|
|
|
|
|
WatchModel *model(WatchType type) const;
|
|
|
|
|
WatchModel *modelForIName(const QString &data) const;
|
|
|
|
|
|
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-07-13 09:11:07 +02: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);
|
2009-06-24 12:31:09 +02:00
|
|
|
void removeData(const QString &iname);
|
2009-06-17 16:00:03 +02:00
|
|
|
WatchData *findItem(const QString &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
|
|
|
|
|
|
|
|
bool isDisplayedIName(const QString &iname) const
|
|
|
|
|
{ return m_displayedINames.contains(iname); }
|
|
|
|
|
bool isExpandedIName(const QString &iname) const
|
|
|
|
|
{ return m_expandedINames.contains(iname); }
|
2009-05-12 14:28:27 +02:00
|
|
|
QSet<QString> expandedINames() const
|
|
|
|
|
{ return m_expandedINames; }
|
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
|
|
|
signals:
|
2009-07-13 09:11:07 +02:00
|
|
|
void watchDataUpdateNeeded(const WatchData &data);
|
2008-12-17 17:43:01 +01:00
|
|
|
void sessionValueRequested(const QString &name, QVariant *value);
|
|
|
|
|
void setSessionValueRequested(const QString &name, const QVariant &value);
|
|
|
|
|
|
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;
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
QHash<QString, int> m_watcherNames;
|
2009-07-13 09:11:07 +02:00
|
|
|
QString watcherName(const QString &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);
|
|
|
|
|
QSet<QString> m_expandedINames; // those expanded in the treeview
|
|
|
|
|
QSet<QString> m_displayedINames; // those with "external" viewers
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchModel *m_locals;
|
|
|
|
|
WatchModel *m_watchers;
|
|
|
|
|
WatchModel *m_tooltips;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Debugger::Internal::WatchData);
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_WATCHHANDLER_H
|