Commit 25c11c4c authored by hjk's avatar hjk

debugger: move SnapshotHandler from DebuggerManager to DebuggerRunControl

parent 7332f1e0
......@@ -162,7 +162,12 @@ enum ModelRoles
// Modules
RequestReloadModulesRole,
RequestModuleSymbolsRole,
RequestAllSymbolsRole
RequestAllSymbolsRole,
// Snapshots
RequestMakeSnapshotRole,
RequestActivateSnapshotRole,
RequestRemoveSnapshotRole,
};
} // namespace Debugger
......
......@@ -277,7 +277,6 @@ struct DebuggerManagerPrivate
// FIXME: Move to DebuggerRunControl
BreakHandler *m_breakHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler;
......@@ -301,7 +300,7 @@ struct DebuggerManagerPrivate
QWidget *m_watchersWindow;
QAbstractItemView *m_registerWindow;
QAbstractItemView *m_modulesWindow;
QWidget *m_snapshotWindow;
QAbstractItemView *m_snapshotWindow;
SourceFilesWindow *m_sourceFilesWindow;
QWidget *m_stackWindow;
QWidget *m_threadsWindow;
......@@ -354,7 +353,6 @@ DebuggerManager::~DebuggerManager()
doDelete(d->m_breakHandler);
doDelete(d->m_threadsHandler);
doDelete(d->m_snapshotHandler);
doDelete(d->m_stackHandler);
doDelete(d->m_watchHandler);
# undef doDelete
......@@ -384,7 +382,7 @@ void DebuggerManager::init()
d->m_registerWindow = new RegisterWindow(this);
d->m_registerWindow->setObjectName(QLatin1String("CppDebugRegisters"));
d->m_snapshotWindow = new SnapshotWindow(this);
d->m_snapshotWindow = new SnapshotWindow();
d->m_snapshotWindow->setObjectName(QLatin1String("CppDebugSnapshots"));
d->m_stackWindow = new StackWindow(this);
d->m_stackWindow->setObjectName(QLatin1String("CppDebugStack"));
......@@ -404,12 +402,6 @@ void DebuggerManager::init()
qobject_cast<DebuggerMainWindow*>(DebuggerUISwitcher::instance()->mainWindow());
QTC_ASSERT(d->m_mainWindow, return)
// Snapshots
d->m_snapshotHandler = new SnapshotHandler;
QAbstractItemView *snapshotView =
qobject_cast<QAbstractItemView *>(d->m_snapshotWindow);
snapshotView->setModel(d->m_snapshotHandler);
// Stack
d->m_stackHandler = new StackHandler;
StackWindow *stackView =
......@@ -698,14 +690,19 @@ void DebuggerManager::clearCppCodeModelSnapshot()
d->m_codeModelSnapshot = CPlusPlus::Snapshot();
}
QAbstractItemView *DebuggerManager::modulesWindow() const
{
return d->m_modulesWindow;
}
QAbstractItemView *DebuggerManager::registerWindow() const
{
return d->m_registerWindow;
}
QAbstractItemView *DebuggerManager::modulesWindow() const
QAbstractItemView *DebuggerManager::snapshotWindow() const
{
return d->m_modulesWindow;
return d->m_snapshotWindow;
}
SourceFilesWindow *DebuggerManager::sourceFileWindow() const
......@@ -844,24 +841,6 @@ void DebuggerManager::frameDown()
activateFrame(qMax(currentIndex - 1, 0));
}
void DebuggerManager::makeSnapshot()
{
QTC_ASSERT(d->m_engine, return);
d->m_engine->makeSnapshot();
}
void DebuggerManager::activateSnapshot(int index)
{
QTC_ASSERT(d->m_engine, return);
d->m_engine->activateSnapshot(index);
}
void DebuggerManager::removeSnapshot(int index)
{
QTC_ASSERT(d->m_engine, return);
d->m_snapshotHandler->removeSnapshot(index);
}
void DebuggerManager::attemptBreakpointSynchronization()
{
if (d->m_engine)
......@@ -1954,11 +1933,13 @@ WatchHandler *DebuggerManager::watchHandler() const
return d->m_watchHandler;
}
SnapshotHandler *DebuggerManager::snapshotHandler() const
void DebuggerManager::makeSnapshot()
{
return d->m_snapshotHandler;
QTC_ASSERT(d->m_engine, return);
d->m_engine->makeSnapshot();
}
//////////////////////////////////////////////////////////////////////
//
// Testing
......
......@@ -193,8 +193,6 @@ public slots:
void breakByFunctionMain();
void activateFrame(int index);
void selectThread(int index);
void activateSnapshot(int index);
void removeSnapshot(int index);
void executeStep();
void executeStepOut();
......@@ -202,7 +200,6 @@ public slots:
void executeContinue();
void executeReturn();
void detachDebugger();
void makeSnapshot();
void frameUp();
void frameDown();
......@@ -252,13 +249,15 @@ public slots: // FIXME
void operateByInstructionTriggered();
void startFailed();
// Called from global action.
void makeSnapshot();
friend class DebuggerRunControl;
public:
Internal::BreakHandler *breakHandler() const;
Internal::StackHandler *stackHandler() const;
Internal::ThreadsHandler *threadsHandler() const;
Internal::WatchHandler *watchHandler() const;
Internal::SnapshotHandler *snapshotHandler() const;
Internal::DebuggerOutputWindow *debuggerOutputWindow() const;
......@@ -266,6 +265,7 @@ private:
Internal::SourceFilesWindow *sourceFileWindow() const;
QAbstractItemView *modulesWindow() const;
QAbstractItemView *registerWindow() const;
QAbstractItemView *snapshotWindow() const;
QWidget *threadsWindow() const;
Internal::DebuggerManagerActions debuggerManagerActions() const;
......
......@@ -169,10 +169,10 @@ public:
ModulesHandler *m_modulesHandler;
RegisterHandler *m_registerHandler;
SnapshotHandler *m_snapshotHandler;
/*
// FIXME: Move from DebuggerManager
BreakHandler *m_breakHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler;
......@@ -190,6 +190,7 @@ DebuggerRunControl::Private::Private(DebuggerRunControl *parent,
m_running = false;
m_modulesHandler = new ModulesHandler(q);
m_registerHandler = new RegisterHandler();
m_snapshotHandler = new SnapshotHandler(q);
}
DebuggerRunControl::Private::~Private()
......@@ -197,6 +198,7 @@ DebuggerRunControl::Private::~Private()
#define doDelete(ptr) delete ptr; ptr = 0
doDelete(m_modulesHandler);
doDelete(m_registerHandler);
doDelete(m_snapshotHandler);
#undef doDelete
}
......@@ -357,7 +359,7 @@ WatchHandler *DebuggerRunControl::watchHandler() const
SnapshotHandler *DebuggerRunControl::snapshotHandler() const
{
return d->m_manager->snapshotHandler();
return d->m_snapshotHandler;
}
void DebuggerRunControl::cleanup()
......@@ -377,6 +379,7 @@ void DebuggerRunControl::startDebugger(IDebuggerEngine *engine)
d->m_engine->setRunControl(this);
d->m_manager->modulesWindow()->setModel(d->m_modulesHandler->model());
d->m_manager->registerWindow()->setModel(d->m_registerHandler->model());
d->m_manager->snapshotWindow()->setModel(d->m_snapshotHandler->model());
d->m_engine->startDebugger();
}
......
......@@ -3019,7 +3019,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response)
void GdbEngine::activateSnapshot(int index)
{
QTC_ASSERT(runControl(), return);
SnapshotData snapshot = m_manager->snapshotHandler()->setCurrentIndex(index);
SnapshotData snapshot = snapshotHandler()->setCurrentIndex(index);
DebuggerStartParameters &sp = const_cast<DebuggerStartParameters &>(runControl()->sp());
sp.startMode = AttachCore;
......@@ -3574,7 +3574,7 @@ WatchData GdbEngine::localVariable(const GdbMi &item,
}
}
if (!m_manager->watchHandler()->isExpandedIName(data.iname))
if (!watchHandler()->isExpandedIName(data.iname))
data.setChildrenUnneeded();
GdbMi t = item.findChild("numchild");
......
......@@ -30,6 +30,9 @@
#include "snapshothandler.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerrunner.h"
#include "idebuggerengine.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
......@@ -109,8 +112,9 @@ QDebug operator<<(QDebug d, const SnapshotData &f)
//
////////////////////////////////////////////////////////////////////////
SnapshotHandler::SnapshotHandler(QObject *parent)
SnapshotHandler::SnapshotHandler(DebuggerRunControl *runControl, QObject *parent)
: QAbstractTableModel(parent),
m_runControl(runControl),
m_positionIcon(QIcon(":/debugger/images/location_16.png")),
m_emptyIcon(QIcon(":/debugger/images/debugger_empty_14.png"))
{
......@@ -203,6 +207,24 @@ 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)
{
if (role == RequestMakeSnapshotRole) {
m_runControl->engine()->makeSnapshot();
return true;
}
if (role == RequestActivateSnapshotRole) {
m_runControl->engine()->activateSnapshot(value.toInt());
return true;
}
if (role == RequestRemoveSnapshotRole) {
removeSnapshot(value.toInt());
return true;
}
return QAbstractTableModel::setData(index, value, role);
}
void SnapshotHandler::removeAll()
{
m_snapshots.clear();
......
......@@ -36,6 +36,9 @@
#include <QtCore/QDateTime>
namespace Debugger {
class DebuggerRunControl;
namespace Internal {
////////////////////////////////////////////////////////////////////////
......@@ -67,11 +70,13 @@ public:
QString function() const; // Topmost entry.
private:
QString m_location; // Name of the core file.
QDateTime m_date; // Date of the snapshot
QList<StackFrame> m_frames; // Stack frames.
QString m_location; // Name of the core file.
QDateTime m_date; // Date of the snapshot
StackFrames m_frames; // Stack frames.
};
typedef QList<SnapshotData> Snapshots;
////////////////////////////////////////////////////////////////////////
//
......@@ -85,11 +90,11 @@ class SnapshotHandler : public QAbstractTableModel
Q_OBJECT
public:
SnapshotHandler(QObject *parent = 0);
SnapshotHandler(DebuggerRunControl *runControl, QObject *parent = 0);
~SnapshotHandler();
void setFrames(const QList<SnapshotData> &snapshots, bool canExpand = false);
QList<SnapshotData> snapshots() const;
void setFrames(const Snapshots &snapshots, bool canExpand = false);
Snapshots snapshots() const;
// Called from SnapshotHandler after a new snapshot has been added
void removeAll();
......@@ -104,12 +109,14 @@ 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 &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(); }
DebuggerRunControl *m_runControl;
int m_currentIndex;
QList<SnapshotData> m_snapshots;
Snapshots m_snapshots;
const QVariant m_positionIcon;
const QVariant m_emptyIcon;
};
......
......@@ -30,8 +30,7 @@
#include "snapshotwindow.h"
#include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggermanager.h"
#include "debuggerconstants.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
......@@ -39,14 +38,10 @@
#include <QtCore/QDebug>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <QtGui/QComboBox>
#include <QtGui/QHeaderView>
#include <QtGui/QKeyEvent>
#include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
#include <QtGui/QTreeView>
#include <QtGui/QVBoxLayout>
static QModelIndexList normalizeIndexes(const QModelIndexList &list)
{
......@@ -67,11 +62,9 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
SnapshotWindow::SnapshotWindow(DebuggerManager *manager, QWidget *parent)
: QTreeView(parent), m_manager(manager), m_alwaysResizeColumnsToContents(false)
SnapshotWindow::SnapshotWindow(QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(false)
{
m_disassemblerAgent = new DisassemblerViewAgent(manager);
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setWindowTitle(tr("Snapshots"));
setAttribute(Qt::WA_MacShowFocusRect, false);
......@@ -90,12 +83,11 @@ SnapshotWindow::SnapshotWindow(DebuggerManager *manager, QWidget *parent)
SnapshotWindow::~SnapshotWindow()
{
delete m_disassemblerAgent;
}
void SnapshotWindow::rowActivated(const QModelIndex &index)
{
m_manager->activateSnapshot(index.row());
model()->setData(index, index.row(), RequestActivateSnapshotRole);
}
void SnapshotWindow::removeSnapshots(const QModelIndexList &indexes)
......@@ -114,7 +106,7 @@ void SnapshotWindow::removeSnapshots(QList<int> list)
const int firstRow = list.front();
qSort(list.begin(), list.end());
for (int i = list.size(); --i >= 0; )
m_manager->removeSnapshot(list.at(i));
model()->setData(QModelIndex(), list.at(i), RequestRemoveSnapshotRole);
const int row = qMin(firstRow, model()->rowCount() - 1);
if (row >= 0)
......
......@@ -38,17 +38,14 @@ class QModelIndex;
QT_END_NAMESPACE
namespace Debugger {
class DebuggerManager;
namespace Internal {
class DisassemblerViewAgent;
class SnapshotWindow : public QTreeView
{
Q_OBJECT
public:
SnapshotWindow(DebuggerManager *manager, QWidget *parent = 0);
SnapshotWindow(QWidget *parent = 0);
~SnapshotWindow();
public slots:
......@@ -65,8 +62,6 @@ private:
void removeSnapshots(const QModelIndexList &list);
void removeSnapshots(QList<int> rows);
DebuggerManager *m_manager;
DisassemblerViewAgent *m_disassemblerAgent;
bool m_alwaysResizeColumnsToContents;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment