2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
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
|
|
|
#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"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerconstants.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"
|
2011-04-08 16:18:47 +02:00
|
|
|
#include "debuggerstartparameters.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
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2009-03-19 15:24:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMetaObject>
|
|
|
|
|
#include <QMetaProperty>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QMimeData>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QPalette>
|
|
|
|
|
#include <QClipboard>
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QItemDelegate>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QMessageBox>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// WatchDelegate
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
QLineEdit *lineEdit = new QLineEdit(parent);
|
|
|
|
|
lineEdit->setFrame(false);
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
return m.data(LocalsAddressRole).toULongLong();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
static inline quint64 pointerValueOf(const QModelIndex &m)
|
2011-05-17 11:30:44 +02:00
|
|
|
{
|
|
|
|
|
return m.data(LocalsPointerValueRole).toULongLong();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn variableMemoryMarkup()
|
|
|
|
|
|
|
|
|
|
\brief Creates markup for a variable in the memory view.
|
|
|
|
|
|
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-04-19 12:17:48 +02:00
|
|
|
typedef QList<MemoryMarkup> MemoryMarkupList;
|
2011-04-08 16:18:47 +02:00
|
|
|
|
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));
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 15:43:00 +02:00
|
|
|
// Condense ranges of identical color into markup ranges. Assign member colors
|
|
|
|
|
// interchangeably.
|
|
|
|
|
const QColor baseColor = 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
|
|
|
QColor memberColor1 = QColor(Qt::yellow).lighter();
|
|
|
|
|
QColor memberColor2 = QColor(Qt::cyan).lighter();
|
|
|
|
|
|
|
|
|
|
int lastColorNumber = 0;
|
|
|
|
|
int childNumber = 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;
|
2011-04-21 12:32:36 +02:00
|
|
|
// Base colors: Parent/register
|
|
|
|
|
QColor color = range.first == registerColorNumber ? registerColor : baseColor;
|
|
|
|
|
if (range.first && range.first != registerColorNumber) {
|
2011-04-12 15:43:00 +02:00
|
|
|
if (childNumber++ & 1) { // Alternating member colors.
|
2011-04-19 12:17:48 +02:00
|
|
|
color = memberColor1;
|
2011-04-12 15:43:00 +02:00
|
|
|
memberColor1 = memberColor1.darker(120);
|
|
|
|
|
} else {
|
2011-04-19 12:17:48 +02:00
|
|
|
color = memberColor2;
|
2011-04-12 15:43:00 +02:00
|
|
|
memberColor2 = memberColor2.darker(120);
|
|
|
|
|
}
|
|
|
|
|
} // color switch
|
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,
|
|
|
|
|
const QModelIndex &m, bool deferencePointer,
|
|
|
|
|
const QPoint &p, QWidget *parent)
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
|
|
|
|
const QColor background = parent->palette().color(QPalette::Normal, QPalette::Base);
|
|
|
|
|
const quint64 address = deferencePointer ? pointerValueOf(m) : addressOf(m);
|
|
|
|
|
// 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);
|
|
|
|
|
const bool sizeIsEstimate = deferencePointer || !typeSize;
|
|
|
|
|
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;
|
|
|
|
|
const QString title = deferencePointer
|
2012-03-29 14:20:45 +02:00
|
|
|
? WatchTreeView::tr("Memory Referenced by Pointer \"%1\" (0x%2)")
|
2011-08-03 13:30:06 +02:00
|
|
|
.arg(nameOf(m)).arg(address, 0, 16)
|
2012-03-29 14:20:45 +02:00
|
|
|
: WatchTreeView::tr("Memory at Variable \"%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
|
|
|
{
|
|
|
|
|
typedef QPair<quint64, QString> RegisterValueNamePair;
|
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);
|
2011-04-21 13:39:40 +02:00
|
|
|
if (idx.data(LocalsReferencingAddressRole).toULongLong() == 0) {
|
|
|
|
|
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();
|
|
|
|
|
if (value < start && start - value < 512) {
|
|
|
|
|
start = value;
|
|
|
|
|
} else if (value > end && value - end < 512) {
|
|
|
|
|
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-03-29 14:20:45 +02:00
|
|
|
QModelIndexList indices = selectionModel()->selectedRows();
|
|
|
|
|
if (indices.isEmpty() && selectionModel()->currentIndex().isValid())
|
|
|
|
|
indices.append(selectionModel()->currentIndex());
|
2012-05-24 16:49:18 +02:00
|
|
|
WatchHandler *handler = currentEngine()->watchHandler();
|
|
|
|
|
foreach (const QModelIndex &idx, indices)
|
|
|
|
|
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()) {
|
2010-06-23 15:13:51 +02:00
|
|
|
watchExpression(ev->mimeData()->text());
|
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("..."));
|
|
|
|
|
}
|
2012-05-14 11:21:01 +02:00
|
|
|
return WatchTreeView::tr("Remove Expression Evaluator for \"%1\"").arg(exp);
|
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();
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
|
clipboard->setText(clipboardText, QClipboard::Selection);
|
|
|
|
|
#endif
|
|
|
|
|
clipboard->setText(clipboardText, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-11-05 19:38:40 +01:00
|
|
|
DebuggerEngine *engine = currentEngine();
|
|
|
|
|
WatchHandler *handler = engine->watchHandler();
|
|
|
|
|
|
2010-03-17 12:38:37 +01:00
|
|
|
const QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
const QModelIndex mi0 = idx.sibling(idx.row(), 0);
|
|
|
|
|
const QModelIndex mi1 = idx.sibling(idx.row(), 1);
|
|
|
|
|
const QModelIndex mi2 = idx.sibling(idx.row(), 2);
|
2011-04-08 16:18:47 +02:00
|
|
|
const quint64 address = addressOf(mi0);
|
|
|
|
|
const uint size = sizeOf(mi0);
|
|
|
|
|
const quint64 pointerValue = pointerValueOf(mi0);
|
2010-06-16 11:08:54 +02:00
|
|
|
const QString exp = mi0.data(LocalsExpressionRole).toString();
|
2011-05-10 15:57:33 +02:00
|
|
|
const QString name = mi0.data(LocalsNameRole).toString();
|
2010-06-16 11:08:54 +02:00
|
|
|
const QString type = mi2.data().toString();
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2011-05-10 15:57:33 +02:00
|
|
|
// Offer to open address pointed to or variable address.
|
|
|
|
|
const bool createPointerActions = pointerValue && pointerValue != address;
|
|
|
|
|
|
2010-03-17 12:38:37 +01:00
|
|
|
const QStringList alternativeFormats =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsTypeFormatListRole).toStringList();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int typeFormat =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsTypeFormatRole).toInt();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int individualFormat =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsIndividualFormatRole).toInt();
|
2011-02-17 19:00:33 +01:00
|
|
|
const int unprintableBase = handler->unprintableBase();
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2010-12-16 10:18:51 +01:00
|
|
|
QMenu formatMenu;
|
2009-07-03 11:20:47 +02:00
|
|
|
QList<QAction *> typeFormatActions;
|
2010-12-16 10:18:51 +01:00
|
|
|
QList<QAction *> individualFormatActions;
|
2010-05-19 15:15:56 +02:00
|
|
|
QAction *clearTypeFormatAction = 0;
|
2010-12-16 10:18:51 +01:00
|
|
|
QAction *clearIndividualFormatAction = 0;
|
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-11-07 20:07:14 +01:00
|
|
|
formatMenu.setTitle(tr("Change Local Display Format..."));
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableUnicode =
|
|
|
|
|
formatMenu.addAction(tr("Treat All Characters as Printable"));
|
|
|
|
|
showUnprintableUnicode->setCheckable(true);
|
|
|
|
|
showUnprintableUnicode->setChecked(unprintableBase == 0);
|
2011-08-03 17:04:32 +02:00
|
|
|
showUnprintableEscape =
|
|
|
|
|
formatMenu.addAction(tr("Show Unprintable Characters as Escape Sequences"));
|
|
|
|
|
showUnprintableEscape->setCheckable(true);
|
|
|
|
|
showUnprintableEscape->setChecked(unprintableBase == -1);
|
2011-03-23 12:16:37 +01:00
|
|
|
showUnprintableOctal =
|
|
|
|
|
formatMenu.addAction(tr("Show Unprintable Characters as Octal"));
|
|
|
|
|
showUnprintableOctal->setCheckable(true);
|
|
|
|
|
showUnprintableOctal->setChecked(unprintableBase == 8);
|
|
|
|
|
showUnprintableHexadecimal =
|
|
|
|
|
formatMenu.addAction(tr("Show Unprintable Characters as Hexadecimal"));
|
|
|
|
|
showUnprintableHexadecimal->setCheckable(true);
|
|
|
|
|
showUnprintableHexadecimal->setChecked(unprintableBase == 16);
|
|
|
|
|
if (idx.isValid() /*&& !alternativeFormats.isEmpty() */) {
|
|
|
|
|
const QString spacer = QLatin1String(" ");
|
2011-02-17 19:00:33 +01:00
|
|
|
formatMenu.addSeparator();
|
2010-12-16 10:18:51 +01:00
|
|
|
QAction *dummy = formatMenu.addAction(
|
2011-04-06 18:11:14 +02:00
|
|
|
tr("Change Display for Object Named \"%1\":").arg(mi0.data().toString()));
|
2010-12-16 10:18:51 +01:00
|
|
|
dummy->setEnabled(false);
|
2012-03-12 18:38:59 +01:00
|
|
|
QString msg = (individualFormat == -1 && typeFormat != -1)
|
|
|
|
|
? tr("Use Format for Type (Currently %1)")
|
|
|
|
|
.arg(alternativeFormats.at(typeFormat))
|
|
|
|
|
: tr("Use Display Format Based on Type ");
|
|
|
|
|
clearIndividualFormatAction = formatMenu.addAction(spacer + msg);
|
2011-04-06 18:11:14 +02:00
|
|
|
clearIndividualFormatAction->setCheckable(true);
|
2012-03-12 18:38:59 +01:00
|
|
|
clearIndividualFormatAction->setChecked(individualFormat == -1);
|
2010-12-16 10:18:51 +01:00
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
2011-03-23 12:16:37 +01:00
|
|
|
const QString format = spacer + alternativeFormats.at(i);
|
2010-12-16 10:18:51 +01:00
|
|
|
QAction *act = new QAction(format, &formatMenu);
|
|
|
|
|
act->setCheckable(true);
|
2012-03-12 18:38:59 +01:00
|
|
|
if (i == individualFormat)
|
2010-12-16 10:18:51 +01:00
|
|
|
act->setChecked(true);
|
|
|
|
|
formatMenu.addAction(act);
|
2011-04-06 18:11:14 +02:00
|
|
|
individualFormatActions.append(act);
|
2010-03-17 13:03:34 +01:00
|
|
|
}
|
2010-12-16 10:18:51 +01:00
|
|
|
formatMenu.addSeparator();
|
|
|
|
|
dummy = formatMenu.addAction(
|
2011-04-06 18:11:14 +02:00
|
|
|
tr("Change Display for Type \"%1\":").arg(type));
|
2010-12-16 10:18:51 +01:00
|
|
|
dummy->setEnabled(false);
|
2011-04-06 18:11:14 +02:00
|
|
|
clearTypeFormatAction = formatMenu.addAction(spacer + tr("Automatic"));
|
|
|
|
|
//clearTypeFormatAction->setEnabled(typeFormat != -1);
|
|
|
|
|
//clearTypeFormatAction->setEnabled(individualFormat != -1);
|
|
|
|
|
clearTypeFormatAction->setCheckable(true);
|
|
|
|
|
clearTypeFormatAction->setChecked(typeFormat == -1);
|
2010-12-16 10:18:51 +01:00
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
2011-03-23 12:16:37 +01:00
|
|
|
const QString format = spacer + alternativeFormats.at(i);
|
2010-12-16 10:18:51 +01:00
|
|
|
QAction *act = new QAction(format, &formatMenu);
|
|
|
|
|
act->setCheckable(true);
|
2011-04-06 18:11:14 +02:00
|
|
|
//act->setEnabled(individualFormat != -1);
|
|
|
|
|
if (i == typeFormat)
|
2010-12-16 10:18:51 +01:00
|
|
|
act->setChecked(true);
|
|
|
|
|
formatMenu.addAction(act);
|
2011-04-06 18:11:14 +02:00
|
|
|
typeFormatActions.append(act);
|
2009-10-07 14:29:55 +02:00
|
|
|
}
|
2009-07-08 09:02:36 +02:00
|
|
|
} else {
|
2011-03-23 12:16:37 +01:00
|
|
|
QAction *dummy = formatMenu.addAction(
|
|
|
|
|
tr("Change Display for Type or Item..."));
|
|
|
|
|
dummy->setEnabled(false);
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2011-05-10 15:57:33 +02:00
|
|
|
QMenu breakpointMenu;
|
|
|
|
|
breakpointMenu.setTitle(tr("Add Data Breakpoint..."));
|
2010-11-10 16:33:11 +01:00
|
|
|
QAction *actSetWatchpointAtVariableAddress = 0;
|
|
|
|
|
QAction *actSetWatchpointAtPointerValue = 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) {
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtVariableAddress =
|
2011-05-10 15:57:33 +02:00
|
|
|
new QAction(tr("Add Data Breakpoint at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16), &breakpointMenu);
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtVariableAddress->
|
2010-06-16 11:08:54 +02:00
|
|
|
setChecked(mi0.data(LocalsIsWatchpointAtAddressRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
if (createPointerActions) {
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtPointerValue =
|
2011-05-10 15:57:33 +02:00
|
|
|
new QAction(tr("Add Data Breakpoint at Referenced Address (0x%1)")
|
|
|
|
|
.arg(pointerValue, 0, 16), &breakpointMenu);
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtPointerValue->setCheckable(true);
|
|
|
|
|
actSetWatchpointAtPointerValue->
|
2010-06-16 11:08:54 +02:00
|
|
|
setChecked(mi0.data(LocalsIsWatchpointAtPointerValueRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
}
|
2010-05-07 15:16:31 +02:00
|
|
|
} else {
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtVariableAddress =
|
2011-05-10 15:57:33 +02:00
|
|
|
new QAction(tr("Add Data Breakpoint"), &breakpointMenu);
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtVariableAddress->setEnabled(false);
|
2010-05-07 15:16:31 +02:00
|
|
|
}
|
2010-11-10 16:33:11 +01:00
|
|
|
actSetWatchpointAtVariableAddress->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."));
|
|
|
|
|
|
2011-11-18 19:44:17 +01: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) {
|
2011-11-18 19:44:17 +01:00
|
|
|
actSetWatchpointAtExpression =
|
|
|
|
|
new QAction(tr("Add Data Breakpoint at Expression"),
|
|
|
|
|
&breakpointMenu);
|
|
|
|
|
actSetWatchpointAtExpression->setEnabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
actSetWatchpointAtExpression =
|
2011-05-10 15:57:33 +02:00
|
|
|
new QAction(tr("Add Data Breakpoint at Expression \"%1\"").arg(name),
|
|
|
|
|
&breakpointMenu);
|
2011-11-18 19:44:17 +01:00
|
|
|
}
|
2011-05-10 15:57:33 +02:00
|
|
|
actSetWatchpointAtExpression->setToolTip(
|
|
|
|
|
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."));
|
|
|
|
|
|
|
|
|
|
breakpointMenu.addAction(actSetWatchpointAtVariableAddress);
|
|
|
|
|
if (actSetWatchpointAtPointerValue)
|
|
|
|
|
breakpointMenu.addAction(actSetWatchpointAtPointerValue);
|
|
|
|
|
breakpointMenu.addAction(actSetWatchpointAtExpression);
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
2011-08-25 11:43:07 +02:00
|
|
|
QAction *actInsertNewWatchItem =
|
2012-05-14 11:21:01 +02:00
|
|
|
menu.addAction(tr("Insert New Expression Evaluator"));
|
2011-05-10 15:57:33 +02:00
|
|
|
actInsertNewWatchItem->setEnabled(canHandleWatches && canInsertWatches);
|
2012-05-16 12:31:07 +02:00
|
|
|
QAction *actSelectWidgetToWatch =
|
|
|
|
|
menu.addAction(tr("Select Widget to Add into Expression Evaluator"));
|
2012-05-16 13:42:00 +02:00
|
|
|
actSelectWidgetToWatch->setEnabled(canHandleWatches && canInsertWatches
|
2012-05-16 12:31:07 +02:00
|
|
|
&& engine->hasCapability(WatchWidgetsCapability));
|
|
|
|
|
|
2011-05-10 15:57:33 +02:00
|
|
|
menu.addSeparator();
|
2010-05-07 15:16:31 +02:00
|
|
|
|
2010-11-25 13:51:54 +01:00
|
|
|
QAction *actWatchExpression = new QAction(addWatchActionText(exp), &menu);
|
2010-07-14 14:52:14 +02:00
|
|
|
actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty());
|
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();
|
|
|
|
|
QAction *actRemoveWatchExpression = new QAction(removeWatchActionText(removeExp), &menu);
|
2010-11-04 11:27:23 +01:00
|
|
|
actRemoveWatchExpression->setEnabled(
|
|
|
|
|
(canHandleWatches || state == DebuggerNotReady) && !exp.isEmpty());
|
2011-08-25 11:43:07 +02:00
|
|
|
QAction *actRemoveWatches =
|
2012-05-14 11:21:01 +02:00
|
|
|
new QAction(tr("Remove All Expression Evaluators"), &menu);
|
2011-01-14 17:28:37 +01:00
|
|
|
actRemoveWatches->setEnabled(!WatchHandler::watcherNames().isEmpty());
|
2010-06-23 15:13:51 +02:00
|
|
|
|
2012-05-16 13:38:59 +02:00
|
|
|
if (m_type == LocalsType) {
|
2010-06-23 15:13:51 +02:00
|
|
|
menu.addAction(actWatchExpression);
|
2012-05-16 13:38:59 +02:00
|
|
|
} else if (m_type == WatchersType) {
|
2010-06-23 15:13:51 +02:00
|
|
|
menu.addAction(actRemoveWatchExpression);
|
2011-01-14 17:28:37 +01:00
|
|
|
menu.addAction(actRemoveWatches);
|
|
|
|
|
}
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2010-12-16 12:07:12 +01:00
|
|
|
QMenu memoryMenu;
|
|
|
|
|
memoryMenu.setTitle(tr("Open Memory Editor..."));
|
|
|
|
|
QAction *actOpenMemoryEditAtVariableAddress = new QAction(&memoryMenu);
|
|
|
|
|
QAction *actOpenMemoryEditAtPointerValue = new QAction(&memoryMenu);
|
|
|
|
|
QAction *actOpenMemoryEditor = new QAction(&memoryMenu);
|
2011-04-21 12:32:36 +02:00
|
|
|
QAction *actOpenMemoryEditorStackLayout = new QAction(&memoryMenu);
|
2011-04-08 16:18:47 +02:00
|
|
|
QAction *actOpenMemoryViewAtVariableAddress = new QAction(&memoryMenu);
|
|
|
|
|
QAction *actOpenMemoryViewAtPointerValue = new QAction(&memoryMenu);
|
2012-01-12 20:28:17 +01:00
|
|
|
if (engine->hasCapability(ShowMemoryCapability)) {
|
2010-12-16 12:07:12 +01:00
|
|
|
actOpenMemoryEditor->setText(tr("Open Memory Editor..."));
|
|
|
|
|
if (address) {
|
|
|
|
|
actOpenMemoryEditAtVariableAddress->setText(
|
|
|
|
|
tr("Open Memory Editor at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16));
|
2011-04-08 16:18:47 +02:00
|
|
|
actOpenMemoryViewAtVariableAddress->setText(
|
|
|
|
|
tr("Open Memory View at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16));
|
2010-12-16 12:07:12 +01:00
|
|
|
} else {
|
|
|
|
|
actOpenMemoryEditAtVariableAddress->setText(
|
|
|
|
|
tr("Open Memory Editor at Object's Address"));
|
|
|
|
|
actOpenMemoryEditAtVariableAddress->setEnabled(false);
|
2011-04-08 16:18:47 +02:00
|
|
|
actOpenMemoryViewAtVariableAddress->setText(
|
|
|
|
|
tr("Open Memory View at Object's Address"));
|
|
|
|
|
actOpenMemoryViewAtVariableAddress->setEnabled(false);
|
2010-12-16 12:07:12 +01:00
|
|
|
}
|
|
|
|
|
if (createPointerActions) {
|
|
|
|
|
actOpenMemoryEditAtPointerValue->setText(
|
|
|
|
|
tr("Open Memory Editor at Referenced Address (0x%1)")
|
|
|
|
|
.arg(pointerValue, 0, 16));
|
2011-04-08 16:18:47 +02:00
|
|
|
actOpenMemoryViewAtPointerValue->setText(
|
|
|
|
|
tr("Open Memory View at Referenced Address (0x%1)")
|
|
|
|
|
.arg(pointerValue, 0, 16));
|
2010-12-16 12:07:12 +01:00
|
|
|
} else {
|
|
|
|
|
actOpenMemoryEditAtPointerValue->setText(
|
|
|
|
|
tr("Open Memory Editor at Referenced Address"));
|
|
|
|
|
actOpenMemoryEditAtPointerValue->setEnabled(false);
|
2011-04-08 16:18:47 +02:00
|
|
|
actOpenMemoryViewAtPointerValue->setText(
|
|
|
|
|
tr("Open Memory View at Referenced Address"));
|
|
|
|
|
actOpenMemoryViewAtPointerValue->setEnabled(false);
|
2010-12-16 12:07:12 +01:00
|
|
|
}
|
2011-08-25 11:43:07 +02:00
|
|
|
actOpenMemoryEditorStackLayout->setText(
|
|
|
|
|
tr("Open Memory Editor Showing Stack Layout"));
|
2011-04-21 15:34:19 +02:00
|
|
|
actOpenMemoryEditorStackLayout->setEnabled(m_type == LocalsType);
|
2011-04-08 16:18:47 +02:00
|
|
|
memoryMenu.addAction(actOpenMemoryViewAtVariableAddress);
|
|
|
|
|
memoryMenu.addAction(actOpenMemoryViewAtPointerValue);
|
2010-12-16 12:07:12 +01:00
|
|
|
memoryMenu.addAction(actOpenMemoryEditAtVariableAddress);
|
|
|
|
|
memoryMenu.addAction(actOpenMemoryEditAtPointerValue);
|
2011-04-21 12:32:36 +02:00
|
|
|
memoryMenu.addAction(actOpenMemoryEditorStackLayout);
|
2010-12-16 12:07:12 +01:00
|
|
|
memoryMenu.addAction(actOpenMemoryEditor);
|
|
|
|
|
} else {
|
|
|
|
|
memoryMenu.setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 09:40:43 +01:00
|
|
|
QAction *actCopy = new QAction(tr("Copy Contents to Clipboard"), &menu);
|
2011-04-12 16:17:19 +02:00
|
|
|
QAction *actCopyValue = new QAction(tr("Copy Value to Clipboard"), &menu);
|
|
|
|
|
actCopyValue->setEnabled(idx.isValid());
|
|
|
|
|
|
2011-02-14 09:40:43 +01:00
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
menu.addAction(actInsertNewWatchItem);
|
|
|
|
|
menu.addAction(actSelectWidgetToWatch);
|
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);
|
2011-04-12 16:17:19 +02:00
|
|
|
menu.addAction(actCopy);
|
|
|
|
|
menu.addAction(actCopyValue);
|
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));
|
2009-10-07 13:36:48 +02:00
|
|
|
|
2010-09-28 13:09:19 +02:00
|
|
|
QAction *actShowInEditor
|
|
|
|
|
= new QAction(tr("Show View Contents in Editor"), &menu);
|
|
|
|
|
actShowInEditor->setEnabled(actionsEnabled);
|
|
|
|
|
menu.addAction(actShowInEditor);
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(SettingsDialog));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-25 11:43:07 +02:00
|
|
|
QAction *actCloseEditorToolTips =
|
|
|
|
|
new QAction(tr("Close Editor Tooltips"), &menu);
|
2011-02-21 16:45:07 +01:00
|
|
|
actCloseEditorToolTips->setEnabled(DebuggerToolTipManager::instance()->hasToolTips());
|
|
|
|
|
menu.addAction(actCloseEditorToolTips);
|
|
|
|
|
|
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) {
|
|
|
|
|
;
|
|
|
|
|
} 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);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actOpenMemoryEditAtVariableAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actOpenMemoryEditAtPointerValue) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), false, mi0, true, ev->globalPos(), this);
|
2010-05-19 17:34:47 +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());
|
2011-04-08 16:18:47 +02:00
|
|
|
} else if (act == actOpenMemoryViewAtVariableAddress) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), true, mi0, false, ev->globalPos(), this);
|
2011-04-08 16:18:47 +02:00
|
|
|
} else if (act == actOpenMemoryViewAtPointerValue) {
|
2011-04-19 12:17:48 +02:00
|
|
|
addVariableMemoryView(currentEngine(), true, mi0, true, ev->globalPos(), this);
|
2011-04-21 12:32:36 +02:00
|
|
|
} else if (act == actOpenMemoryEditorStackLayout) {
|
2011-07-28 14:47:49 +02:00
|
|
|
addStackLayoutMemoryView(currentEngine(), false, model(), ev->globalPos(), this);
|
2010-11-10 16:33:11 +01:00
|
|
|
} else if (act == actSetWatchpointAtVariableAddress) {
|
2012-06-03 21:59:21 +02:00
|
|
|
breakHandler()->setWatchpointAtAddress(address, size);
|
2010-11-10 16:33:11 +01:00
|
|
|
} else if (act == actSetWatchpointAtPointerValue) {
|
2012-06-03 21:59:21 +02:00
|
|
|
breakHandler()->setWatchpointAtAddress(pointerValue, sizeof(void *)); // FIXME: an approximation..
|
2011-05-10 15:57:33 +02:00
|
|
|
} else if (act == actSetWatchpointAtExpression) {
|
2012-06-03 21:59:21 +02:00
|
|
|
breakHandler()->setWatchpointAtExpression(name);
|
2009-08-12 10:51:25 +02:00
|
|
|
} else if (act == actSelectWidgetToWatch) {
|
2009-07-01 12:49:41 +02:00
|
|
|
grabMouse(Qt::CrossCursor);
|
|
|
|
|
m_grabbing = true;
|
2010-06-23 15:13:51 +02:00
|
|
|
} else if (act == actWatchExpression) {
|
|
|
|
|
watchExpression(exp);
|
|
|
|
|
} else if (act == actRemoveWatchExpression) {
|
2012-05-24 16:49:18 +02:00
|
|
|
handler->removeData(p.data(LocalsINameRole).toByteArray());
|
2011-04-12 16:17:19 +02:00
|
|
|
} else if (act == actCopy) {
|
2011-05-27 11:02:57 +02:00
|
|
|
copyToClipboard(DebuggerToolTipWidget::treeModelClipboardContents(model()));
|
2011-04-12 16:17:19 +02:00
|
|
|
} else if (act == actCopyValue) {
|
|
|
|
|
copyToClipboard(mi1.data().toString());
|
2011-01-14 17:28:37 +01:00
|
|
|
} else if (act == actRemoveWatches) {
|
2012-05-24 16:49:18 +02:00
|
|
|
handler->clearWatches();
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == clearTypeFormatAction) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsTypeFormatRole, -1, mi1);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == clearIndividualFormatAction) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsIndividualFormatRole, -1, mi1);
|
2010-09-08 09:09:09 +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);
|
2011-02-17 19:00:33 +01:00
|
|
|
} else if (act == showUnprintableUnicode) {
|
|
|
|
|
handler->setUnprintableBase(0);
|
2011-08-03 17:04:32 +02:00
|
|
|
} else if (act == showUnprintableEscape) {
|
|
|
|
|
handler->setUnprintableBase(-1);
|
2011-02-17 19:00:33 +01:00
|
|
|
} else if (act == showUnprintableOctal) {
|
|
|
|
|
handler->setUnprintableBase(8);
|
|
|
|
|
} else if (act == showUnprintableHexadecimal) {
|
|
|
|
|
handler->setUnprintableBase(16);
|
2011-02-21 16:45:07 +01:00
|
|
|
} else if (act == actCloseEditorToolTips) {
|
|
|
|
|
DebuggerToolTipManager::instance()->closeAllToolTips();
|
2011-09-30 12:28:55 +02:00
|
|
|
} else if (handleBaseContextAction(act)) {
|
|
|
|
|
;
|
2010-01-29 21:33:57 +01:00
|
|
|
} else {
|
2010-03-17 13:03:34 +01:00
|
|
|
for (int i = 0; i != typeFormatActions.size(); ++i) {
|
2009-07-03 11:20:47 +02:00
|
|
|
if (act == typeFormatActions.at(i))
|
2010-06-23 16:30:42 +02:00
|
|
|
setModelData(LocalsTypeFormatRole, i, mi1);
|
2010-03-17 13:03:34 +01:00
|
|
|
}
|
|
|
|
|
for (int i = 0; i != individualFormatActions.size(); ++i) {
|
|
|
|
|
if (act == individualFormatActions.at(i))
|
2010-06-23 16:30:42 +02:00
|
|
|
setModelData(LocalsIndividualFormatRole, i, mi1);
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
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)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-11-05 19:38:40 +01:00
|
|
|
currentEngine()->watchHandler()->watchExpression(exp);
|
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
|