debugger: more handler/window refactoring

This commit is contained in:
hjk
2010-11-05 19:38:40 +01:00
parent 1dacb9e55f
commit b373da1b12
23 changed files with 297 additions and 489 deletions

View File

@@ -214,36 +214,9 @@ enum ModelRoles
LocalsPointerValueRole, // Pointer value (address) as quint64
LocalsIsWatchpointAtAddressRole,
LocalsIsWatchpointAtPointerValueRole,
RequestShowInEditorRole,
RequestWatchPointRole,
RequestToggleWatchRole,
RequestToolTipByExpressionRole,
RequestClearCppCodeModelSnapshotRole,
RequestWatchExpressionRole,
RequestRemoveWatchExpressionRole,
// Stack
StackFrameAddressRole,
RequestActivateFrameRole,
RequestReloadFullStackRole,
RequestShowMemoryRole,
RequestShowDisassemblerRole,
// Modules
RequestReloadModulesRole,
RequestExamineModulesRole,
RequestModuleSymbolsRole,
RequestAllSymbolsRole,
RequestOpenFileRole,
// Snapshots
SnapshotCapabilityRole,
RequestCreateSnapshotRole,
RequestActivateSnapshotRole,
RequestRemoveSnapshotRole,
// Sources
RequestReloadSourceFilesRole,
};
enum DebuggerEngineType

View File

