summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2010-11-05 19:38:40 +0100
committerhjk <qtc-committer@nokia.com>2010-11-08 13:20:12 +0100
commitb373da1b12d477b5ac52c08e6463aefef24845f1 (patch)
tree469a36170adc9fe9b39262543cbb3863b5d87edf /src/plugins
parent1dacb9e55f80b50c1922df3c7d18620625ce492b (diff)
downloadqt-creator-b373da1b12d477b5ac52c08e6463aefef24845f1.tar.gz
debugger: more handler/window refactoring
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/debugger/debuggerconstants.h27
-rw-r--r--src/plugins/debugger/debuggerengine.cpp65
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp70
-rw-r--r--src/plugins/debugger/debuggerplugin.h2
-rw-r--r--src/plugins/debugger/moduleshandler.cpp77
-rw-r--r--src/plugins/debugger/moduleshandler.h52
-rw-r--r--src/plugins/debugger/moduleswindow.cpp43
-rw-r--r--src/plugins/debugger/moduleswindow.h2
-rw-r--r--src/plugins/debugger/snapshothandler.cpp71
-rw-r--r--src/plugins/debugger/snapshothandler.h10
-rw-r--r--src/plugins/debugger/snapshotwindow.cpp33
-rw-r--r--src/plugins/debugger/snapshotwindow.h11
-rw-r--r--src/plugins/debugger/sourcefileshandler.cpp27
-rw-r--r--src/plugins/debugger/sourcefileshandler.h6
-rw-r--r--src/plugins/debugger/sourcefileswindow.cpp20
-rw-r--r--src/plugins/debugger/stackhandler.cpp43
-rw-r--r--src/plugins/debugger/stackhandler.h12
-rw-r--r--src/plugins/debugger/stackwindow.cpp60
-rw-r--r--src/plugins/debugger/stackwindow.h5
-rw-r--r--src/plugins/debugger/watchhandler.cpp51
-rw-r--r--src/plugins/debugger/watchhandler.h2
-rw-r--r--src/plugins/debugger/watchwindow.cpp92
-rw-r--r--src/plugins/debugger/watchwindow.h5
23 files changed, 297 insertions, 489 deletions
diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h
index 38b14d1a6b..bfddd639bf 100644
--- a/src/plugins/debugger/debuggerconstants.h
+++ b/src/plugins/debugger/debuggerconstants.h
@@ -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
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index f9166bad7b..252b6edec0 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -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;
- }
}
}
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 2f9273ea2e..dffc00cd54 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -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;
diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h
index 245645abbd..75f49f62d8 100644
--- a/src/plugins/debugger/debuggerplugin.h
+++ b/src/plugins/debugger/debuggerplugin.h
@@ -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:
diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp
index 5069a2679a..acbeec7497 100644
--- a/src/plugins/debugger/moduleshandler.cpp
+++ b/src/plugins/debugger/moduleshandler.cpp
@@ -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"
diff --git a/src/plugins/debugger/moduleshandler.h b/src/plugins/debugger/moduleshandler.h
index 8749c8285e..8baa62f05a 100644
--- a/src/plugins/debugger/moduleshandler.h
+++ b/src/plugins/debugger/moduleshandler.h
@@ -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;
+
//////////////////////////////////////////////////////////////////
//
@@ -98,6 +93,45 @@ 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;
diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp
index e73f5d02cb..39334634e8 100644
--- a/src/plugins/debugger/moduleswindow.cpp
+++ b/src/plugins/debugger/moduleswindow.cpp
@@ -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
diff --git a/src/plugins/debugger/moduleswindow.h b/src/plugins/debugger/moduleswindow.h
index 5cce3eee13..49976ecc0e 100644
--- a/src/plugins/debugger/moduleswindow.h
+++ b/src/plugins/debugger/moduleswindow.h
@@ -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;
};
diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp
index e465713a02..a65c05b0dc 100644
--- a/src/plugins/debugger/snapshothandler.cpp
+++ b/src/plugins/debugger/snapshothandler.cpp
@@ -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;
diff --git a/src/plugins/debugger/snapshothandler.h b/src/plugins/debugger/snapshothandler.h
index 41f6d50bfb..56e421905d 100644
--- a/src/plugins/debugger/snapshothandler.h
+++ b/src/plugins/debugger/snapshothandler.h
@@ -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;
diff --git a/src/plugins/debugger/snapshotwindow.cpp b/src/plugins/debugger/snapshotwindow.cpp
index ef0ab00bc0..7fa7092117 100644
--- a/src/plugins/debugger/snapshotwindow.cpp
+++ b/src/plugins/debugger/snapshotwindow.cpp
@@ -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)
diff --git a/src/plugins/debugger/snapshotwindow.h b/src/plugins/debugger/snapshotwindow.h
index 9135c5bac5..42934e61ca 100644
--- a/src/plugins/debugger/snapshotwindow.h
+++ b/src/plugins/debugger/snapshotwindow.h
@@ -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
diff --git a/src/plugins/debugger/sourcefileshandler.cpp b/src/plugins/debugger/sourcefileshandler.cpp
index 670601f8d1..4b0ce011b9 100644
--- a/src/plugins/debugger/sourcefileshandler.cpp
+++ b/src/plugins/debugger/sourcefileshandler.cpp
@@ -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();
diff --git a/src/plugins/debugger/sourcefileshandler.h b/src/plugins/debugger/sourcefileshandler.h
index c3831dd57f..c6cc51f7d7 100644
--- a/src/plugins/debugger/sourcefileshandler.h
+++ b/src/plugins/debugger/sourcefileshandler.h
@@ -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;
diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp
index 9b10bc6890..b3f90d7d73 100644
--- a/src/plugins/debugger/sourcefileswindow.cpp
+++ b/src/plugins/debugger/sourcefileswindow.cpp
@@ -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
diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp
index 9d11caffbe..731523f333 100644
--- a/src/plugins/debugger/stackhandler.cpp
+++ b/src/plugins/debugger/stackhandler.cpp
@@ -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
diff --git a/src/plugins/debugger/stackhandler.h b/src/plugins/debugger/stackhandler.h
index b5dd8d95da..b23d0b07d0 100644
--- a/src/plugins/debugger/stackhandler.h
+++ b/src/plugins/debugger/stackhandler.h
@@ -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;
diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp
index b5870c2bfe..d7e61330b3 100644
--- a/src/plugins/debugger/stackwindow.cpp
+++ b/src/plugins/debugger/stackwindow.cpp
@@ -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
diff --git a/src/plugins/debugger/stackwindow.h b/src/plugins/debugger/stackwindow.h
index ad6ad41dc7..c19280215f 100644
--- a/src/plugins/debugger/stackwindow.h
+++ b/src/plugins/debugger/stackwindow.h
@@ -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;
};
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 7b4c86b699..38ca032426 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -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)
diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h
index b0c83f3ac6..f818f15bb3 100644
--- a/src/plugins/debugger/watchhandler.h
+++ b/src/plugins/debugger/watchhandler.h
@@ -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;
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index 95f91f4bcd..10e01f5d23 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -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
+
diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h
index 4470a6baa3..438b2e4f46 100644
--- a/src/plugins/debugger/watchwindow.h
+++ b/src/plugins/debugger/watchwindow.h
@@ -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());