2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAbstractItemModel>
|
2014-04-15 18:13:03 +02:00
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QVector>
|
2009-08-12 11:21:44 +02:00
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-05-17 21:00:22 +02:00
|
|
|
class SeparatedView;
|
2014-11-07 13:50:09 +01:00
|
|
|
class WatchModel;
|
2014-05-17 21:00:22 +02:00
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
// Special formats. Keep in sync with dumper.py.
|
|
|
|
|
enum DisplayFormat
|
|
|
|
|
{
|
|
|
|
|
AutomaticFormat = -1, // Based on type for individuals, dumper default for types.
|
|
|
|
|
RawFormat = 0,
|
|
|
|
|
|
|
|
|
|
// Values between 1 and 99 refer to dumper provided custom formats.
|
|
|
|
|
|
|
|
|
|
// Values between 100 and 199 refer to well-known formats handled in dumpers.
|
|
|
|
|
KnownDumperFormatBase = 100,
|
|
|
|
|
Latin1StringFormat,
|
|
|
|
|
Utf8StringFormat,
|
|
|
|
|
Local8BitStringFormat,
|
|
|
|
|
Utf16StringFormat,
|
|
|
|
|
Ucs4StringFormat,
|
|
|
|
|
|
|
|
|
|
Array10Format,
|
|
|
|
|
Array100Format,
|
|
|
|
|
Array1000Format,
|
|
|
|
|
Array10000Format,
|
|
|
|
|
|
2014-05-27 22:35:54 +02:00
|
|
|
SeparateLatin1StringFormat,
|
|
|
|
|
SeparateUtf8StringFormat,
|
|
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
|
|
|
|
|
// Values above 200 refer to format solely handled in the WatchHandler code
|
|
|
|
|
ArtificialFormatBase = 200,
|
|
|
|
|
|
|
|
|
|
BoolTextFormat,
|
|
|
|
|
BoolIntegerFormat,
|
|
|
|
|
|
|
|
|
|
DecimalIntegerFormat,
|
|
|
|
|
HexadecimalIntegerFormat,
|
|
|
|
|
BinaryIntegerFormat,
|
|
|
|
|
OctalIntegerFormat,
|
|
|
|
|
|
|
|
|
|
CompactFloatFormat,
|
|
|
|
|
ScientificFloatFormat,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TypeFormatItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TypeFormatItem() : format(-1) {}
|
|
|
|
|
TypeFormatItem(const QString &display, int format);
|
|
|
|
|
|
|
|
|
|
QString display;
|
|
|
|
|
int format;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TypeFormatList : public QVector<TypeFormatItem>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
using QVector::append;
|
|
|
|
|
void append(int format);
|
|
|
|
|
TypeFormatItem find(int format) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Debugger::Internal::TypeFormatList)
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Debugger {
|
2012-05-18 02:28:41 +02:00
|
|
|
|
2010-09-13 13:30:35 +02:00
|
|
|
class DebuggerEngine;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
class UpdateParameters
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
UpdateParameters() { tryPartial = tooltipOnly = false; }
|
|
|
|
|
|
|
|
|
|
bool tryPartial;
|
|
|
|
|
bool tooltipOnly;
|
|
|
|
|
QByteArray varList;
|
2014-11-11 11:00:32 +01:00
|
|
|
QString tooltipExpression;
|
2012-05-18 02:28:41 +02:00
|
|
|
};
|
|
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
typedef QHash<QString, QStringList> DumperTypeFormats; // Type name -> Dumper Formats
|
2009-07-06 10:44:08 +02:00
|
|
|
|
2014-11-07 13:50:09 +01:00
|
|
|
class WatchModelBase : public QAbstractItemModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
WatchModelBase() {}
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void currentIndexRequested(const QModelIndex &idx);
|
|
|
|
|
void itemIsExpanded(const QModelIndex &idx);
|
|
|
|
|
void columnAdjustmentRequested();
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
class WatchHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-06-16 11:08:54 +02:00
|
|
|
explicit WatchHandler(DebuggerEngine *engine);
|
2012-05-18 02:28:41 +02:00
|
|
|
~WatchHandler();
|
|
|
|
|
|
2014-11-07 13:50:09 +01:00
|
|
|
WatchModelBase *model() const;
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void cleanup();
|
2012-08-31 11:34:27 +02:00
|
|
|
void watchExpression(const QString &exp, const QString &name = QString());
|
2012-10-29 12:59:53 +01:00
|
|
|
void watchVariable(const QString &exp);
|
2011-01-14 17:28:37 +01:00
|
|
|
Q_SLOT void clearWatches();
|
2010-02-04 16:23:51 +01:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
void showEditValue(const WatchData &data);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
const WatchData *watchData(const QModelIndex &) const;
|
2014-06-02 10:43:26 +02:00
|
|
|
void fetchMore(const QByteArray &iname) const;
|
2012-05-18 02:28:41 +02:00
|
|
|
const WatchData *findData(const QByteArray &iname) const;
|
2012-08-31 11:34:27 +02:00
|
|
|
const WatchData *findCppLocalVariable(const QString &name) const;
|
2012-05-18 02:28:41 +02:00
|
|
|
bool hasItem(const QByteArray &iname) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-23 13:44:37 +01:00
|
|
|
void loadSessionData();
|
|
|
|
|
void saveSessionData();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
bool isExpandedIName(const QByteArray &iname) const;
|
|
|
|
|
QSet<QByteArray> expandedINames() const;
|
|
|
|
|
|
2010-11-04 18:11:09 +01:00
|
|
|
static QStringList watchedExpressions();
|
2012-03-14 12:26:27 +01:00
|
|
|
static QHash<QByteArray, int> 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
|
|
|
|
2010-03-11 18:55:52 +01:00
|
|
|
int format(const QByteArray &iname) const;
|
2009-06-18 10:34:53 +02:00
|
|
|
|
2010-09-01 19:02:56 +02:00
|
|
|
void addTypeFormats(const QByteArray &type, const QStringList &formats);
|
2014-04-15 18:13:03 +02:00
|
|
|
void setTypeFormats(const DumperTypeFormats &typeFormats);
|
|
|
|
|
DumperTypeFormats typeFormats() const;
|
2010-06-25 09:07:14 +02:00
|
|
|
|
2011-08-03 14:36:07 +02:00
|
|
|
void setUnprintableBase(int base);
|
|
|
|
|
static int unprintableBase();
|
2011-02-17 19:00:33 +01:00
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray watcherName(const QByteArray &exp);
|
2010-11-05 19:38:40 +01:00
|
|
|
QString editorContents();
|
2011-11-07 20:07:14 +01:00
|
|
|
void editTypeFormats(bool includeLocals, const QByteArray &iname);
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2012-01-17 18:44:02 +01:00
|
|
|
void scheduleResetLocation();
|
|
|
|
|
void resetLocation();
|
2012-02-07 15:39:27 +01:00
|
|
|
bool isValidToolTip(const QByteArray &iname) const;
|
2012-01-17 18:44:02 +01:00
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
void setCurrentItem(const QByteArray &iname);
|
|
|
|
|
void updateWatchersWindow();
|
|
|
|
|
|
|
|
|
|
void insertData(const WatchData &data); // Convenience.
|
|
|
|
|
void insertData(const QList<WatchData> &list);
|
|
|
|
|
void insertIncompleteData(const WatchData &data);
|
|
|
|
|
void removeData(const QByteArray &iname);
|
|
|
|
|
void removeChildren(const QByteArray &iname);
|
2012-10-09 16:13:29 +02:00
|
|
|
void removeAllData(bool includeInspectData = false);
|
2012-09-21 16:46:06 +02:00
|
|
|
void resetValueCache();
|
2012-04-18 14:20:54 +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
|
|
|
|
2010-11-23 13:44:37 +01:00
|
|
|
void saveWatchers();
|
2013-11-28 14:28:20 +01:00
|
|
|
static void loadFormats();
|
|
|
|
|
static void saveFormats();
|
2008-12-17 17:43:01 +01:00
|
|
|
|
2010-09-01 19:02:56 +02:00
|
|
|
void setFormat(const QByteArray &type, int format);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-02-11 12:25:12 +01:00
|
|
|
WatchModel *m_model; // Owned.
|
|
|
|
|
DebuggerEngine *m_engine; // Not owned.
|
2014-05-17 21:00:22 +02:00
|
|
|
SeparatedView *m_separatedView; // Owned.
|
2011-09-08 12:22:13 +02:00
|
|
|
|
|
|
|
|
int m_watcherCounter;
|
2012-01-17 18:44:02 +01:00
|
|
|
|
|
|
|
|
bool m_contentsValid;
|
|
|
|
|
bool m_resetLocationScheduled;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
Q_DECLARE_METATYPE(Debugger::Internal::UpdateParameters)
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif // DEBUGGER_WATCHHANDLER_H
|