@@ -224,10 +224,10 @@ public:
m_lastGoodState(DebuggerNotReady),
m_targetState(DebuggerNotReady),
m_commandHandler(engine),
m_modulesHandler(engine),
m_modulesHandler(),
m_registerHandler(),
m_sourceFilesHandler(engine),
m_stackHandler(engine),
m_sourceFilesHandler(),
m_stackHandler(),
m_threadsHandler(),
m_watchHandler(engine),
m_disassemblerViewAgent(engine),
@@ -248,25 +248,29 @@ public slots:
void doInterruptInferior();
void doFinishDebugger();
void queueRunEngine() {
void queueRunEngine()
{
m_engine->setState(EngineRunRequested);
m_engine->showMessage(_("QUEUE: RUN ENGINE"));
QTimer::singleShot(0, this, SLOT(doRunEngine()));
}
void queueShutdownEngine() {
void queueShutdownEngine()
{
m_engine->setState(EngineShutdownRequested);
m_engine->showMessage(_("QUEUE: SHUTDOWN ENGINE"));
QTimer::singleShot(0, this, SLOT(doShutdownEngine()));
}
void queueShutdownInferior() {
void queueShutdownInferior()
{
m_engine->setState(InferiorShutdownRequested);
m_engine->showMessage(_("QUEUE: SHUTDOWN INFERIOR"));
QTimer::singleShot(0, this, SLOT(doShutdownInferior()));
}
void queueFinishDebugger() {
void queueFinishDebugger()
{
QTC_ASSERT(state() == EngineShutdownOk
|| state() == EngineShutdownFailed, qDebug() << state());
m_engine->setState(DebuggerFinished);
@@ -274,7 +278,8 @@ public slots:
QTimer::singleShot(0, this, SLOT(doFinishDebugger()));
}
void raiseApplication() {
void raiseApplication()
{
QTC_ASSERT(m_runControl, return);
m_runControl->bringApplicationToForeground(m_inferiorPid);
}
@@ -514,30 +519,9 @@ void DebuggerEngine::removeTooltip()
void DebuggerEngine::handleCommand(int role, const QVariant &value)
{
if (role != RequestToolTipByExpressionRole)
removeTooltip();
removeTooltip();
switch (role) {
case RequestActivateFrameRole:
activateFrame(value.toInt());
break;
case RequestReloadFullStackRole:
reloadFullStack();
break;
case RequestReloadSourceFilesRole:
reloadSourceFiles();
break;
case RequestReloadModulesRole:
reloadModules();
break;
//case RequestReloadRegistersRole:
// reloadRegisters();
// break;
case RequestExecDetachRole:
detachDebugger();
break;
@@ -590,10 +574,6 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
d->queueShutdownInferior();
break;
case RequestCreateSnapshotRole:
createSnapshot();
break;
case RequestActivationRole:
setActive(value.toBool());
break;
@@ -614,29 +594,12 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
executeDebuggerCommand(value.toString());
break;
case RequestToolTipByExpressionRole: {
QList<QVariant> list = value.toList();
QTC_ASSERT(list.size() == 3, break);
QPoint point = list.at(0).value<QPoint>();
TextEditor::ITextEditor *editor = // Eeks.
(TextEditor::ITextEditor *)(list.at(1).value<quint64>());
int pos = list.at(2).toInt();
setToolTipExpression(point, editor, pos);
break;
}
case RequestContextMenuRole: {
QList<QVariant> list = value.toList();
QTC_ASSERT(list.size() == 3, break);
d->handleContextMenuRequest(list);
break;
}
case RequestShowMemoryRole: {
qDebug() << "CREATING MEMORY VIEW";
(void) MemoryViewAgent(this, "0x0");
break;
}
}
}

View File

@@ -823,7 +823,7 @@ struct DebuggerActions
QAction *jumpToLineAction; // in the Debug menu
QAction *returnFromFunctionAction;
QAction *nextAction;
QAction *snapshotAction;
//QAction *snapshotAction;
QAction *watchAction1; // in the Debug menu
QAction *watchAction2; // in the text editor context menu
QAction *breakAction;
@@ -854,19 +854,29 @@ public:
void notifyCurrentEngine(int role, const QVariant &value = QVariant());
void connectEngine(DebuggerEngine *engine, bool notify = true);
void disconnectEngine() { connectEngine(0); }
DebuggerEngine *currentEngine() const { return m_currentEngine; }
public slots:
void updateWatchersHeader(int section, int, int newSize)
{ m_watchersWindow->header()->resizeSection(section, newSize); }
{
m_watchersWindow->header()->resizeSection(section, newSize);
}
void sourceFilesDockToggled(bool on)
{ if (on) notifyCurrentEngine(RequestReloadSourceFilesRole); }
{
if (on)
m_currentEngine->reloadSourceFiles();
}
void modulesDockToggled(bool on)
{ if (on) notifyCurrentEngine(RequestReloadModulesRole); }
{
if (on)
m_currentEngine->reloadModules();
}
void registerDockToggled(bool on)
{
if (on && m_currentEngine)
if (on)
m_currentEngine->reloadRegisters();
}
@@ -1137,8 +1147,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
m_registerWindow = new RegisterWindow;
m_registerWindow->setObjectName(QLatin1String("CppDebugRegisters"));
m_snapshotWindow = new SnapshotWindow;
m_snapshotWindow->setObjectName(QLatin1String("CppDebugSnapshots"));
m_stackWindow = new StackWindow;
m_stackWindow->setObjectName(QLatin1String("CppDebugStack"));
m_sourceFilesWindow = new SourceFilesWindow;
@@ -1160,6 +1168,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
// Snapshot
m_snapshotHandler = new SnapshotHandler;
m_snapshotWindow = new SnapshotWindow(m_snapshotHandler);
m_snapshotWindow->setObjectName(QLatin1String("CppDebugSnapshots"));
m_snapshotWindow->setModel(m_snapshotHandler->model());
// Debug mode setup
@@ -1227,10 +1237,10 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
m_actions.watchAction2 = new QAction(tr("Add to Watch Window"), this);
m_actions.watchAction2->setProperty(Role, RequestExecWatchRole);
m_actions.snapshotAction = new QAction(tr("Create Snapshot"), this);
m_actions.snapshotAction->setProperty(Role, RequestCreateSnapshotRole);
m_actions.snapshotAction->setIcon(
QIcon(__(":/debugger/images/debugger_snapshot_small.png")));
//m_actions.snapshotAction = new QAction(tr("Create Snapshot"), this);
//m_actions.snapshotAction->setProperty(Role, RequestCreateSnapshotRole);
//m_actions.snapshotAction->setIcon(
// QIcon(__(":/debugger/images/debugger_snapshot_small.png")));
m_actions.reverseDirectionAction =
new QAction(tr("Reverse Direction"), this);
@@ -1261,7 +1271,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
connect(m_actions.returnFromFunctionAction, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.watchAction1, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.watchAction2, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.snapshotAction, SIGNAL(triggered()), SLOT(onAction()));
//connect(m_actions.snapshotAction, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.frameDownAction, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.frameUpAction, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.stopAction, SIGNAL(triggered()), SLOT(onAction()));
@@ -1514,11 +1524,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
m_uiSwitcher->addMenuAction(cmd, CppLanguage);
cmd = am->registerAction(m_actions.snapshotAction,
Constants::SNAPSHOT, cppDebuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::SNAPSHOT_KEY));
cmd->setAttribute(Command::CA_Hide);
m_uiSwitcher->addMenuAction(cmd, CppLanguage);
//cmd = am->registerAction(m_actions.snapshotAction,
// Constants::SNAPSHOT, cppDebuggercontext);
//cmd->setDefaultKeySequence(QKeySequence(Constants::SNAPSHOT_KEY));
//cmd->setAttribute(Command::CA_Hide);
//m_uiSwitcher->addMenuAction(cmd, CppLanguage);
cmd = am->registerAction(m_actions.frameDownAction,
Constants::FRAME_DOWN, cppDebuggercontext);
@@ -2025,7 +2035,8 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
toggleBreakpoint(editor->file()->fileName(), lineNumber);
}
void DebuggerPluginPrivate::showToolTip(ITextEditor *editor, const QPoint &point, int pos)
void DebuggerPluginPrivate::showToolTip(ITextEditor *editor,
const QPoint &point, int pos)
{
if (!isDebuggable(editor))
return;
@@ -2033,12 +2044,7 @@ void DebuggerPluginPrivate::showToolTip(ITextEditor *editor, const QPoint &point
return;
if (state() != InferiorStopOk)
return;
QList<QVariant> list;
list.append(point);
list.append(quint64(editor));
list.append(pos);
notifyCurrentEngine(RequestToolTipByExpressionRole, list);
currentEngine()->setToolTipExpression(point, editor, pos);
}
DebuggerRunControl *DebuggerPluginPrivate::createDebugger
@@ -2264,7 +2270,7 @@ void DebuggerPluginPrivate::setInitialState()
m_actions.watchAction1->setEnabled(true);
m_actions.watchAction2->setEnabled(true);
m_actions.breakAction->setEnabled(true);
m_actions.snapshotAction->setEnabled(false);
//m_actions.snapshotAction->setEnabled(false);
theDebuggerAction(OperateByInstruction)->setEnabled(false);
m_actions.stopAction->setEnabled(false);
@@ -2393,7 +2399,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.watchAction1->setEnabled(true);
m_actions.watchAction2->setEnabled(true);
m_actions.breakAction->setEnabled(true);
m_actions.snapshotAction->setEnabled(stopped && (caps & SnapshotCapability));
//m_actions.snapshotAction->setEnabled(stopped && (caps & SnapshotCapability));
theDebuggerAction(OperateByInstruction)->setEnabled(stopped);
@@ -2562,11 +2568,8 @@ void DebuggerPluginPrivate::scriptExpressionEntered(const QString &expression)
void DebuggerPluginPrivate::openMemoryEditor()
{
AddressDialog dialog;
if (dialog.exec() != QDialog::Accepted)
return;
QTC_ASSERT(m_watchersWindow, return);
m_watchersWindow->model()->setData(
QModelIndex(), dialog.address(), RequestShowMemoryRole);
if (dialog.exec() == QDialog::Accepted)
(void) new MemoryViewAgent(currentEngine(), dialog.address());
}
void DebuggerPluginPrivate::coreShutdown()
@@ -2874,6 +2877,11 @@ Internal::BreakHandler *DebuggerPlugin::breakHandler() const
return d->m_breakHandler;
}
Internal::SnapshotHandler *DebuggerPlugin::snapshotHandler() const
{
return d->m_snapshotHandler;
}
DebuggerEngine *DebuggerPlugin::currentEngine() const
{
return d->m_currentEngine;

View File

@@ -57,6 +57,7 @@ class DebuggerStartParameters;
namespace Internal {
class BreakHandler;
class SnapshotHandler;
}
class DEBUGGER_EXPORT DebuggerPlugin : public ExtensionSystem::IPlugin
@@ -91,6 +92,7 @@ public:
void openTextEditor(const QString &titlePattern, const QString &contents);
Internal::BreakHandler *breakHandler() const;
Internal::SnapshotHandler *snapshotHandler() const;
DebuggerEngine *currentEngine() const;
public slots:

View File

@@ -28,7 +28,6 @@
**************************************************************************/
#include "moduleshandler.h"
#include "debuggerengine.h"
#include <utils/qtcassert.h>
@@ -45,41 +44,8 @@
namespace Debugger {
namespace Internal {
class ModulesModel : public QAbstractItemModel
{ // Needs tr - context.
Q_OBJECT
public:
explicit ModulesModel(ModulesHandler *parent, DebuggerEngine *engine);
// QAbstractItemModel
int columnCount(const QModelIndex &parent) const
{ return parent.isValid() ? 0 : 5; }
int rowCount(const QModelIndex &parent) const
{ return parent.isValid() ? 0 : m_modules.size(); }
QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
QModelIndex index(int row, int column, const QModelIndex &) const
{ return createIndex(row, column); }
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
void clearModel();
void addModule(const Module &module);
void removeModule(const QString &moduleName);
void setModules(const Modules &modules);
void updateModule(const QString &moduleName, const Module &module);
const Modules &modules() const { return m_modules; }
private:
int indexOfModule(const QString &name) const;
DebuggerEngine *m_engine;
Modules m_modules;
};
ModulesModel::ModulesModel(ModulesHandler *parent, DebuggerEngine *engine)
: QAbstractItemModel(parent), m_engine(engine)
ModulesModel::ModulesModel(ModulesHandler *parent)
: QAbstractItemModel(parent)
{}
QVariant ModulesModel::headerData(int section,
@@ -101,12 +67,6 @@ QVariant ModulesModel::headerData(int section,
QVariant ModulesModel::data(const QModelIndex &index, int role) const
{
if (role == EngineCapabilitiesRole)
return m_engine->debuggerCapabilities();
if (role == EngineActionsEnabledRole)
return m_engine->debuggerActionsEnabled();
int row = index.row();
if (row < 0 || row >= m_modules.size())
return QVariant();
@@ -153,34 +113,6 @@ QVariant ModulesModel::data(const QModelIndex &index, int role) const
return QVariant();
}
bool ModulesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(index);
switch (role) {
case RequestReloadModulesRole:
m_engine->reloadModules();
return true;
case RequestExamineModulesRole:
m_engine->examineModules();
return true;
case RequestModuleSymbolsRole:
m_engine->loadSymbols(value.toString());
return true;
case RequestAllSymbolsRole:
m_engine->loadAllSymbols();
return true;
case RequestOpenFileRole:
m_engine->openFile(value.toString());
return true;
}
return false;
}
void ModulesModel::addModule(const Module &m)
{
beginInsertRows(QModelIndex(), m_modules.size(), m_modules.size());
@@ -234,9 +166,9 @@ void ModulesModel::updateModule(const QString &moduleName, const Module &module)
//
//////////////////////////////////////////////////////////////////
ModulesHandler::ModulesHandler(DebuggerEngine *engine)
ModulesHandler::ModulesHandler()
{
m_model = new ModulesModel(this, engine);
m_model = new ModulesModel(this);
m_proxyModel = new QSortFilterProxyModel(this);
m_proxyModel->setSourceModel(m_model);
}
@@ -279,4 +211,3 @@ Modules ModulesHandler::modules() const
} // namespace Internal
} // namespace Debugger
#include "moduleshandler.moc"

View File

@@ -32,20 +32,15 @@
#include <QtCore/QList>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QAbstractItemModel;
class QSortFilterProxyModel;
QT_END_NAMESPACE
#include <QtGui/QSortFilterProxyModel>
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class ModulesModel;
class ModulesHandler;
//////////////////////////////////////////////////////////////////
//
@@ -96,6 +91,45 @@ public:
typedef QList<Module> Modules;
//////////////////////////////////////////////////////////////////
//
// ModulesModel
//
//////////////////////////////////////////////////////////////////
class ModulesModel : public QAbstractItemModel
{
// Needs tr - context.
Q_OBJECT
public:
ModulesModel(ModulesHandler *parent);
// QAbstractItemModel
int columnCount(const QModelIndex &parent) const
{ return parent.isValid() ? 0 : 5; }
int rowCount(const QModelIndex &parent) const
{ return parent.isValid() ? 0 : m_modules.size(); }
QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
QModelIndex index(int row, int column, const QModelIndex &) const
{ return createIndex(row, column); }
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant data(const QModelIndex &index, int role) const;
void clearModel();
void addModule(const Module &module);
void removeModule(const QString &moduleName);
void setModules(const Modules &modules);
void updateModule(const QString &moduleName, const Module &module);
const Modules &modules() const { return m_modules; }
private:
int indexOfModule(const QString &name) const;
Modules m_modules;
};
//////////////////////////////////////////////////////////////////
//
// ModulesHandler
@@ -107,7 +141,7 @@ class ModulesHandler : public QObject
Q_OBJECT
public:
explicit ModulesHandler(DebuggerEngine *engine);
ModulesHandler();
QAbstractItemModel *model() const;

View File

@@ -29,8 +29,10 @@
#include "moduleswindow.h"
#include "debuggerconstants.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include "debuggerplugin.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
@@ -51,6 +53,11 @@
namespace Debugger {
namespace Internal {
static DebuggerEngine *currentEngine()
{
return DebuggerPlugin::instance()->currentEngine();
}
ModulesWindow::ModulesWindow(QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(false)
{
@@ -63,16 +70,14 @@ ModulesWindow::ModulesWindow(QWidget *parent)
setIconSize(QSize(10, 10));
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(moduleActivated(QModelIndex)));
SLOT(moduleActivated(QModelIndex)));
connect(act, SIGNAL(toggled(bool)),
this, SLOT(setAlternatingRowColorsHelper(bool)));
SLOT(setAlternatingRowColorsHelper(bool)));
}
void ModulesWindow::moduleActivated(const QModelIndex &index)
{
qDebug() << "ACTIVATED: " << index.row() << index.column()
<< index.data().toString();
setModelData(RequestOpenFileRole, index.data().toString());
currentEngine()->openFile(index.data().toString());
}
void ModulesWindow::resizeEvent(QResizeEvent *event)
@@ -100,10 +105,9 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
if (index.isValid())
name = index.data().toString();
const bool enabled =
model() && model()->data(index, EngineActionsEnabledRole).toBool();
const unsigned capabilities =
model()->data(index, EngineCapabilitiesRole).toInt();
DebuggerEngine *engine = currentEngine();
const bool enabled = engine->debuggerActionsEnabled();
const unsigned capabilities = engine->debuggerCapabilities();
QMenu menu;
@@ -168,7 +172,7 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act = menu.exec(ev->globalPos());
if (act == actUpdateModuleList) {
setModelData(RequestReloadModulesRole);
engine->reloadModules();
} else if (act == actAdjustColumnWidths) {
resizeColumnsToContents();
} else if (act == actAlwaysAdjustColumnWidth) {
@@ -176,15 +180,15 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
//} else if (act == actShowSourceFiles) {
// emit displaySourceRequested(name);
} else if (act == actLoadSymbolsForAllModules) {
setModelData(RequestAllSymbolsRole);
engine->loadAllSymbols();
} else if (act == actExamineAllModules) {
setModelData(RequestExamineModulesRole);
engine->examineModules();
} else if (act == actLoadSymbolsForModule) {
setModelData(RequestModuleSymbolsRole, name);
engine->loadSymbols(name);
} else if (act == actEditFile) {
setModelData(RequestOpenFileRole, name);
engine->openFile(name);
} else if (act == actShowSymbols) {
setModelData(RequestModuleSymbolsRole, name);
// FIXME setModelData(RequestModuleSymbolsRole, name);
}
}
@@ -215,12 +219,5 @@ void ModulesWindow::setModel(QAbstractItemModel *model)
setAlwaysResizeColumnsToContents(true);
}
void ModulesWindow::setModelData
(int role, const QVariant &value, const QModelIndex &index)
{
QTC_ASSERT(model(), return);
model()->setData(index, value, role);
}
} // namespace Internal
} // namespace Debugger

View File

@@ -52,8 +52,6 @@ private:
void resizeEvent(QResizeEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
void setModel(QAbstractItemModel *model);
void setModelData(int role, const QVariant &value = QVariant(),
const QModelIndex &index = QModelIndex());
bool m_alwaysResizeColumnsToContents;
};

View File

@@ -177,7 +177,8 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const
case Qt::ToolTipRole:
return QVariant();
case Qt::DecorationRole: // Return icon that indicates whether this is the active stack frame
case Qt::DecorationRole:
// Return icon that indicates whether this is the active stack frame.
if (index.column() == 0)
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
break;
@@ -208,38 +209,43 @@ Qt::ItemFlags SnapshotHandler::flags(const QModelIndex &index) const
return true ? QAbstractTableModel::flags(index) : Qt::ItemFlags(0);
}
bool SnapshotHandler::setData
(const QModelIndex &index, const QVariant &value, int role)
void SnapshotHandler::activateSnapshot(int index)
{
Q_UNUSED(value);
if (index.isValid() && role == RequestCreateSnapshotRole) {
DebuggerEngine *engine = engineAt(index.row());
QTC_ASSERT(engine, return false);
engine->createSnapshot();
return true;
}
if (index.isValid() && role == RequestActivateSnapshotRole) {
m_currentIndex = index.row();
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
DebuggerPlugin::displayDebugger(m_snapshots.at(m_currentIndex));
reset();
return true;
}
if (index.isValid() && role == RequestRemoveSnapshotRole) {
DebuggerEngine *engine = engineAt(index.row());
//qDebug() << "REMOVING " << engine;
QTC_ASSERT(engine, return false);
engine->quitDebugger();
return true;
}
return false;
m_currentIndex = index;
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
DebuggerPlugin::displayDebugger(m_snapshots.at(index));
reset();
}
void SnapshotHandler::createSnapshot(int index)
{
DebuggerEngine *engine = engineAt(index);
QTC_ASSERT(engine, return);
engine->createSnapshot();
}
void SnapshotHandler::removeSnapshot(int index)
{
DebuggerEngine *engine = engineAt(index);
//qDebug() << "REMOVING " << engine;
QTC_ASSERT(engine, return);
#if 0
// See http://sourceware.org/bugzilla/show_bug.cgi?id=11241.
setState(EngineSetupRequested);
postCommand("set stack-cache off");
#endif
QString fileName = engine->startParameters().coreFile;
//if (!fileName.isEmpty())
// QFile::remove(fileName);
m_snapshots.removeAt(index);
if (index == m_currentIndex)
m_currentIndex = -1;
else if (index < m_currentIndex)
--m_currentIndex;
engine->quitDebugger();
reset();
}
void SnapshotHandler::removeAll()
{
@@ -263,21 +269,6 @@ void SnapshotHandler::removeSnapshot(DebuggerRunControl *rc)
removeSnapshot(index);
}
void SnapshotHandler::removeSnapshot(int index)
{
const DebuggerEngine *engine = engineAt(index);
QTC_ASSERT(engine, return);
QString fileName = engine->startParameters().coreFile;
//if (!fileName.isEmpty())
// QFile::remove(fileName);
m_snapshots.removeAt(index);
if (index == m_currentIndex)
m_currentIndex = -1;
else if (index < m_currentIndex)
--m_currentIndex;
reset();
}
void SnapshotHandler::setCurrentIndex(int index)
{
m_currentIndex = index;

View File

@@ -63,20 +63,22 @@ public:
void removeSnapshot(DebuggerRunControl *rc);
void setCurrentIndex(int index);
int size() const { return m_snapshots.size(); }
DebuggerRunControl *at(int i) const;
QList<DebuggerRunControl*> runControls() const;
DebuggerRunControl *at(int index) const;
QList<DebuggerRunControl *> runControls() const;
void createSnapshot(int index);
void activateSnapshot(int index);
void removeSnapshot(int index);
private:
// QAbstractTableModel
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
Q_SLOT void resetModel() { reset(); }
DebuggerEngine *engineAt(int i) const;
void removeSnapshot(int index);
int m_currentIndex;
QList< QPointer<DebuggerRunControl> > m_snapshots;

View File

@@ -28,6 +28,7 @@
**************************************************************************/
#include "snapshotwindow.h"
#include "snapshothandler.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
@@ -60,9 +61,11 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
SnapshotWindow::SnapshotWindow(QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(false)
SnapshotWindow::SnapshotWindow(SnapshotHandler *handler)
: m_alwaysResizeColumnsToContents(false)
{
m_snapshotHandler = handler;
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setWindowTitle(tr("Snapshots"));
setAttribute(Qt::WA_MacShowFocusRect, false);
@@ -74,25 +77,14 @@ SnapshotWindow::SnapshotWindow(QWidget *parent)
header()->setDefaultAlignment(Qt::AlignLeft);
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(rowActivated(QModelIndex)));
SLOT(rowActivated(QModelIndex)));
connect(act, SIGNAL(toggled(bool)),
this, SLOT(setAlternatingRowColorsHelper(bool)));
}
SnapshotWindow::~SnapshotWindow()
{
SLOT(setAlternatingRowColorsHelper(bool)));
}
void SnapshotWindow::rowActivated(const QModelIndex &index)
{
model()->setData(index, index.row(), RequestActivateSnapshotRole);
}
void SnapshotWindow::removeSnapshots(const QModelIndexList &indexes)
{
QTC_ASSERT(!indexes.isEmpty(), return);
foreach (const QModelIndex &idx, indexes)
model()->setData(idx, QVariant(), RequestRemoveSnapshotRole);
{
m_snapshotHandler->activateSnapshot(index.row());
}
void SnapshotWindow::keyPressEvent(QKeyEvent *ev)
@@ -103,7 +95,8 @@ void SnapshotWindow::keyPressEvent(QKeyEvent *ev)
QModelIndexList si = sm->selectedIndexes();
if (si.isEmpty())
si.append(currentIndex().sibling(currentIndex().row(), 0));
removeSnapshots(normalizeIndexes(si));
foreach (const QModelIndex &idx, normalizeIndexes(si))
m_snapshotHandler->removeSnapshot(idx.row());
}
QTreeView::keyPressEvent(ev);
}
@@ -138,9 +131,9 @@ void SnapshotWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act = menu.exec(ev->globalPos());
if (act == actCreate)
model()->setData(idx, idx.row(), RequestCreateSnapshotRole);
m_snapshotHandler->createSnapshot(idx.row());
else if (act == actRemove)
model()->setData(idx, idx.row(), RequestRemoveSnapshotRole);
m_snapshotHandler->removeSnapshot(idx.row());
else if (act == actAdjust)
resizeColumnsToContents();
else if (act == actAlwaysAdjust)

