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
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/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
|
|
|
|
|
** 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, 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
|
|
|
#include "watchwindow.h"
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
#include "breakhandler.h"
|
2011-04-21 12:32:36 +02:00
|
|
|
#include "registerhandler.h"
|
2009-03-17 17:00:06 +01:00
|
|
|
#include "debuggeractions.h"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.h"
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2009-08-19 14:41:51 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2010-11-05 19:38:40 +01:00
|
|
|
#include "debuggerengine.h"
|
2010-09-22 17:30:22 +02:00
|
|
|
#include "watchdelegatewidgets.h"
|
2010-11-05 19:38:40 +01:00
|
|
|
#include "watchhandler.h"
|
2011-02-14 09:40:43 +01:00
|
|
|
#include "debuggertooltipmanager.h"
|
2011-04-19 12:17:48 +02:00
|
|
|
#include "memoryagent.h"
|
2011-11-11 17:17:57 +01:00
|
|
|
|
2012-11-15 16:57:11 +01:00
|
|
|
#include <texteditor/syntaxhighlighter.h>
|
|
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2013-06-11 11:56:21 +02:00
|
|
|
#include <utils/fancylineedit.h>
|
2009-03-19 15:24:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMetaProperty>
|
|
|
|
|
#include <QMimeData>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QClipboard>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QItemDelegate>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QMessageBox>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
Q_DECLARE_METATYPE(QModelIndex)
|
|
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// WatchDelegate
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
const char CurrentIndex[] = "CurrentIndex";
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
static DebuggerEngine *currentEngine()
|
|
|
|
|
{
|
2010-11-10 11:39:01 +01:00
|
|
|
return debuggerCore()->currentEngine();
|
2010-11-05 19:38:40 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
class WatchDelegate : public QItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-03-29 14:20:45 +02:00
|
|
|
explicit WatchDelegate(WatchTreeView *parent)
|
2010-11-05 19:38:40 +01:00
|
|
|
: QItemDelegate(parent), m_watchWindow(parent)
|
|
|
|
|
{}
|
2009-03-19 15:24:18 +01:00
|
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
2010-09-22 17:30:22 +02:00
|
|
|
const QModelIndex &index) const
|
2009-03-19 15:24:18 +01:00
|
|
|
{
|
2010-09-22 17:30:22 +02:00
|
|
|
// Value column: Custom editor. Apply integer-specific settings.
|
|
|
|
|
if (index.column() == 1) {
|
2010-11-04 11:27:23 +01:00
|
|
|
const QVariant::Type type =
|
|
|
|
|
static_cast<QVariant::Type>(index.data(LocalsEditTypeRole).toInt());
|
2010-09-22 17:30:22 +02:00
|
|
|
switch (type) {
|
|
|
|
|
case QVariant::Bool:
|
|
|
|
|
return new BooleanComboBox(parent);
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
WatchLineEdit *edit = WatchLineEdit::create(type, parent);
|
2011-02-17 16:31:43 +01:00
|
|
|
edit->setFrame(false);
|
|
|
|
|
IntegerWatchLineEdit *intEdit
|
|
|
|
|
= qobject_cast<IntegerWatchLineEdit *>(edit);
|
|
|
|
|
if (intEdit)
|
2010-09-22 17:30:22 +02:00
|
|
|
intEdit->setBase(index.data(LocalsIntegerBaseRole).toInt());
|
|
|
|
|
return edit;
|
|
|
|
|
}
|
2011-02-17 16:31:43 +01:00
|
|
|
|
|
|
|
|
// Standard line edits for the rest.
|
2013-06-11 11:56:21 +02:00
|
|
|
Utils::FancyLineEdit *lineEdit = new Utils::FancyLineEdit(parent);
|
2011-02-17 16:31:43 +01:00
|
|
|
lineEdit->setFrame(false);
|
2013-06-11 11:56:21 +02:00
|
|
|
lineEdit->setHistoryCompleter(QLatin1String("WatchItems"));
|
2011-02-17 16:31:43 +01:00
|
|
|
return lineEdit;
|
2009-03-19 15:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-07 13:38:19 +02:00
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
2010-09-24 10:35:22 +02:00
|
|
|
const QModelIndex &index) const
|
2009-03-19 15:24:18 +01:00
|
|
|
{
|
2010-09-24 10:35:22 +02:00
|
|
|
// Standard handling for anything but the watcher name column (change
|
|
|
|
|
// expression), which removes/recreates a row, which cannot be done
|
|
|
|
|
// in model->setData().
|
|
|
|
|
if (index.column() != 0) {
|
|
|
|
|
QItemDelegate::setModelData(editor, model, index);
|
2010-09-22 17:30:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2010-09-24 10:35:22 +02:00
|
|
|
const QMetaProperty userProperty = editor->metaObject()->userProperty();
|
|
|
|
|
QTC_ASSERT(userProperty.isValid(), return);
|
2010-11-05 19:38:40 +01:00
|
|
|
const QString value = editor->property(userProperty.name()).toString();
|
2010-09-24 10:35:22 +02:00
|
|
|
const QString exp = index.data(LocalsExpressionRole).toString();
|
2010-11-05 19:38:40 +01:00
|
|
|
if (exp == value)
|
|
|
|
|
return;
|
2012-05-24 16:49:18 +02:00
|
|
|
WatchHandler *handler = currentEngine()->watchHandler();
|
|
|
|
|
handler->removeData(index.data(LocalsINameRole).toByteArray());
|
2010-11-05 19:38:40 +01:00
|
|
|
m_watchWindow->watchExpression(value);
|
2009-03-19 15:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &) const
|
|
|
|
|
{
|
|
|
|
|
editor->setGeometry(option.rect);
|
|
|
|
|
}
|
2010-11-05 19:38:40 +01:00
|
|
|
|
|
|
|
|
private:
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView *m_watchWindow;
|
2009-03-19 15:24:18 +01:00
|
|
|
};
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
// Watch model query helpers.
|
|
|
|
|
static inline quint64 addressOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
2013-03-06 10:03:29 +01:00
|
|
|
return m.data(LocalsObjectAddressRole).toULongLong();
|
2011-05-17 11:30:44 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-06 10:03:29 +01:00
|
|
|
static inline quint64 pointerAddressOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
2013-03-06 10:03:29 +01:00
|
|
|
return m.data(LocalsPointerAddressRole).toULongLong();
|
2011-05-17 11:30:44 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
static inline QString nameOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
|
|
|
|
return m.data().toString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-21 09:10:31 +02:00
|
|
|
static inline QString typeOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
|
|
|
|
return m.data(LocalsTypeRole).toString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
static inline uint sizeOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
|
|
|
|
return m.data(LocalsSizeRole).toUInt();
|
|
|
|
|
}
|
2011-04-08 16:18:47 +02:00
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
// Create a map of value->name for register markup.
|
2011-04-21 12:32:36 +02:00
|
|
|
typedef QMap<quint64, QString> RegisterMap;
|
|
|
|
|
typedef RegisterMap::const_iterator RegisterMapConstIt;
|
|
|
|
|
|
|
|
|
|
RegisterMap registerMap(const DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
RegisterMap result;
|
|
|
|
|
foreach (const Register ®, engine->registerHandler()->registers()) {
|
|
|
|
|
const QVariant v = reg.editValue();
|
|
|
|
|
if (v.type() == QVariant::ULongLong)
|
2012-02-16 09:55:47 +02:00
|
|
|
result.insert(v.toULongLong(), QString::fromLatin1(reg.name));
|
2011-04-21 12:32:36 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 15:43:00 +02:00
|
|
|
// Helper functionality to indicate the area of a member variable in
|
|
|
|
|
// a vector representing the memory area by a unique color
|
|
|
|
|
// number and tooltip. Parts of it will be overwritten when recursing
|
|
|
|
|
// over the children.
|
|
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
typedef QPair<int, QString> ColorNumberToolTip;
|
|
|
|
|
typedef QVector<ColorNumberToolTip> ColorNumberToolTips;
|
2011-04-12 15:43:00 +02:00
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
static QString variableToolTip(const QString &name, const QString &type,
|
|
|
|
|
quint64 offset)
|
2011-04-21 09:10:31 +02:00
|
|
|
{
|
|
|
|
|
return offset ?
|
|
|
|
|
//: HTML tooltip of a variable in the memory editor
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::tr("<i>%1</i> %2 at #%3").
|
2011-04-21 09:10:31 +02:00
|
|
|
arg(type, name).arg(offset) :
|
|
|
|
|
//: HTML tooltip of a variable in the memory editor
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::tr("<i>%1</i> %2").arg(type, name);
|
2011-04-21 09:10:31 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-21 12:32:36 +02:00
|
|
|
static int memberVariableRecursion(const QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex &modelIndex,
|
|
|
|
|
const QString &name,
|
|
|
|
|
quint64 start, quint64 end,
|
|
|
|
|
int *colorNumberIn,
|
2011-08-03 13:30:06 +02:00
|
|
|
ColorNumberToolTips *cnmv)
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
2011-04-12 15:43:00 +02:00
|
|
|
int childCount = 0;
|
2012-08-21 16:08:43 +02:00
|
|
|
QTC_ASSERT(modelIndex.isValid(), return childCount );
|
|
|
|
|
const int rowCount = model->rowCount(modelIndex);
|
2011-04-08 16:18:47 +02:00
|
|
|
if (!rowCount)
|
2011-04-12 15:43:00 +02:00
|
|
|
return childCount;
|
2011-04-21 12:32:36 +02:00
|
|
|
const QString nameRoot = name.isEmpty() ? name : name + QLatin1Char('.');
|
2011-04-08 16:18:47 +02:00
|
|
|
for (int r = 0; r < rowCount; r++) {
|
2012-08-21 16:08:43 +02:00
|
|
|
const QModelIndex childIndex = modelIndex.child(r, 0);
|
2011-04-08 16:18:47 +02:00
|
|
|
const quint64 childAddress = addressOf(childIndex);
|
|
|
|
|
const uint childSize = sizeOf(childIndex);
|
|
|
|
|
if (childAddress && childAddress >= start
|
2011-04-12 15:43:00 +02:00
|
|
|
&& (childAddress + childSize) <= end) { // Non-static, within area?
|
|
|
|
|
const QString childName = nameRoot + nameOf(childIndex);
|
|
|
|
|
const quint64 childOffset = childAddress - start;
|
2011-04-21 09:10:31 +02:00
|
|
|
const QString toolTip
|
|
|
|
|
= variableToolTip(childName, typeOf(childIndex), childOffset);
|
2011-08-03 13:30:06 +02:00
|
|
|
const ColorNumberToolTip colorNumberNamePair((*colorNumberIn)++, toolTip);
|
|
|
|
|
const ColorNumberToolTips::iterator begin = cnmv->begin() + childOffset;
|
2011-04-12 15:43:00 +02:00
|
|
|
qFill(begin, begin + childSize, colorNumberNamePair);
|
|
|
|
|
childCount++;
|
2011-08-03 13:30:06 +02:00
|
|
|
childCount += memberVariableRecursion(model, childIndex,
|
|
|
|
|
childName, start, end, colorNumberIn, cnmv);
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-04-12 15:43:00 +02:00
|
|
|
return childCount;
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-05 08:43:52 +03:00
|
|
|
typedef QList<MemoryMarkup> MemoryMarkupList;
|
2011-04-08 16:18:47 +02:00
|
|
|
|
2013-06-05 08:43:52 +03:00
|
|
|
/*!
|
2013-09-06 17:16:18 +02:00
|
|
|
Creates markup for a variable in the memory view.
|
2011-04-08 16:18:47 +02:00
|
|
|
|
2011-04-12 15:43:00 +02:00
|
|
|
Marks the visible children with alternating colors in the parent, that is, for
|
2011-04-08 16:18:47 +02:00
|
|
|
\code
|
|
|
|
|
struct Foo {
|
|
|
|
|
char c1
|
|
|
|
|
char c2
|
|
|
|
|
int x2;
|
2011-04-12 15:43:00 +02:00
|
|
|
QPair<int, int> pair
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
\endcode
|
|
|
|
|
create something like:
|
|
|
|
|
\code
|
|
|
|
|
0 memberColor1
|
|
|
|
|
1 memberColor2
|
|
|
|
|
2 base color (padding area of parent)
|
|
|
|
|
3 base color
|
|
|
|
|
4 member color1
|
|
|
|
|
...
|
2011-04-12 15:43:00 +02:00
|
|
|
8 memberColor2 (pair.first)
|
|
|
|
|
...
|
|
|
|
|
12 memberColor1 (pair.second)
|
2011-04-08 16:18:47 +02:00
|
|
|
\endcode
|
|
|
|
|
|
2011-04-21 12:32:36 +02:00
|
|
|
In addition, registers pointing into the area are shown as 1 byte-markers.
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
Fixme: When dereferencing a pointer, the size of the pointee is not
|
|
|
|
|
known, currently. So, we take an area of 1024 and fill the background
|
|
|
|
|
with the default color so that just the members are shown
|
|
|
|
|
(sizeIsEstimate=true). This could be fixed by passing the pointee size
|
|
|
|
|
as well from the debugger, but would require expensive type manipulation.
|
|
|
|
|
|
2011-04-21 12:32:36 +02:00
|
|
|
\note To recurse over the top level items of the model, pass an invalid model
|
|
|
|
|
index.
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
\sa Debugger::Internal::MemoryViewWidget
|
|
|
|
|
*/
|
2011-08-03 13:30:06 +02:00
|
|
|
static MemoryMarkupList
|
2011-04-21 12:32:36 +02:00
|
|
|
variableMemoryMarkup(const QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex &modelIndex,
|
|
|
|
|
const QString &rootName,
|
|
|
|
|
const QString &rootToolTip,
|
|
|
|
|
quint64 address, quint64 size,
|
|
|
|
|
const RegisterMap ®isterMap,
|
2011-04-08 16:18:47 +02:00
|
|
|
bool sizeIsEstimate,
|
|
|
|
|
const QColor &defaultBackground)
|
|
|
|
|
{
|
|
|
|
|
enum { debug = 0 };
|
2011-04-21 12:32:36 +02:00
|
|
|
enum { registerColorNumber = 0x3453 };
|
2011-04-08 16:18:47 +02:00
|
|
|
|
2011-04-21 12:32:36 +02:00
|
|
|
if (debug)
|
|
|
|
|
qDebug() << address << ' ' << size << rootName << rootToolTip;
|
|
|
|
|
// Starting out from base, create an array representing the area
|
|
|
|
|
// filled with base color. Fill children with some unique color numbers,
|
2011-04-08 16:18:47 +02:00
|
|
|
// leaving the padding areas of the parent colored with the base color.
|
2011-04-19 12:17:48 +02:00
|
|
|
MemoryMarkupList result;
|
2011-04-12 15:43:00 +02:00
|
|
|
int colorNumber = 0;
|
2011-08-03 13:30:06 +02:00
|
|
|
ColorNumberToolTips ranges(size, ColorNumberToolTip(colorNumber, rootToolTip));
|
2012-11-15 17:24:49 +01:00
|
|
|
colorNumber++;
|
2011-04-21 12:32:36 +02:00
|
|
|
const int childCount = memberVariableRecursion(model, modelIndex,
|
|
|
|
|
rootName, address, address + size,
|
|
|
|
|
&colorNumber, &ranges);
|
2011-04-12 15:43:00 +02:00
|
|
|
if (sizeIsEstimate && !childCount)
|
|
|
|
|
return result; // Fixme: Exact size not known, no point in filling if no children.
|
2011-04-21 12:32:36 +02:00
|
|
|
// Punch in registers as 1-byte markers on top.
|
|
|
|
|
const RegisterMapConstIt regcEnd = registerMap.constEnd();
|
2011-04-21 13:04:43 +02:00
|
|
|
for (RegisterMapConstIt it = registerMap.constBegin(); it != regcEnd; ++it) {
|
|
|
|
|
if (it.key() >= address) {
|
|
|
|
|
const quint64 offset = it.key() - address;
|
|
|
|
|
if (offset < size) {
|
2011-08-03 13:30:06 +02:00
|
|
|
ranges[offset] = ColorNumberToolTip(registerColorNumber,
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::tr("Register <i>%1</i>").arg(it.value()));
|
2011-04-21 13:04:43 +02:00
|
|
|
} else {
|
|
|
|
|
break; // Sorted.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // for registers.
|
2011-04-08 16:18:47 +02:00
|
|
|
if (debug) {
|
|
|
|
|
QDebug dbg = qDebug().nospace();
|
2011-04-21 12:32:36 +02:00
|
|
|
dbg << rootToolTip << ' ' << address << ' ' << size << '\n';
|
2011-04-08 16:18:47 +02:00
|
|
|
QString name;
|
2011-05-10 15:19:38 +02:00
|
|
|
for (unsigned i = 0; i < size; ++i)
|
2011-04-08 16:18:47 +02:00
|
|
|
if (name != ranges.at(i).second) {
|
2011-08-03 13:30:06 +02:00
|
|
|
dbg << ",[" << i << ' ' << ranges.at(i).first << ' '
|
|
|
|
|
<< ranges.at(i).second << ']';
|
2011-04-08 16:18:47 +02:00
|
|
|
name = ranges.at(i).second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 16:57:11 +01:00
|
|
|
// Assign colors from a list, use base color for 0 (contrast to black text).
|
2012-11-15 17:24:49 +01:00
|
|
|
// Overwrite the first color (which is usually very bright) by the base color.
|
|
|
|
|
QList<QColor> colors = TextEditor::SyntaxHighlighter::generateColors(colorNumber + 2,
|
2012-11-15 16:57:11 +01:00
|
|
|
QColor(Qt::black));
|
2012-11-15 17:24:49 +01:00
|
|
|
colors[0] = sizeIsEstimate ? defaultBackground : Qt::lightGray;
|
2011-04-21 12:32:36 +02:00
|
|
|
const QColor registerColor = Qt::green;
|
2011-04-12 15:43:00 +02:00
|
|
|
int lastColorNumber = 0;
|
2011-05-10 15:19:38 +02:00
|
|
|
for (unsigned i = 0; i < size; ++i) {
|
2011-08-03 13:30:06 +02:00
|
|
|
const ColorNumberToolTip &range = ranges.at(i);
|
2011-04-12 15:43:00 +02:00
|
|
|
if (result.isEmpty() || lastColorNumber != range.first) {
|
|
|
|
|
lastColorNumber = range.first;
|
2012-11-15 16:57:11 +01:00
|
|
|
const QColor color = range.first == registerColorNumber ?
|
|
|
|
|
registerColor : colors.at(range.first);
|
2011-04-19 12:17:48 +02:00
|
|
|
result.push_back(MemoryMarkup(address + i, 1, color, range.second));
|
2011-04-08 16:18:47 +02:00
|
|
|
} else {
|
2011-04-19 12:17:48 +02:00
|
|
|
result.back().length++;
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
QDebug dbg = qDebug().nospace();
|
2011-04-21 12:32:36 +02:00
|
|
|
dbg << rootName << ' ' << address << ' ' << size << '\n';
|
2011-04-08 16:18:47 +02:00
|
|
|
QString name;
|
2011-05-10 15:19:38 +02:00
|
|
|
for (unsigned i = 0; i < size; ++i)
|
2011-04-08 16:18:47 +02:00
|
|
|
if (name != ranges.at(i).second) {
|
2011-08-03 13:30:06 +02:00
|
|
|
dbg << ',' << i << ' ' << ranges.at(i).first << ' '
|
|
|
|
|
<< ranges.at(i).second;
|
2011-04-08 16:18:47 +02:00
|
|
|
name = ranges.at(i).second;
|
|
|
|
|
}
|
|
|
|
|
dbg << '\n';
|
2011-04-19 12:17:48 +02:00
|
|
|
foreach (const MemoryMarkup &m, result)
|
|
|
|
|
dbg << m.address << ' ' << m.length << ' ' << m.toolTip << '\n';
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convenience to create a memory view of a variable.
|
2011-08-03 13:30:06 +02:00
|
|
|
static void addVariableMemoryView(DebuggerEngine *engine, bool separateView,
|
2013-03-06 10:03:29 +01:00
|
|
|
const QModelIndex &m, bool atPointerAddress,
|
2011-08-03 13:30:06 +02:00
|
|
|
const QPoint &p, QWidget *parent)
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
|
|
|
|
const QColor background = parent->palette().color(QPalette::Normal, QPalette::Base);
|
2013-03-06 10:03:29 +01:00
|
|
|
const quint64 address = atPointerAddress ? pointerAddressOf(m) : addressOf(m);
|
2011-04-08 16:18:47 +02:00
|
|
|
// Fixme: Get the size of pointee (see variableMemoryMarkup())?
|
2011-04-21 12:32:36 +02:00
|
|
|
const QString rootToolTip = variableToolTip(nameOf(m), typeOf(m), 0);
|
2011-04-08 16:18:47 +02:00
|
|
|
const quint64 typeSize = sizeOf(m);
|
2013-03-06 10:03:29 +01:00
|
|
|
const bool sizeIsEstimate = atPointerAddress || !typeSize;
|
2011-04-08 16:18:47 +02:00
|
|
|
const quint64 size = sizeIsEstimate ? 1024 : typeSize;
|
|
|
|
|
if (!address)
|
|
|
|
|
return;
|
2011-04-19 12:17:48 +02:00
|
|
|
const QList<MemoryMarkup> markup =
|
2011-04-21 12:32:36 +02:00
|
|
|
variableMemoryMarkup(m.model(), m, nameOf(m), rootToolTip,
|
|
|
|
|
address, size,
|
|
|
|
|
registerMap(engine),
|
|
|
|
|
sizeIsEstimate, background);
|
2011-08-03 13:30:06 +02:00
|
|
|
const unsigned flags = separateView
|
|
|
|
|
? DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly : 0;
|
2013-03-06 10:03:29 +01:00
|
|
|
const QString title = atPointerAddress
|
|
|
|
|
? WatchTreeView::tr("Memory at Pointer's Address \"%1\" (0x%2)")
|
2011-08-03 13:30:06 +02:00
|
|
|
.arg(nameOf(m)).arg(address, 0, 16)
|
2013-03-06 10:03:29 +01:00
|
|
|
: WatchTreeView::tr("Memory at Object's Address \"%1\" (0x%2)")
|
2011-08-03 13:30:06 +02:00
|
|
|
.arg(nameOf(m)).arg(address, 0, 16);
|
2011-04-19 12:17:48 +02:00
|
|
|
engine->openMemoryView(address, flags, markup, p, title, parent);
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-21 12:32:36 +02:00
|
|
|
// Add a memory view of the stack layout showing local variables
|
|
|
|
|
// and registers.
|
2011-08-03 13:30:06 +02:00
|
|
|
static void addStackLayoutMemoryView(DebuggerEngine *engine, bool separateView,
|
|
|
|
|
const QAbstractItemModel *m, const QPoint &p, QWidget *parent)
|
2011-04-21 12:32:36 +02:00
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(engine && m, return);
|
2011-04-21 12:32:36 +02:00
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
// Determine suitable address range from locals.
|
2011-04-27 13:35:48 +02:00
|
|
|
quint64 start = Q_UINT64_C(0xFFFFFFFFFFFFFFFF);
|
2011-04-21 12:32:36 +02:00
|
|
|
quint64 end = 0;
|
2012-08-21 16:08:43 +02:00
|
|
|
const QModelIndex localsIndex = m->index(0, 0);
|
|
|
|
|
QTC_ASSERT(localsIndex.data(LocalsINameRole).toString() == QLatin1String("local"), return);
|
|
|
|
|
const int localsItemCount = m->rowCount(localsIndex);
|
2011-04-21 13:39:40 +02:00
|
|
|
// Note: Unsorted by default. Exclude 'Automatically dereferenced
|
|
|
|
|
// pointer' items as they are outside the address range.
|
2012-08-21 16:08:43 +02:00
|
|
|
for (int r = 0; r < localsItemCount; r++) {
|
|
|
|
|
const QModelIndex idx = localsIndex.child(r, 0);
|
2013-03-06 10:03:29 +01:00
|
|
|
const quint64 pointerAddress = pointerAddressOf(idx);
|
|
|
|
|
if (pointerAddress == 0) {
|
2011-04-21 13:39:40 +02:00
|
|
|
const quint64 address = addressOf(idx);
|
|
|
|
|
if (address) {
|
|
|
|
|
if (address < start)
|
|
|
|
|
start = address;
|
2012-08-21 16:08:43 +02:00
|
|
|
const uint size = qMax(1u, sizeOf(idx));
|
|
|
|
|
if (address + size > end)
|
|
|
|
|
end = address + size;
|
2011-04-21 13:39:40 +02:00
|
|
|
}
|
2011-04-21 12:32:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-08-21 16:08:43 +02:00
|
|
|
if (const quint64 remainder = end % 8)
|
|
|
|
|
end += 8 - remainder;
|
2011-04-21 12:32:36 +02:00
|
|
|
// Anything found and everything in a sensible range (static data in-between)?
|
|
|
|
|
if (end <= start || end - start > 100 * 1024) {
|
2011-08-03 13:30:06 +02:00
|
|
|
QMessageBox::information(parent,
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::tr("Cannot Display Stack Layout"),
|
|
|
|
|
WatchTreeView::tr("Could not determine a suitable address range."));
|
2011-04-21 12:32:36 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Take a look at the register values. Extend the range a bit if suitable
|
|
|
|
|
// to show stack/stack frame pointers.
|
|
|
|
|
const RegisterMap regMap = registerMap(engine);
|
|
|
|
|
const RegisterMapConstIt regcEnd = regMap.constEnd();
|
|
|
|
|
for (RegisterMapConstIt it = regMap.constBegin(); it != regcEnd; ++it) {
|
|
|
|
|
const quint64 value = it.key();
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (value < start && start - value < 512)
|
2011-04-21 12:32:36 +02:00
|
|
|
start = value;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else if (value > end && value - end < 512)
|
2011-04-21 12:32:36 +02:00
|
|
|
end = value + 1;
|
|
|
|
|
}
|
|
|
|
|
// Indicate all variables.
|
|
|
|
|
const QColor background = parent->palette().color(QPalette::Normal, QPalette::Base);
|
|
|
|
|
const MemoryMarkupList markup =
|
2012-08-21 16:08:43 +02:00
|
|
|
variableMemoryMarkup(m, localsIndex, QString(),
|
2011-04-21 12:32:36 +02:00
|
|
|
QString(), start, end - start,
|
|
|
|
|
regMap, true, background);
|
2011-08-03 13:30:06 +02:00
|
|
|
const unsigned flags = separateView
|
|
|
|
|
? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
|
2011-04-21 12:32:36 +02:00
|
|
|
const QString title =
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::tr("Memory Layout of Local Variables at 0x%1").arg(start, 0, 16);
|
2011-04-21 12:32:36 +02:00
|
|
|
engine->openMemoryView(start, flags, markup, p, title, parent);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// WatchWindow
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
WatchTreeView::WatchTreeView(Type type, QWidget *parent)
|
|
|
|
|
: BaseTreeView(parent),
|
2010-06-16 11:08:54 +02:00
|
|
|
m_type(type)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-04-08 16:18:47 +02:00
|
|
|
setObjectName(QLatin1String("WatchWindow"));
|
2009-07-01 12:49:41 +02:00
|
|
|
m_grabbing = false;
|
2011-05-10 15:57:33 +02:00
|
|
|
setWindowTitle(tr("Locals and Expressions"));
|
2012-03-29 14:20:45 +02:00
|
|
|
setIndentation(indentation() * 9/10);
|
|
|
|
|
setUniformRowHeights(true);
|
|
|
|
|
setItemDelegate(new WatchDelegate(this));
|
|
|
|
|
setDragEnabled(true);
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
setDropIndicatorShown(true);
|
2011-09-30 12:28:55 +02:00
|
|
|
setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustLocalsColumnWidths));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
connect(this, SIGNAL(expanded(QModelIndex)),
|
2011-03-16 18:48:14 +01:00
|
|
|
SLOT(expandNode(QModelIndex)));
|
2012-03-29 14:20:45 +02:00
|
|
|
connect(this, SIGNAL(collapsed(QModelIndex)),
|
2011-03-16 18:48:14 +01:00
|
|
|
SLOT(collapseNode(QModelIndex)));
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::expandNode(const QModelIndex &idx)
|
2010-01-29 21:33:57 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsExpandedRole, true, idx);
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::collapseNode(const QModelIndex &idx)
|
2010-01-29 21:33:57 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsExpandedRole, false, idx);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::keyPressEvent(QKeyEvent *ev)
|
2008-12-17 18:02:08 +01:00
|
|
|
{
|
2009-04-03 13:39:14 +02:00
|
|
|
if (ev->key() == Qt::Key_Delete && m_type == WatchersType) {
|
2012-05-24 16:49:18 +02:00
|
|
|
WatchHandler *handler = currentEngine()->watchHandler();
|
2013-01-10 15:48:45 +01:00
|
|
|
foreach (const QModelIndex &idx, activeRows())
|
2012-05-24 16:49:18 +02:00
|
|
|
handler->removeData(idx.data(LocalsINameRole).toByteArray());
|
2009-04-07 13:38:19 +02:00
|
|
|
} else if (ev->key() == Qt::Key_Return
|
|
|
|
|
&& ev->modifiers() == Qt::ControlModifier
|
|
|
|
|
&& m_type == LocalsType) {
|
2012-03-29 14:20:45 +02:00
|
|
|
QModelIndex idx = currentIndex();
|
2009-04-03 13:39:14 +02:00
|
|
|
QModelIndex idx1 = idx.sibling(idx.row(), 0);
|
|
|
|
|
QString exp = model()->data(idx1).toString();
|
2010-06-23 15:13:51 +02:00
|
|
|
watchExpression(exp);
|
2008-12-17 18:02:08 +01:00
|
|
|
}
|
2012-05-18 02:28:41 +02:00
|
|
|
BaseTreeView::keyPressEvent(ev);
|
2008-12-17 18:02:08 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::dragEnterEvent(QDragEnterEvent *ev)
|
2009-04-29 12:20:10 +02:00
|
|
|
{
|
2012-05-18 02:28:41 +02:00
|
|
|
//BaseTreeView::dragEnterEvent(ev);
|
2011-12-21 14:02:52 +01:00
|
|
|
if (ev->mimeData()->hasText()) {
|
2009-04-29 12:20:10 +02:00
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::dragMoveEvent(QDragMoveEvent *ev)
|
2009-04-29 12:20:10 +02:00
|
|
|
{
|
2012-05-18 02:28:41 +02:00
|
|
|
//BaseTreeView::dragMoveEvent(ev);
|
2011-12-21 14:02:52 +01:00
|
|
|
if (ev->mimeData()->hasText()) {
|
2009-04-29 12:20:10 +02:00
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::dropEvent(QDropEvent *ev)
|
2009-04-29 12:20:10 +02:00
|
|
|
{
|
2011-12-21 14:02:52 +01:00
|
|
|
if (ev->mimeData()->hasText()) {
|
2012-09-21 22:45:40 +02:00
|
|
|
QString exp;
|
|
|
|
|
QString data = ev->mimeData()->text();
|
|
|
|
|
foreach (const QChar c, data)
|
|
|
|
|
exp.append(c.isPrint() ? c : QChar(QLatin1Char(' ')));
|
2012-10-29 12:59:53 +01:00
|
|
|
currentEngine()->watchHandler()->watchVariable(exp);
|
2009-04-29 12:20:10 +02:00
|
|
|
//ev->acceptProposedAction();
|
|
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
2012-05-18 02:28:41 +02:00
|
|
|
//BaseTreeView::dropEvent(ev);
|
2009-04-29 12:20:10 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::mouseDoubleClickEvent(QMouseEvent *ev)
|
2010-07-14 15:38:20 +02:00
|
|
|
{
|
|
|
|
|
const QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
if (!idx.isValid()) {
|
2010-07-23 18:20:13 +02:00
|
|
|
// The "<Edit>" case.
|
|
|
|
|
watchExpression(QString());
|
2010-07-14 15:38:20 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2012-05-18 02:28:41 +02:00
|
|
|
BaseTreeView::mouseDoubleClickEvent(ev);
|
2010-07-14 15:38:20 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
// Text for add watch action with truncated expression.
|
|
|
|
|
static QString addWatchActionText(QString exp)
|
2010-11-25 13:51:54 +01:00
|
|
|
{
|
|
|
|
|
if (exp.isEmpty())
|
2012-05-14 11:21:01 +02:00
|
|
|
return WatchTreeView::tr("Add Expression Evaluator");
|
2010-11-25 13:51:54 +01:00
|
|
|
if (exp.size() > 30) {
|
|
|
|
|
exp.truncate(30);
|
|
|
|
|
exp.append(QLatin1String("..."));
|
|
|
|
|
}
|
2012-05-14 11:21:01 +02:00
|
|
|
return WatchTreeView::tr("Add Expression Evaluator for \"%1\"").arg(exp);
|
2010-11-25 13:51:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
// Text for add watch action with truncated expression.
|
|
|
|
|
static QString removeWatchActionText(QString exp)
|
2010-11-25 13:51:54 +01:00
|
|
|
{
|
|
|
|
|
if (exp.isEmpty())
|
2012-05-14 11:21:01 +02:00
|
|
|
return WatchTreeView::tr("Remove Expression Evaluator");
|
2010-11-25 13:51:54 +01:00
|
|
|
if (exp.size() > 30) {
|
|
|
|
|
exp.truncate(30);
|
|
|
|
|
exp.append(QLatin1String("..."));
|
|
|
|
|
}
|
2013-03-05 20:29:05 -08:00
|
|
|
return WatchTreeView::tr("Remove Expression Evaluator for \"%1\"")
|
|
|
|
|
.arg(exp.replace(QLatin1Char('&'), QLatin1String("&&")));
|
2010-11-25 13:51:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-03 13:30:06 +02:00
|
|
|
static void copyToClipboard(const QString &clipboardText)
|
2011-04-12 16:17:19 +02:00
|
|
|
{
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
|
clipboard->setText(clipboardText, QClipboard::Selection);
|
|
|
|
|
clipboard->setText(clipboardText, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
void WatchTreeView::fillFormatMenu(QMenu *formatMenu, const QModelIndex &mi)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-04-15 18:13:03 +02:00
|
|
|
QTC_CHECK(mi.isValid());
|
|
|
|
|
|
|
|
|
|
const QModelIndex mi2 = mi.sibling(mi.row(), 2);
|
2010-06-16 11:08:54 +02:00
|
|
|
const QString type = mi2.data().toString();
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
const TypeFormatList alternativeFormats =
|
|
|
|
|
mi.data(LocalsTypeFormatListRole).value<TypeFormatList>();
|
2012-12-28 18:51:32 +01:00
|
|
|
int typeFormat =
|
2014-04-15 18:13:03 +02:00
|
|
|
mi.data(LocalsTypeFormatRole).toInt();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int individualFormat =
|
2014-04-15 18:13:03 +02:00
|
|
|
mi.data(LocalsIndividualFormatRole).toInt();
|
2014-05-06 08:27:43 +02:00
|
|
|
const int unprintableBase = WatchHandler::unprintableBase();
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2011-02-17 19:00:33 +01:00
|
|
|
QAction *showUnprintableUnicode = 0;
|
2011-08-03 17:04:32 +02:00
|
|
|
QAction *showUnprintableEscape = 0;
|
2011-02-17 19:00:33 +01:00
|
|
|
QAction *showUnprintableOctal = 0;
|
|
|
|
|
QAction *showUnprintableHexadecimal = 0;
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableUnicode =
|
2014-04-15 18:13:03 +02:00
|
|
|
formatMenu->addAction(tr("Treat All Characters as Printable"));
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableUnicode->setCheckable(true);
|
|
|
|
|
showUnprintableUnicode->setChecked(unprintableBase == 0);
|
2014-04-15 18:13:03 +02:00
|
|
|
showUnprintableUnicode->setData(0);
|
2011-08-03 17:04:32 +02:00
|
|
|
showUnprintableEscape =
|
2014-04-15 18:13:03 +02:00
|
|
|
formatMenu->addAction(tr("Show Unprintable Characters as Escape Sequences"));
|
2011-08-03 17:04:32 +02:00
|
|
|
showUnprintableEscape->setCheckable(true);
|
|
|
|
|
showUnprintableEscape->setChecked(unprintableBase == -1);
|
2014-04-15 18:13:03 +02:00
|
|
|
showUnprintableEscape->setData(-1);
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableOctal =
|
2014-04-15 18:13:03 +02:00
|
|
|
formatMenu->addAction(tr("Show Unprintable Characters as Octal"));
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableOctal->setCheckable(true);
|
|
|
|
|
showUnprintableOctal->setChecked(unprintableBase == 8);
|
2014-04-15 18:13:03 +02:00
|
|
|
showUnprintableOctal->setData(8);
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableHexadecimal =
|
2014-04-15 18:13:03 +02:00
|
|
|
formatMenu->addAction(tr("Show Unprintable Characters as Hexadecimal"));
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableHexadecimal->setCheckable(true);
|
|
|
|
|
showUnprintableHexadecimal->setChecked(unprintableBase == 16);
|
2014-04-15 18:13:03 +02:00
|
|
|
showUnprintableHexadecimal->setData(16);
|
|
|
|
|
|
|
|
|
|
connect(showUnprintableUnicode, SIGNAL(triggered()), SLOT(onShowUnprintable()));
|
|
|
|
|
connect(showUnprintableEscape, SIGNAL(triggered()), SLOT(onShowUnprintable()));
|
|
|
|
|
connect(showUnprintableOctal, SIGNAL(triggered()), SLOT(onShowUnprintable()));
|
|
|
|
|
connect(showUnprintableHexadecimal, SIGNAL(triggered()), SLOT(onShowUnprintable()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QString spacer = QLatin1String(" ");
|
|
|
|
|
formatMenu->addSeparator();
|
|
|
|
|
QAction *dummy = formatMenu->addAction(
|
|
|
|
|
tr("Change Display for Object Named \"%1\":").arg(mi.data().toString()));
|
|
|
|
|
dummy->setEnabled(false);
|
|
|
|
|
QString msg = (individualFormat == AutomaticFormat && typeFormat != AutomaticFormat)
|
|
|
|
|
? tr("Use Format for Type (Currently %1)")
|
|
|
|
|
.arg(alternativeFormats.find(typeFormat).display)
|
|
|
|
|
: tr("Use Display Format Based on Type") + QLatin1Char(' ');
|
|
|
|
|
|
|
|
|
|
QAction *clearIndividualFormatAction = formatMenu->addAction(spacer + msg);
|
|
|
|
|
clearIndividualFormatAction->setCheckable(true);
|
|
|
|
|
clearIndividualFormatAction->setChecked(individualFormat == AutomaticFormat);
|
|
|
|
|
connect(clearIndividualFormatAction, SIGNAL(triggered()),
|
|
|
|
|
SLOT(onClearIndividualFormat()));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
|
|
|
|
const QString display = spacer + alternativeFormats.at(i).display;
|
|
|
|
|
const int format = alternativeFormats.at(i).format;
|
|
|
|
|
QAction *act = new QAction(display, formatMenu);
|
|
|
|
|
act->setData(format);
|
|
|
|
|
act->setCheckable(true);
|
|
|
|
|
act->setChecked(format == individualFormat);
|
|
|
|
|
act->setProperty(CurrentIndex, QVariant::fromValue(mi));
|
|
|
|
|
formatMenu->addAction(act);
|
|
|
|
|
connect(act, SIGNAL(triggered()), SLOT(onIndividualFormatChange()));
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-15 18:13:03 +02:00
|
|
|
formatMenu->addSeparator();
|
|
|
|
|
dummy = formatMenu->addAction(tr("Change Display for Type \"%1\":").arg(type));
|
|
|
|
|
dummy->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
QAction *clearTypeFormatAction = formatMenu->addAction(spacer + tr("Automatic"));
|
|
|
|
|
clearTypeFormatAction->setCheckable(true);
|
|
|
|
|
clearTypeFormatAction->setChecked(typeFormat == AutomaticFormat);
|
|
|
|
|
connect(clearTypeFormatAction, SIGNAL(triggered()), SLOT(onClearTypeFormat()));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
|
|
|
|
const QString display = spacer + alternativeFormats.at(i).display;
|
|
|
|
|
QAction *act = new QAction(display, formatMenu);
|
|
|
|
|
const int format = alternativeFormats.at(i).format;
|
|
|
|
|
act->setData(format);
|
|
|
|
|
act->setCheckable(true);
|
|
|
|
|
act->setChecked(format == typeFormat);
|
|
|
|
|
act->setProperty(CurrentIndex, QVariant::fromValue(mi));
|
|
|
|
|
formatMenu->addAction(act);
|
|
|
|
|
connect(act, SIGNAL(triggered()), SLOT(onTypeFormatChange()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::onClearTypeFormat()
|
|
|
|
|
{
|
|
|
|
|
const QModelIndexList active = activeRows();
|
|
|
|
|
foreach (const QModelIndex &idx, active)
|
|
|
|
|
setModelData(LocalsTypeFormatRole, AutomaticFormat, idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::onClearIndividualFormat()
|
|
|
|
|
{
|
|
|
|
|
const QModelIndexList active = activeRows();
|
|
|
|
|
foreach (const QModelIndex &idx, active)
|
|
|
|
|
setModelData(LocalsIndividualFormatRole, AutomaticFormat, idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::onShowUnprintable()
|
|
|
|
|
{
|
|
|
|
|
QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
|
QTC_ASSERT(act, return);
|
|
|
|
|
DebuggerEngine *engine = currentEngine();
|
|
|
|
|
WatchHandler *handler = engine->watchHandler();
|
|
|
|
|
handler->setUnprintableBase(act->data().toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::onTypeFormatChange()
|
|
|
|
|
{
|
|
|
|
|
QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
|
QTC_ASSERT(act, return);
|
|
|
|
|
QModelIndex idx = act->property(CurrentIndex).value<QModelIndex>();
|
|
|
|
|
setModelData(LocalsTypeFormatRole, act->data(), idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::onIndividualFormatChange()
|
|
|
|
|
{
|
|
|
|
|
QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
|
QTC_ASSERT(act, return);
|
|
|
|
|
QModelIndex idx = act->property(CurrentIndex).value<QModelIndex>();
|
|
|
|
|
setModelData(LocalsIndividualFormatRole, act->data(), idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
DebuggerEngine *engine = currentEngine();
|
|
|
|
|
WatchHandler *handler = engine->watchHandler();
|
|
|
|
|
|
|
|
|
|
const QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
const QModelIndex mi0 = idx.sibling(idx.row(), 0);
|
|
|
|
|
const QModelIndex mi1 = idx.sibling(idx.row(), 1);
|
|
|
|
|
const quint64 address = addressOf(mi0);
|
|
|
|
|
const uint size = sizeOf(mi0);
|
|
|
|
|
const quint64 pointerAddress = pointerAddressOf(mi0);
|
|
|
|
|
const QString exp = mi0.data(LocalsExpressionRole).toString();
|
|
|
|
|
const QString name = mi0.data(LocalsNameRole).toString();
|
|
|
|
|
|
|
|
|
|
// Offer to open address pointed to or variable address.
|
|
|
|
|
const bool createPointerActions = pointerAddress && pointerAddress != address;
|
|
|
|
|
|
2010-11-25 18:49:26 +01:00
|
|
|
const bool actionsEnabled = engine->debuggerActionsEnabled();
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canHandleWatches = engine->hasCapability(AddWatcherCapability);
|
2010-11-25 18:49:26 +01:00
|
|
|
const DebuggerState state = engine->state();
|
2011-05-10 15:57:33 +02:00
|
|
|
const bool canInsertWatches = state == InferiorStopOk
|
2012-01-12 19:32:25 +01:00
|
|
|
|| state == DebuggerNotReady
|
2011-08-03 12:40:28 +02:00
|
|
|
|| state == InferiorUnrunnable
|
2012-01-12 20:28:17 +01:00
|
|
|
|| (state == InferiorRunOk && engine->hasCapability(AddWatcherWhileRunningCapability));
|
2009-08-18 16:46:33 +02:00
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actSetWatchpointAtObjectAddress(0);
|
|
|
|
|
QAction actSetWatchpointAtPointerAddress(0);
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canSetWatchpoint = engine->hasCapability(WatchpointByAddressCapability);
|
2010-05-19 17:34:47 +02:00
|
|
|
if (canSetWatchpoint && address) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtObjectAddress
|
|
|
|
|
.setText(tr("Add Data Breakpoint at Object's Address (0x%1)").arg(address, 0, 16));
|
|
|
|
|
actSetWatchpointAtObjectAddress
|
|
|
|
|
.setChecked(mi0.data(LocalsIsWatchpointAtObjectAddressRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
if (createPointerActions) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtPointerAddress
|
|
|
|
|
.setText(tr("Add Data Breakpoint at Pointer's Address (0x%1)")
|
|
|
|
|
.arg(pointerAddress, 0, 16));
|
|
|
|
|
actSetWatchpointAtPointerAddress.setCheckable(true);
|
|
|
|
|
actSetWatchpointAtPointerAddress
|
|
|
|
|
.setChecked(mi0.data(LocalsIsWatchpointAtPointerAddressRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
}
|
2010-05-07 15:16:31 +02:00
|
|
|
} else {
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtObjectAddress.setText(tr("Add Data Breakpoint"));
|
|
|
|
|
actSetWatchpointAtObjectAddress.setEnabled(false);
|
2010-05-07 15:16:31 +02:00
|
|
|
}
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtObjectAddress.setToolTip(
|
2011-05-10 15:57:33 +02:00
|
|
|
tr("Setting a data breakpoint on an address will cause the program "
|
|
|
|
|
"to stop when the data at the address is modified."));
|
|
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actSetWatchpointAtExpression(0);
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canSetWatchpointAtExpression = engine->hasCapability(WatchpointByExpressionCapability);
|
2011-12-23 14:01:30 +01:00
|
|
|
if (name.isEmpty() || !canSetWatchpointAtExpression) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtExpression.setText(tr("Add Data Breakpoint at Expression"));
|
|
|
|
|
actSetWatchpointAtExpression.setEnabled(false);
|
2011-11-18 19:44:17 +01:00
|
|
|
} else {
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtExpression.setText(tr("Add Data Breakpoint at Expression \"%1\"").arg(name));
|
2011-11-18 19:44:17 +01:00
|
|
|
}
|
2014-05-27 15:45:34 +02:00
|
|
|
actSetWatchpointAtExpression.setToolTip(
|
2011-05-10 15:57:33 +02:00
|
|
|
tr("Setting a data breakpoint on an expression will cause the program "
|
|
|
|
|
"to stop when the data at the address given by the expression "
|
|
|
|
|
"is modified."));
|
|
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actInsertNewWatchItem(tr("Add New Expression Evaluator..."), 0);
|
|
|
|
|
actInsertNewWatchItem.setEnabled(canHandleWatches && canInsertWatches);
|
2011-05-10 15:57:33 +02:00
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actSelectWidgetToWatch(tr("Select Widget to Add into Expression Evaluator"), 0);
|
|
|
|
|
actSelectWidgetToWatch.setEnabled(canHandleWatches && canInsertWatches
|
2012-05-16 12:31:07 +02:00
|
|
|
&& engine->hasCapability(WatchWidgetsCapability));
|
|
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actWatchExpression(addWatchActionText(exp), 0);
|
|
|
|
|
actWatchExpression.setEnabled(
|
2014-05-27 11:58:07 +02:00
|
|
|
canHandleWatches && !exp.isEmpty() && m_type == LocalsType);
|
2010-06-23 15:13:51 +02:00
|
|
|
|
2010-10-11 12:59:49 +02:00
|
|
|
// Can remove watch if engine can handle it or session engine.
|
2011-08-25 12:36:11 +02:00
|
|
|
QModelIndex p = mi0;
|
2012-05-24 16:24:53 +02:00
|
|
|
while (true) {
|
|
|
|
|
QModelIndex pp = p.parent();
|
|
|
|
|
if (!pp.isValid() || !pp.parent().isValid())
|
|
|
|
|
break;
|
|
|
|
|
p = pp;
|
|
|
|
|
}
|
2011-08-25 12:36:11 +02:00
|
|
|
QString removeExp = p.data(LocalsExpressionRole).toString();
|
2014-05-27 15:45:34 +02:00
|
|
|
QAction actRemoveWatchExpression(removeWatchActionText(removeExp), 0);
|
|
|
|
|
actRemoveWatchExpression.setEnabled(
|
2014-05-27 11:58:07 +02:00
|
|
|
(canHandleWatches || state == DebuggerNotReady)
|
|
|
|
|
&& !exp.isEmpty() && m_type == WatchersType);
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2014-05-16 01:59:27 +02:00
|
|
|
QMenu formatMenu(tr("Change Local Display Format..."));
|
2014-05-27 15:45:34 +02:00
|
|
|
if (mi0.isValid())
|
2014-04-15 18:13:03 +02:00
|
|
|
fillFormatMenu(&formatMenu, mi0);
|
|
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QMenu memoryMenu(tr("Open Memory Editor..."));
|
|
|
|
|
QAction actOpenMemoryEditAtObjectAddress(0);
|
|
|
|
|
QAction actOpenMemoryEditAtPointerAddress(0);
|
|
|
|
|
QAction actOpenMemoryEditor(0);
|
|
|
|
|
QAction actOpenMemoryEditorStackLayout(0);
|
|
|
|
|
QAction actOpenMemoryViewAtObjectAddress(0);
|
|
|
|
|
QAction actOpenMemoryViewAtPointerAddress(0);
|
2012-01-12 20:28:17 +01:00
|
|
|
if (engine->hasCapability(ShowMemoryCapability)) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditor.setText(tr("Open Memory Editor..."));
|
2010-12-16 12:07:12 +01:00
|
|
|
if (address) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtObjectAddress.setText(
|
2010-12-16 12:07:12 +01:00
|
|
|
tr("Open Memory Editor at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryViewAtObjectAddress.setText(
|
2011-04-08 16:18:47 +02:00
|
|
|
tr("Open Memory View at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16));
|
2010-12-16 12:07:12 +01:00
|
|
|
} else {
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtObjectAddress.setText(
|
2010-12-16 12:07:12 +01:00
|
|
|
tr("Open Memory Editor at Object's Address"));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtObjectAddress.setEnabled(false);
|
|
|
|
|
actOpenMemoryViewAtObjectAddress.setText(
|
2011-04-08 16:18:47 +02:00
|
|
|
tr("Open Memory View at Object's Address"));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryViewAtObjectAddress.setEnabled(false);
|
2010-12-16 12:07:12 +01:00
|
|
|
}
|
|
|
|
|
if (createPointerActions) {
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtPointerAddress.setText(
|
2013-03-06 10:03:29 +01:00
|
|
|
tr("Open Memory Editor at Pointer's Address (0x%1)")
|
|
|
|
|
.arg(pointerAddress, 0, 16));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryViewAtPointerAddress.setText(
|
2013-03-06 10:03:29 +01:00
|
|
|
tr("Open Memory View at Pointer's Address (0x%1)")
|
|
|
|
|
.arg(pointerAddress, 0, 16));
|
2010-12-16 12:07:12 +01:00
|
|
|
} else {
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtPointerAddress.setText(
|
2013-03-06 10:03:29 +01:00
|
|
|
tr("Open Memory Editor at Pointer's Address"));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditAtPointerAddress.setEnabled(false);
|
|
|
|
|
actOpenMemoryViewAtPointerAddress.setText(
|
2013-03-06 10:03:29 +01:00
|
|
|
tr("Open Memory View at Pointer's Address"));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryViewAtPointerAddress.setEnabled(false);
|
2010-12-16 12:07:12 +01:00
|
|
|
}
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditorStackLayout.setText(
|
2011-08-25 11:43:07 +02:00
|
|
|
tr("Open Memory Editor Showing Stack Layout"));
|
2014-05-27 15:45:34 +02:00
|
|
|
actOpenMemoryEditorStackLayout.setEnabled(m_type == LocalsType);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryViewAtObjectAddress);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryViewAtPointerAddress);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryEditAtObjectAddress);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryEditAtPointerAddress);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryEditorStackLayout);
|
|
|
|
|
memoryMenu.addAction(&actOpenMemoryEditor);
|
2010-12-16 12:07:12 +01:00
|
|
|
} else {
|
|
|
|
|
memoryMenu.setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 15:45:34 +02:00
|
|
|
QMenu breakpointMenu;
|
|
|
|
|
breakpointMenu.setTitle(tr("Add Data Breakpoint..."));
|
|
|
|
|
breakpointMenu.addAction(&actSetWatchpointAtObjectAddress);
|
|
|
|
|
if (canSetWatchpoint && address)
|
|
|
|
|
breakpointMenu.addAction(&actSetWatchpointAtPointerAddress);
|
|
|
|
|
breakpointMenu.addAction(&actSetWatchpointAtExpression);
|
|
|
|
|
|
|
|
|
|
QAction actCopy(tr("Copy View Contents to Clipboard"), 0);
|
|
|
|
|
QAction actCopyValue(tr("Copy Value to Clipboard"), 0);
|
|
|
|
|
actCopyValue.setEnabled(idx.isValid());
|
|
|
|
|
|
|
|
|
|
QAction actShowInEditor(tr("Open View Contents in Editor"), 0);
|
|
|
|
|
actShowInEditor.setEnabled(actionsEnabled);
|
|
|
|
|
QAction actCloseEditorToolTips(tr("Close Editor Tooltips"), 0);
|
|
|
|
|
actCloseEditorToolTips.setEnabled(DebuggerToolTipManager::hasToolTips());
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
menu.addAction(&actInsertNewWatchItem);
|
|
|
|
|
menu.addAction(&actWatchExpression);
|
|
|
|
|
menu.addAction(&actRemoveWatchExpression);
|
|
|
|
|
menu.addAction(&actSelectWidgetToWatch);
|
|
|
|
|
menu.addSeparator();
|
2011-04-12 16:17:19 +02:00
|
|
|
|
2010-12-16 10:18:51 +01:00
|
|
|
menu.addMenu(&formatMenu);
|
2010-12-16 12:07:12 +01:00
|
|
|
menu.addMenu(&memoryMenu);
|
2011-05-10 15:57:33 +02:00
|
|
|
menu.addMenu(&breakpointMenu);
|
2014-05-27 15:45:34 +02:00
|
|
|
menu.addSeparator();
|
|
|
|
|
|
|
|
|
|
menu.addAction(&actCloseEditorToolTips);
|
|
|
|
|
menu.addAction(&actCopy);
|
|
|
|
|
menu.addAction(&actCopyValue);
|
|
|
|
|
menu.addAction(&actShowInEditor);
|
2009-02-27 11:41:19 +01:00
|
|
|
menu.addSeparator();
|
2009-10-07 13:36:48 +02:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(UseDebuggingHelpers));
|
|
|
|
|
menu.addAction(debuggerCore()->action(UseToolTipsInLocalsView));
|
|
|
|
|
menu.addAction(debuggerCore()->action(AutoDerefPointers));
|
|
|
|
|
menu.addAction(debuggerCore()->action(SortStructMembers));
|
2011-11-29 12:20:06 +01:00
|
|
|
menu.addAction(debuggerCore()->action(UseDynamicType));
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(SettingsDialog));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-09-30 12:28:55 +02:00
|
|
|
addBaseContextActions(&menu);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *act = menu.exec(ev->globalPos());
|
|
|
|
|
|
2012-04-26 15:58:46 +02:00
|
|
|
if (!act) {
|
|
|
|
|
;
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actInsertNewWatchItem) {
|
2011-02-28 10:58:21 +01:00
|
|
|
bool ok;
|
2012-05-14 11:21:01 +02:00
|
|
|
QString newExp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"),
|
2011-02-28 10:58:21 +01:00
|
|
|
tr("Expression:"), QLineEdit::Normal,
|
|
|
|
|
QString(), &ok);
|
2011-09-30 12:28:55 +02:00
|
|
|
if (ok && !newExp.isEmpty())
|
2011-02-28 10:58:21 +01:00
|
|
|
watchExpression(newExp);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryEditAtObjectAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryEditAtPointerAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), false, mi0, true, ev->globalPos(), this);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryEditor) {
|
2009-08-19 14:41:51 +02:00
|
|
|
AddressDialog dialog;
|
2011-05-04 15:08:43 +02:00
|
|
|
if (address)
|
|
|
|
|
dialog.setAddress(address);
|
2010-06-16 11:08:54 +02:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
2011-04-19 12:17:48 +02:00
|
|
|
currentEngine()->openMemoryView(dialog.address(), false, MemoryMarkupList(), QPoint());
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryViewAtObjectAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), true, mi0, false, ev->globalPos(), this);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryViewAtPointerAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), true, mi0, true, ev->globalPos(), this);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actOpenMemoryEditorStackLayout) {
|
2011-07-28 14:47:49 +02:00
|
|
|
addStackLayoutMemoryView(currentEngine(), false, model(), ev->globalPos(), this);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actSetWatchpointAtObjectAddress) {
|
2012-06-03 21:59:21 +02:00
|
|
|
breakHandler()->setWatchpointAtAddress(address, size);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actSetWatchpointAtPointerAddress) {
|
2013-03-06 10:03:29 +01:00
|
|
|
breakHandler()->setWatchpointAtAddress(pointerAddress, sizeof(void *)); // FIXME: an approximation..
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actSetWatchpointAtExpression) {
|
2012-06-03 21:59:21 +02:00
|
|
|
breakHandler()->setWatchpointAtExpression(name);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actSelectWidgetToWatch) {
|
2009-07-01 12:49:41 +02:00
|
|
|
grabMouse(Qt::CrossCursor);
|
|
|
|
|
m_grabbing = true;
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actWatchExpression) {
|
2012-08-31 11:34:27 +02:00
|
|
|
watchExpression(exp, name);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actRemoveWatchExpression) {
|
2012-05-24 16:49:18 +02:00
|
|
|
handler->removeData(p.data(LocalsINameRole).toByteArray());
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actCopy) {
|
2011-05-27 11:02:57 +02:00
|
|
|
copyToClipboard(DebuggerToolTipWidget::treeModelClipboardContents(model()));
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actCopyValue) {
|
2011-04-12 16:17:19 +02:00
|
|
|
copyToClipboard(mi1.data().toString());
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actShowInEditor) {
|
2010-11-05 19:38:40 +01:00
|
|
|
QString contents = handler->editorContents();
|
2012-05-14 11:21:01 +02:00
|
|
|
debuggerCore()->openTextEditor(tr("Locals & Expressions"), contents);
|
2014-05-27 15:45:34 +02:00
|
|
|
} else if (act == &actCloseEditorToolTips) {
|
2013-10-11 17:04:56 +02:00
|
|
|
DebuggerToolTipManager::closeAllToolTips();
|
2009-07-01 12:49:41 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
bool WatchTreeView::event(QEvent *ev)
|
2009-07-01 12:49:41 +02:00
|
|
|
{
|
|
|
|
|
if (m_grabbing && ev->type() == QEvent::MouseButtonPress) {
|
|
|
|
|
QMouseEvent *mev = static_cast<QMouseEvent *>(ev);
|
|
|
|
|
m_grabbing = false;
|
|
|
|
|
releaseMouse();
|
2010-11-05 19:38:40 +01:00
|
|
|
currentEngine()->watchPoint(mapToGlobal(mev->pos()));
|
2009-07-01 12:49:41 +02:00
|
|
|
}
|
2012-05-18 02:28:41 +02:00
|
|
|
return BaseTreeView::event(ev);
|
2009-07-01 12:49:41 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-15 22:39:39 +03:00
|
|
|
void WatchTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
2012-10-05 13:42:14 +02:00
|
|
|
{
|
|
|
|
|
emit currentIndexChanged(current);
|
2013-08-15 22:39:39 +03:00
|
|
|
BaseTreeView::currentChanged(current, previous);
|
2012-10-05 13:42:14 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::editItem(const QModelIndex &idx)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(idx) // FIXME
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::setModel(QAbstractItemModel *model)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-03-29 14:20:45 +02:00
|
|
|
BaseTreeView::setModel(model);
|
2012-05-18 02:28:41 +02:00
|
|
|
setRootIndex(model->index(m_type, 0, QModelIndex()));
|
2012-03-29 14:20:45 +02:00
|
|
|
setRootIsDecorated(true);
|
2011-03-16 18:48:14 +01:00
|
|
|
if (header()) {
|
|
|
|
|
header()->setDefaultAlignment(Qt::AlignLeft);
|
2012-04-18 14:20:54 +02:00
|
|
|
if (m_type != LocalsType && m_type != InspectType)
|
2011-03-16 18:48:14 +01:00
|
|
|
header()->hide();
|
|
|
|
|
}
|
2009-03-25 13:05:12 +01:00
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
connect(model, SIGNAL(layoutChanged()), SLOT(resetHelper()));
|
2012-05-18 02:28:41 +02:00
|
|
|
connect(model, SIGNAL(currentIndexRequested(QModelIndex)),
|
2012-04-18 14:20:54 +02:00
|
|
|
SLOT(setCurrentIndex(QModelIndex)));
|
2012-05-18 02:28:41 +02:00
|
|
|
connect(model, SIGNAL(itemIsExpanded(QModelIndex)),
|
|
|
|
|
SLOT(handleItemIsExpanded(QModelIndex)));
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-09 17:39:41 +02:00
|
|
|
void WatchTreeView::rowActivated(const QModelIndex &index)
|
2012-11-23 13:35:44 +01:00
|
|
|
{
|
|
|
|
|
currentEngine()->watchDataSelected(currentEngine()->watchHandler()->watchData(index)->iname);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
void WatchTreeView::handleItemIsExpanded(const QModelIndex &idx)
|
|
|
|
|
{
|
|
|
|
|
bool on = idx.data(LocalsExpandedRole).toBool();
|
|
|
|
|
QTC_ASSERT(on, return);
|
|
|
|
|
if (!isExpanded(idx))
|
|
|
|
|
expand(idx);
|
2009-03-25 13:05:12 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::resetHelper()
|
2009-03-25 13:05:12 +01:00
|
|
|
{
|
2012-05-18 02:28:41 +02:00
|
|
|
QModelIndex idx = model()->index(m_type, 0);
|
|
|
|
|
resetHelper(idx);
|
|
|
|
|
expand(idx);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::resetHelper(const QModelIndex &idx)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
if (idx.data(LocalsExpandedRole).toBool()) {
|
2009-03-25 13:05:12 +01:00
|
|
|
//qDebug() << "EXPANDING " << model()->data(idx, INameRole);
|
2012-03-29 14:20:45 +02:00
|
|
|
if (!isExpanded(idx)) {
|
|
|
|
|
expand(idx);
|
2010-11-25 18:44:07 +01:00
|
|
|
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
|
|
|
|
|
QModelIndex idx1 = model()->index(i, 0, idx);
|
|
|
|
|
resetHelper(idx1);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-03-25 13:05:12 +01:00
|
|
|
} else {
|
|
|
|
|
//qDebug() << "COLLAPSING " << model()->data(idx, INameRole);
|
2012-03-29 14:20:45 +02:00
|
|
|
if (isExpanded(idx))
|
|
|
|
|
collapse(idx);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
void WatchTreeView::reset()
|
|
|
|
|
{
|
|
|
|
|
BaseTreeView::reset();
|
|
|
|
|
setRootIndex(model()->index(m_type, 0));
|
|
|
|
|
resetHelper();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::watchExpression(const QString &exp)
|
2010-06-23 15:13:51 +02:00
|
|
|
{
|
2012-08-31 11:34:27 +02:00
|
|
|
watchExpression(exp, QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchTreeView::watchExpression(const QString &exp, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
currentEngine()->watchHandler()->watchExpression(exp, name);
|
2010-06-23 15:13:51 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::setModelData
|
2010-06-16 11:08:54 +02:00
|
|
|
(int role, const QVariant &value, const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(model(), return);
|
|
|
|
|
model()->setData(index, value, role);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|