View File

@@ -32,20 +32,17 @@
#include <QtGui/QTreeView>
QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class SnapshotHandler;
class SnapshotWindow : public QTreeView
{
Q_OBJECT
public:
SnapshotWindow(QWidget *parent = 0);
~SnapshotWindow();
explicit SnapshotWindow(SnapshotHandler *handler);
public slots:
void resizeColumnsToContents();
@@ -58,9 +55,9 @@ private slots:
private:
void keyPressEvent(QKeyEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
void removeSnapshots(const QModelIndexList &list);
bool m_alwaysResizeColumnsToContents;
SnapshotHandler *m_snapshotHandler;
};
} // namespace Internal

View File

@@ -29,9 +29,6 @@
#include "sourcefileshandler.h"
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
@@ -40,8 +37,7 @@
namespace Debugger {
namespace Internal {
SourceFilesHandler::SourceFilesHandler(DebuggerEngine *engine)
: m_engine(engine)
SourceFilesHandler::SourceFilesHandler()
{
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(this);
@@ -80,11 +76,6 @@ Qt::ItemFlags SourceFilesHandler::flags(const QModelIndex &index) const
QVariant SourceFilesHandler::data(const QModelIndex &index, int role) const
{
switch (role) {
case EngineActionsEnabledRole:
return m_engine->debuggerActionsEnabled();
}
int row = index.row();
if (row < 0 || row >= m_shortNames.size())
return QVariant();
@@ -107,22 +98,6 @@ QVariant SourceFilesHandler::data(const QModelIndex &index, int role) const
return QVariant();
}
bool SourceFilesHandler::setData
(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(index);
switch (role) {
case RequestReloadSourceFilesRole:
m_engine->reloadSourceFiles();
return true;
case RequestOpenFileRole:
m_engine->openFile(value.toString());
return true;
}
return false;
}
void SourceFilesHandler::setSourceFiles(const QMap<QString, QString> &sourceFiles)
{
m_shortNames.clear();

View File

@@ -34,8 +34,6 @@
#include <QtCore/QStringList>
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class SourceFilesHandler : public QAbstractItemModel
@@ -43,7 +41,7 @@ class SourceFilesHandler : public QAbstractItemModel
Q_OBJECT
public:
explicit SourceFilesHandler(DebuggerEngine *engine);
SourceFilesHandler();
int columnCount(const QModelIndex &parent) const
{ return parent.isValid() ? 0 : 2; }
@@ -54,7 +52,6 @@ public:
{ return createIndex(row, column); }
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
Qt::ItemFlags flags(const QModelIndex &index) const;
void clearModel();
@@ -66,7 +63,6 @@ public:
QAbstractItemModel *model() { return m_proxyModel; }
private:
DebuggerEngine *m_engine;
QStringList m_shortNames;
QStringList m_fullNames;
QAbstractItemModel *m_proxyModel;

View File

@@ -31,6 +31,8 @@
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include "debuggerplugin.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
@@ -42,6 +44,7 @@
#include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
//////////////////////////////////////////////////////////////////
//
// SourceFilesWindow
@@ -51,6 +54,11 @@
namespace Debugger {
namespace Internal {
static DebuggerEngine *currentEngine()
{
return DebuggerPlugin::instance()->currentEngine();
}
SourceFilesWindow::SourceFilesWindow(QWidget *parent)
: QTreeView(parent)
{
@@ -66,14 +74,14 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent)
//header()->setDefaultAlignment(Qt::AlignLeft);
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(sourceFileActivated(QModelIndex)));
SLOT(sourceFileActivated(QModelIndex)));
connect(act, SIGNAL(toggled(bool)),
this, SLOT(setAlternatingRowColorsHelper(bool)));
SLOT(setAlternatingRowColorsHelper(bool)));
}
void SourceFilesWindow::sourceFileActivated(const QModelIndex &index)
{
setModelData(RequestOpenFileRole, index.data());
currentEngine()->openFile(index.data().toString());
}
void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
@@ -81,7 +89,7 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
QModelIndex index = indexAt(ev->pos());
index = index.sibling(index.row(), 0);
QString name = index.data().toString();
bool engineActionsEnabled = index.data(EngineActionsEnabledRole).toBool();
bool engineActionsEnabled = currentEngine()->debuggerActionsEnabled();
QMenu menu;
QAction *act1 = new QAction(tr("Reload Data"), &menu);
@@ -105,9 +113,9 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act = menu.exec(ev->globalPos());
if (act == act1)
setModelData(RequestReloadSourceFilesRole);
currentEngine()->reloadSourceFiles();
else if (act == act2)
setModelData(RequestOpenFileRole, name);
currentEngine()->openFile(name);
}
void SourceFilesWindow::setModelData

View File

@@ -48,12 +48,10 @@ namespace Internal {
//
////////////////////////////////////////////////////////////////////////
StackHandler::StackHandler(DebuggerEngine *engine)
StackHandler::StackHandler()
: m_positionIcon(QIcon(QLatin1String(":/debugger/images/location_16.png"))),
m_emptyIcon(QIcon(QLatin1String(":/debugger/images/debugger_empty_14.png")))
{
m_engine = engine;
m_disassemblerViewAgent = new DisassemblerViewAgent(engine);
m_currentIndex = 0;
m_canExpand = false;
connect(theDebuggerAction(OperateByInstruction), SIGNAL(triggered()),
@@ -62,7 +60,6 @@ StackHandler::StackHandler(DebuggerEngine *engine)
StackHandler::~StackHandler()
{
delete m_disassemblerViewAgent;
}
int StackHandler::rowCount(const QModelIndex &parent) const
@@ -78,17 +75,6 @@ int StackHandler::columnCount(const QModelIndex &parent) const
QVariant StackHandler::data(const QModelIndex &index, int role) const
{
switch (role) {
case EngineStateRole:
return m_engine->state();
case EngineCapabilitiesRole:
return m_engine->debuggerCapabilities();
case EngineActionsEnabledRole:
return m_engine->debuggerActionsEnabled();
}
if (!index.isValid() || index.row() >= m_stackFrames.size() + m_canExpand)
return QVariant();
@@ -127,9 +113,6 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
}
if (role == StackFrameAddressRole)
return frame.address;
if (role == Qt::ToolTipRole)
return frame.toToolTip();
@@ -137,29 +120,6 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
}
bool StackHandler::setData(const QModelIndex &index, const QVariant &value, int role)
{
switch (role) {
case RequestReloadFullStackRole:
case RequestActivateFrameRole:
m_engine->handleCommand(role, value);
return true;
case RequestShowMemoryRole:
(void) new MemoryViewAgent(m_engine, value.toString());
return true;
case RequestShowDisassemblerRole: {
const StackFrame &frame = m_stackFrames.at(value.toInt());
m_disassemblerViewAgent->setFrame(frame);
return true;
}
default:
return QAbstractTableModel::setData(index, value, role);
}
}
QVariant StackHandler::headerData(int section, Qt::Orientation orient, int role) const
{
if (orient == Qt::Horizontal && role == Qt::DisplayRole) {
@@ -238,6 +198,5 @@ bool StackHandler::isDebuggingDebuggingHelpers() const
return false;
}
} // namespace Internal
} // namespace Debugger

View File

@@ -35,15 +35,11 @@
#include <QtCore/QAbstractItemModel>
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DisassemblerViewAgent;
////////////////////////////////////////////////////////////////////////
//
// StackModel
// StackCookie
//
////////////////////////////////////////////////////////////////////////
@@ -68,7 +64,7 @@ class StackHandler : public QAbstractTableModel
Q_OBJECT
public:
explicit StackHandler(DebuggerEngine *engine);
StackHandler();
~StackHandler();
void setFrames(const StackFrames &frames, bool canExpand = false);
@@ -76,6 +72,7 @@ public:
void setCurrentIndex(int index);
int currentIndex() const { return m_currentIndex; }
StackFrame currentFrame() const;
const StackFrame &frameAt(int index) const { return m_stackFrames.at(index); }
int stackSize() const { return m_stackFrames.size(); }
quint64 topAddress() const { return m_stackFrames.at(0).address; }
@@ -89,13 +86,10 @@ private:
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
Q_SLOT void resetModel() { reset(); }
DebuggerEngine *m_engine;
DisassemblerViewAgent *m_disassemblerViewAgent;
StackFrames m_stackFrames;
int m_currentIndex;
const QVariant m_positionIcon;

View File

@@ -28,10 +28,13 @@
**************************************************************************/
#include "stackwindow.h"
#include "stackframe.h"
#include "stackhandler.h"
#include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include "debuggerplugin.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
@@ -47,6 +50,11 @@
namespace Debugger {
namespace Internal {
static DebuggerEngine *currentEngine()
{
return DebuggerPlugin::instance()->currentEngine();
}
StackWindow::StackWindow(QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(false)
{
@@ -65,19 +73,15 @@ StackWindow::StackWindow(QWidget *parent)
header()->resizeSection(3, 60);
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(rowActivated(QModelIndex)));
SLOT(rowActivated(QModelIndex)));
connect(act, SIGNAL(toggled(bool)),
this, SLOT(setAlternatingRowColorsHelper(bool)));
SLOT(setAlternatingRowColorsHelper(bool)));
connect(theDebuggerAction(UseAddressInStackView), SIGNAL(toggled(bool)),
this, SLOT(showAddressColumn(bool)));
SLOT(showAddressColumn(bool)));
connect(theDebuggerAction(ExpandStack), SIGNAL(triggered()),
this, SLOT(reloadFullStack()));
SLOT(reloadFullStack()));
connect(theDebuggerAction(MaximalStackDepth), SIGNAL(triggered()),
this, SLOT(reloadFullStack()));
}
StackWindow::~StackWindow()
{
SLOT(reloadFullStack()));
}
void StackWindow::showAddressColumn(bool on)
@@ -87,14 +91,20 @@ void StackWindow::showAddressColumn(bool on)
void StackWindow::rowActivated(const QModelIndex &index)
{
setModelData(RequestActivateFrameRole, index.row());
currentEngine()->activateFrame(index.row());
}
void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
{
DebuggerEngine *engine = currentEngine();
StackHandler *handler = engine->stackHandler();
const QModelIndex index = indexAt(ev->pos());
const quint64 address = modelData(StackFrameAddressRole, index).toULongLong();
const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt();
const int row = index.row();
const unsigned engineCapabilities = engine->debuggerCapabilities();
StackFrame frame;
if (row < handler->stackSize())
frame = handler->frameAt(row);
const quint64 address = frame.address;
QMenu menu;
menu.addAction(theDebuggerAction(ExpandStack));
@@ -149,9 +159,11 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == actAlwaysAdjust)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == actShowMemory)
setModelData(RequestShowMemoryRole, address);
else if (act == actShowDisassembler)
setModelData(RequestShowDisassemblerRole, index.row());
(void) new MemoryViewAgent(currentEngine(), address);
else if (act == actShowDisassembler) {
DisassemblerViewAgent *agent = new DisassemblerViewAgent(engine);
agent->setFrame(frame);
}
}
void StackWindow::copyContentsToClipboard()
@@ -176,7 +188,7 @@ void StackWindow::copyContentsToClipboard()
void StackWindow::reloadFullStack()
{
setModelData(RequestReloadFullStackRole);
currentEngine()->reloadFullStack();
}
void StackWindow::resizeColumnsToContents()
@@ -194,19 +206,5 @@ void StackWindow::setAlwaysResizeColumnsToContents(bool on)
header()->setResizeMode(i, mode);
}
void StackWindow::setModelData
(int role, const QVariant &value, const QModelIndex &index)
{
QTC_ASSERT(model(), return);
model()->setData(index, value, role);
}
QVariant StackWindow::modelData(int role, const QModelIndex &index)
{
QTC_ASSERT(model(), return QVariant());
return model()->data(index, role);
}
} // namespace Internal
} // namespace Debugger

View File

@@ -41,7 +41,6 @@ class StackWindow : public QTreeView
public:
explicit StackWindow(QWidget *parent = 0);
~StackWindow();
public slots:
void resizeColumnsToContents();
@@ -57,10 +56,6 @@ private:
void contextMenuEvent(QContextMenuEvent *ev);
void copyContentsToClipboard();
void setModelData(int role, const QVariant &value = QVariant(),
const QModelIndex &index = QModelIndex());
QVariant modelData(int role, const QModelIndex &index = QModelIndex());
bool m_alwaysResizeColumnsToContents;
};

View File

@@ -30,7 +30,6 @@
#include "watchhandler.h"
#include "breakhandler.h"
#include "breakpoint.h"
#include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerengine.h"
@@ -822,44 +821,6 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
switch (role) {
case RequestShowInEditorRole: {
m_handler->showInEditor();
return true;
}
case RequestToggleWatchRole: {
BreakHandler *handler = engine()->breakHandler();
const quint64 address = value.toULongLong();
const int index = handler->findWatchPointIndexByAddress(address);
if (index == -1) {
BreakpointData *data = new BreakpointData;
data->type = Watchpoint;
data->address = address;
handler->appendBreakpoint(data);
} else {
handler->removeBreakpoint(index);
}
engine()->attemptBreakpointSynchronization();
return true;
}
case RequestShowMemoryRole: {
(void) new MemoryViewAgent(engine(), value.toULongLong());
return true;
}
case RequestClearCppCodeModelSnapshotRole: {
plugin()->clearCppCodeModelSnapshot();
return true;
}
case RequestWatchPointRole: {
engine()->watchPoint(value.toPoint());
return true;
}
}
WatchItem &data = *watchItem(index);
switch (role) {
@@ -899,14 +860,6 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro
engine()->updateWatchData(data);
break;
}
case RequestRemoveWatchExpressionRole:
m_handler->removeWatchExpression(value.toString());
break;
case RequestWatchExpressionRole:
m_handler->watchExpression(value.toString());
break;
}
emit dataChanged(index, index);
@@ -1734,12 +1687,12 @@ void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &for
m_reportedTypeFormats.insert(type, formats);
}
void WatchHandler::showInEditor()
QString WatchHandler::editorContents()
{
QString contents;
showInEditorHelper(&contents, m_locals->m_root, 0);
showInEditorHelper(&contents, m_watchers->m_root, 0);
plugin()->openTextEditor(tr("Locals & Watchers"), contents);
return contents;
}
void WatchHandler::showInEditorHelper(QString *contents, WatchItem *item, int depth)

View File

@@ -178,6 +178,7 @@ public:
QByteArray watcherName(const QByteArray &exp);
void synchronizeWatchers();
QString editorContents();
private:
friend class WatchModel;
@@ -189,7 +190,6 @@ private:
void setFormat(const QByteArray &type, int format);
void updateWatchersWindow();
void showInEditor();
void showInEditorHelper(QString *contents, WatchItem *item, int level);
bool m_inChange;

View File

@@ -29,20 +29,23 @@
#include "watchwindow.h"
#include "breakhandler.h"
#include "debuggeragents.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include "debuggerdialogs.h"
#include "watchhandler.h"
#include "debuggerengine.h"
#include "debuggerplugin.h"
#include "watchdelegatewidgets.h"
#include "watchhandler.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
#include <QtCore/QDebug>
#include <QtCore/QVariant>
#include <QtCore/QMetaProperty>
#include <QtCore/QMetaObject>
#include <QtCore/QMetaProperty>
#include <QtCore/QVariant>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QHeaderView>
@@ -50,8 +53,6 @@
#include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
using namespace Debugger;
using namespace Debugger::Internal;
/////////////////////////////////////////////////////////////////////
//
@@ -59,10 +60,25 @@ using namespace Debugger::Internal;
//
/////////////////////////////////////////////////////////////////////
namespace Debugger {
namespace Internal {
static DebuggerPlugin *plugin()
{
return DebuggerPlugin::instance();
}
static DebuggerEngine *currentEngine()
{
return DebuggerPlugin::instance()->currentEngine();
}
class WatchDelegate : public QItemDelegate
{
public:
explicit WatchDelegate(QObject *parent) : QItemDelegate(parent) {}
explicit WatchDelegate(WatchWindow *parent)
: QItemDelegate(parent), m_watchWindow(parent)
{}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
const QModelIndex &index) const
@@ -98,12 +114,12 @@ public:
}
const QMetaProperty userProperty = editor->metaObject()->userProperty();
QTC_ASSERT(userProperty.isValid(), return);
const QVariant value = editor->property(userProperty.name());
const QString value = editor->property(userProperty.name()).toString();
const QString exp = index.data(LocalsExpressionRole).toString();
if (exp != value.toString()) {
model->setData(index, exp, RequestRemoveWatchExpressionRole);
model->setData(index, value, RequestWatchExpressionRole);
}
if (exp == value)
return;
m_watchWindow->removeWatchExpression(exp);
m_watchWindow->watchExpression(value);
}
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
@@ -111,6 +127,9 @@ public:
{
editor->setGeometry(option.rect);
}
private:
WatchWindow *m_watchWindow;
};
/////////////////////////////////////////////////////////////////////
@@ -216,6 +235,9 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
void WatchWindow::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);
@@ -420,17 +442,17 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == actInsertNewWatchItem) {
watchExpression(QString());
} else if (act == actOpenMemoryEditAtVariableAddress) {
setModelData(RequestShowMemoryRole, address);
(void) new MemoryViewAgent(currentEngine(), address);
} else if (act == actOpenMemoryEditAtPointerValue) {
setModelData(RequestShowMemoryRole, pointerValue);
(void) new MemoryViewAgent(currentEngine(), pointerValue);
} else if (act == actOpenMemoryEditor) {
AddressDialog dialog;
if (dialog.exec() == QDialog::Accepted)
setModelData(RequestShowMemoryRole, dialog.address());
(void) new MemoryViewAgent(currentEngine(), dialog.address());
} else if (act == actSetWatchPointAtVariableAddress) {
setModelData(RequestToggleWatchRole, address);
setWatchpoint(address);
} else if (act == actSetWatchPointAtPointerValue) {
setModelData(RequestToggleWatchRole, pointerValue);
setWatchpoint(pointerValue);
} else if (act == actSelectWidgetToWatch) {
grabMouse(Qt::CrossCursor);
m_grabbing = true;
@@ -439,13 +461,14 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == actRemoveWatchExpression) {
removeWatchExpression(exp);
} else if (act == actClearCodeModelSnapshot) {
setModelData(RequestClearCppCodeModelSnapshotRole);
plugin()->clearCppCodeModelSnapshot();
} else if (act == clearTypeFormatAction) {
setModelData(LocalsTypeFormatRole, -1, mi1);
} else if (act == clearIndividualFormatAction) {
setModelData(LocalsIndividualFormatRole, -1, mi1);
} else if (act == actShowInEditor) {
setModelData(RequestShowInEditorRole);
QString contents = handler->editorContents();
plugin()->openTextEditor(tr("Locals & Watchers"), contents);
} else {
for (int i = 0; i != typeFormatActions.size(); ++i) {
if (act == typeFormatActions.at(i))
@@ -481,7 +504,7 @@ bool WatchWindow::event(QEvent *ev)
QMouseEvent *mev = static_cast<QMouseEvent *>(ev);
m_grabbing = false;
releaseMouse();
setModelData(RequestWatchPointRole, mapToGlobal(mev->pos()));
currentEngine()->watchPoint(mapToGlobal(mev->pos()));
}
return QTreeView::event(ev);
}
@@ -501,10 +524,8 @@ void WatchWindow::setModel(QAbstractItemModel *model)
if (m_type != LocalsType)
header()->hide();
connect(model, SIGNAL(layoutChanged()),
this, SLOT(resetHelper()));
connect(model, SIGNAL(enableUpdates(bool)),
this, SLOT(setUpdatesEnabled(bool)));
connect(model, SIGNAL(layoutChanged()), SLOT(resetHelper()));
connect(model, SIGNAL(enableUpdates(bool)), SLOT(setUpdatesEnabled(bool)));
}
void WatchWindow::setUpdatesEnabled(bool enable)
@@ -535,12 +556,12 @@ void WatchWindow::resetHelper(const QModelIndex &idx)
void WatchWindow::watchExpression(const QString &exp)
{
setModelData(RequestWatchExpressionRole, exp);
currentEngine()->watchHandler()->watchExpression(exp);
}
void WatchWindow::removeWatchExpression(const QString &exp)
{
setModelData(RequestRemoveWatchExpressionRole, exp);
currentEngine()->watchHandler()->removeWatchExpression(exp);
}
void WatchWindow::setModelData
@@ -556,3 +577,22 @@ QVariant WatchWindow::modelData(int role, const QModelIndex &index)
return model()->data(index, role);
}
void WatchWindow::setWatchpoint(quint64 address)
{
DebuggerEngine *engine = currentEngine();
BreakHandler *handler = engine->breakHandler();
const int index = handler->findWatchPointIndexByAddress(address);
if (index == -1) {
BreakpointData *data = new BreakpointData;
data->type = Watchpoint;
data->address = address;
handler->appendBreakpoint(data);
} else {
handler->removeBreakpoint(index);
}
engine->attemptBreakpointSynchronization();
}
} // namespace Internal
} // namespace Debugger

View File

@@ -56,6 +56,8 @@ public slots:
void setAlwaysResizeColumnsToContents(bool on = true);
void setModel(QAbstractItemModel *model);
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
void watchExpression(const QString &exp);
void removeWatchExpression(const QString &exp);
private:
Q_SLOT void resetHelper();
@@ -73,8 +75,7 @@ private:
void editItem(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx);
void watchExpression(const QString &exp);
void removeWatchExpression(const QString &exp);
void setWatchpoint(quint64 address);
void setModelData(int role, const QVariant &value = QVariant(),
const QModelIndex &index = QModelIndex());