debugger: move SnapshotHandler from DebuggerManager to DebuggerRunControl

This commit is contained in:
hjk
2010-06-15 12:15:25 +02:00
parent 7332f1e016
commit 25c11c4ce0
9 changed files with 74 additions and 69 deletions

View File

@@ -162,7 +162,12 @@ enum ModelRoles
// Modules // Modules
RequestReloadModulesRole, RequestReloadModulesRole,
RequestModuleSymbolsRole, RequestModuleSymbolsRole,
RequestAllSymbolsRole RequestAllSymbolsRole,
// Snapshots
RequestMakeSnapshotRole,
RequestActivateSnapshotRole,
RequestRemoveSnapshotRole,
}; };
} // namespace Debugger } // namespace Debugger

View File

@@ -277,7 +277,6 @@ struct DebuggerManagerPrivate
// FIXME: Move to DebuggerRunControl // FIXME: Move to DebuggerRunControl
BreakHandler *m_breakHandler; BreakHandler *m_breakHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler; StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler; ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler; WatchHandler *m_watchHandler;
@@ -301,7 +300,7 @@ struct DebuggerManagerPrivate
QWidget *m_watchersWindow; QWidget *m_watchersWindow;
QAbstractItemView *m_registerWindow; QAbstractItemView *m_registerWindow;
QAbstractItemView *m_modulesWindow; QAbstractItemView *m_modulesWindow;
QWidget *m_snapshotWindow; QAbstractItemView *m_snapshotWindow;
SourceFilesWindow *m_sourceFilesWindow; SourceFilesWindow *m_sourceFilesWindow;
QWidget *m_stackWindow; QWidget *m_stackWindow;
QWidget *m_threadsWindow; QWidget *m_threadsWindow;
@@ -354,7 +353,6 @@ DebuggerManager::~DebuggerManager()
doDelete(d->m_breakHandler); doDelete(d->m_breakHandler);
doDelete(d->m_threadsHandler); doDelete(d->m_threadsHandler);
doDelete(d->m_snapshotHandler);
doDelete(d->m_stackHandler); doDelete(d->m_stackHandler);
doDelete(d->m_watchHandler); doDelete(d->m_watchHandler);
# undef doDelete # undef doDelete
@@ -384,7 +382,7 @@ void DebuggerManager::init()
d->m_registerWindow = new RegisterWindow(this); d->m_registerWindow = new RegisterWindow(this);
d->m_registerWindow->setObjectName(QLatin1String("CppDebugRegisters")); 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_snapshotWindow->setObjectName(QLatin1String("CppDebugSnapshots"));
d->m_stackWindow = new StackWindow(this); d->m_stackWindow = new StackWindow(this);
d->m_stackWindow->setObjectName(QLatin1String("CppDebugStack")); d->m_stackWindow->setObjectName(QLatin1String("CppDebugStack"));
@@ -404,12 +402,6 @@ void DebuggerManager::init()
qobject_cast<DebuggerMainWindow*>(DebuggerUISwitcher::instance()->mainWindow()); qobject_cast<DebuggerMainWindow*>(DebuggerUISwitcher::instance()->mainWindow());
QTC_ASSERT(d->m_mainWindow, return) 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 // Stack
d->m_stackHandler = new StackHandler; d->m_stackHandler = new StackHandler;
StackWindow *stackView = StackWindow *stackView =
@@ -698,14 +690,19 @@ void DebuggerManager::clearCppCodeModelSnapshot()
d->m_codeModelSnapshot = CPlusPlus::Snapshot(); d->m_codeModelSnapshot = CPlusPlus::Snapshot();
} }
QAbstractItemView *DebuggerManager::modulesWindow() const
{
return d->m_modulesWindow;
}
QAbstractItemView *DebuggerManager::registerWindow() const QAbstractItemView *DebuggerManager::registerWindow() const
{ {
return d->m_registerWindow; return d->m_registerWindow;
} }
QAbstractItemView *DebuggerManager::modulesWindow() const QAbstractItemView *DebuggerManager::snapshotWindow() const
{ {
return d->m_modulesWindow; return d->m_snapshotWindow;
} }
SourceFilesWindow *DebuggerManager::sourceFileWindow() const SourceFilesWindow *DebuggerManager::sourceFileWindow() const
@@ -844,24 +841,6 @@ void DebuggerManager::frameDown()
activateFrame(qMax(currentIndex - 1, 0)); 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() void DebuggerManager::attemptBreakpointSynchronization()
{ {
if (d->m_engine) if (d->m_engine)
@@ -1954,11 +1933,13 @@ WatchHandler *DebuggerManager::watchHandler() const
return d->m_watchHandler; 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 // Testing

View File

@@ -193,8 +193,6 @@ public slots:
void breakByFunctionMain(); void breakByFunctionMain();
void activateFrame(int index); void activateFrame(int index);
void selectThread(int index); void selectThread(int index);
void activateSnapshot(int index);
void removeSnapshot(int index);
void executeStep(); void executeStep();
void executeStepOut(); void executeStepOut();
@@ -202,7 +200,6 @@ public slots:
void executeContinue(); void executeContinue();
void executeReturn(); void executeReturn();
void detachDebugger(); void detachDebugger();
void makeSnapshot();
void frameUp(); void frameUp();
void frameDown(); void frameDown();
@@ -252,13 +249,15 @@ public slots: // FIXME
void operateByInstructionTriggered(); void operateByInstructionTriggered();
void startFailed(); void startFailed();
// Called from global action.
void makeSnapshot();
friend class DebuggerRunControl; friend class DebuggerRunControl;
public: public:
Internal::BreakHandler *breakHandler() const; Internal::BreakHandler *breakHandler() const;
Internal::StackHandler *stackHandler() const; Internal::StackHandler *stackHandler() const;
Internal::ThreadsHandler *threadsHandler() const; Internal::ThreadsHandler *threadsHandler() const;
Internal::WatchHandler *watchHandler() const; Internal::WatchHandler *watchHandler() const;
Internal::SnapshotHandler *snapshotHandler() const;
Internal::DebuggerOutputWindow *debuggerOutputWindow() const; Internal::DebuggerOutputWindow *debuggerOutputWindow() const;
@@ -266,6 +265,7 @@ private:
Internal::SourceFilesWindow *sourceFileWindow() const; Internal::SourceFilesWindow *sourceFileWindow() const;
QAbstractItemView *modulesWindow() const; QAbstractItemView *modulesWindow() const;
QAbstractItemView *registerWindow() const; QAbstractItemView *registerWindow() const;
QAbstractItemView *snapshotWindow() const;
QWidget *threadsWindow() const; QWidget *threadsWindow() const;
Internal::DebuggerManagerActions debuggerManagerActions() const; Internal::DebuggerManagerActions debuggerManagerActions() const;

View File

@@ -169,10 +169,10 @@ public:
ModulesHandler *m_modulesHandler; ModulesHandler *m_modulesHandler;
RegisterHandler *m_registerHandler; RegisterHandler *m_registerHandler;
SnapshotHandler *m_snapshotHandler;
/* /*
// FIXME: Move from DebuggerManager // FIXME: Move from DebuggerManager
BreakHandler *m_breakHandler; BreakHandler *m_breakHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler; StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler; ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler; WatchHandler *m_watchHandler;
@@ -190,6 +190,7 @@ DebuggerRunControl::Private::Private(DebuggerRunControl *parent,
m_running = false; m_running = false;
m_modulesHandler = new ModulesHandler(q); m_modulesHandler = new ModulesHandler(q);
m_registerHandler = new RegisterHandler(); m_registerHandler = new RegisterHandler();
m_snapshotHandler = new SnapshotHandler(q);
} }
DebuggerRunControl::Private::~Private() DebuggerRunControl::Private::~Private()
@@ -197,6 +198,7 @@ DebuggerRunControl::Private::~Private()
#define doDelete(ptr) delete ptr; ptr = 0 #define doDelete(ptr) delete ptr; ptr = 0
doDelete(m_modulesHandler); doDelete(m_modulesHandler);
doDelete(m_registerHandler); doDelete(m_registerHandler);
doDelete(m_snapshotHandler);
#undef doDelete #undef doDelete
} }
@@ -357,7 +359,7 @@ WatchHandler *DebuggerRunControl::watchHandler() const
SnapshotHandler *DebuggerRunControl::snapshotHandler() const SnapshotHandler *DebuggerRunControl::snapshotHandler() const
{ {
return d->m_manager->snapshotHandler(); return d->m_snapshotHandler;
} }
void DebuggerRunControl::cleanup() void DebuggerRunControl::cleanup()
@@ -377,6 +379,7 @@ void DebuggerRunControl::startDebugger(IDebuggerEngine *engine)
d->m_engine->setRunControl(this); d->m_engine->setRunControl(this);
d->m_manager->modulesWindow()->setModel(d->m_modulesHandler->model()); d->m_manager->modulesWindow()->setModel(d->m_modulesHandler->model());
d->m_manager->registerWindow()->setModel(d->m_registerHandler->model()); d->m_manager->registerWindow()->setModel(d->m_registerHandler->model());
d->m_manager->snapshotWindow()->setModel(d->m_snapshotHandler->model());
d->m_engine->startDebugger(); d->m_engine->startDebugger();
} }

View File

@@ -3019,7 +3019,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response)
void GdbEngine::activateSnapshot(int index) void GdbEngine::activateSnapshot(int index)
{ {
QTC_ASSERT(runControl(), return); QTC_ASSERT(runControl(), return);
SnapshotData snapshot = m_manager->snapshotHandler()->setCurrentIndex(index); SnapshotData snapshot = snapshotHandler()->setCurrentIndex(index);
DebuggerStartParameters &sp = const_cast<DebuggerStartParameters &>(runControl()->sp()); DebuggerStartParameters &sp = const_cast<DebuggerStartParameters &>(runControl()->sp());
sp.startMode = AttachCore; 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(); data.setChildrenUnneeded();
GdbMi t = item.findChild("numchild"); GdbMi t = item.findChild("numchild");

View File

@@ -30,6 +30,9 @@
#include "snapshothandler.h" #include "snapshothandler.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerrunner.h"
#include "idebuggerengine.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/savedaction.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), : QAbstractTableModel(parent),
m_runControl(runControl),
m_positionIcon(QIcon(":/debugger/images/location_16.png")), m_positionIcon(QIcon(":/debugger/images/location_16.png")),
m_emptyIcon(QIcon(":/debugger/images/debugger_empty_14.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); 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() void SnapshotHandler::removeAll()
{ {
m_snapshots.clear(); m_snapshots.clear();

View File

@@ -36,6 +36,9 @@
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
namespace Debugger { namespace Debugger {
class DebuggerRunControl;
namespace Internal { namespace Internal {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -67,11 +70,13 @@ public:
QString function() const; // Topmost entry. QString function() const; // Topmost entry.
private: private:
QString m_location; // Name of the core file. QString m_location; // Name of the core file.
QDateTime m_date; // Date of the snapshot QDateTime m_date; // Date of the snapshot
QList<StackFrame> m_frames; // Stack frames. StackFrames m_frames; // Stack frames.
}; };
typedef QList<SnapshotData> Snapshots;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
@@ -85,11 +90,11 @@ class SnapshotHandler : public QAbstractTableModel
Q_OBJECT Q_OBJECT
public: public:
SnapshotHandler(QObject *parent = 0); SnapshotHandler(DebuggerRunControl *runControl, QObject *parent = 0);
~SnapshotHandler(); ~SnapshotHandler();
void setFrames(const QList<SnapshotData> &snapshots, bool canExpand = false); void setFrames(const Snapshots &snapshots, bool canExpand = false);
QList<SnapshotData> snapshots() const; Snapshots snapshots() const;
// Called from SnapshotHandler after a new snapshot has been added // Called from SnapshotHandler after a new snapshot has been added
void removeAll(); void removeAll();
@@ -104,12 +109,14 @@ private:
int rowCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) 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; QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
Q_SLOT void resetModel() { reset(); } Q_SLOT void resetModel() { reset(); }
DebuggerRunControl *m_runControl;
int m_currentIndex; int m_currentIndex;
QList<SnapshotData> m_snapshots; Snapshots m_snapshots;
const QVariant m_positionIcon; const QVariant m_positionIcon;
const QVariant m_emptyIcon; const QVariant m_emptyIcon;
}; };

View File

@@ -30,8 +30,7 @@
#include "snapshotwindow.h" #include "snapshotwindow.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h" #include "debuggerconstants.h"
#include "debuggermanager.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/savedaction.h> #include <utils/savedaction.h>
@@ -39,14 +38,10 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <QtGui/QComboBox>
#include <QtGui/QHeaderView> #include <QtGui/QHeaderView>
#include <QtGui/QKeyEvent>
#include <QtGui/QMenu> #include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QVBoxLayout>
static QModelIndexList normalizeIndexes(const QModelIndexList &list) static QModelIndexList normalizeIndexes(const QModelIndexList &list)
{ {
@@ -67,11 +62,9 @@ namespace Internal {
// //
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
SnapshotWindow::SnapshotWindow(DebuggerManager *manager, QWidget *parent) SnapshotWindow::SnapshotWindow(QWidget *parent)
: QTreeView(parent), m_manager(manager), m_alwaysResizeColumnsToContents(false) : QTreeView(parent), m_alwaysResizeColumnsToContents(false)
{ {
m_disassemblerAgent = new DisassemblerViewAgent(manager);
QAction *act = theDebuggerAction(UseAlternatingRowColors); QAction *act = theDebuggerAction(UseAlternatingRowColors);
setWindowTitle(tr("Snapshots")); setWindowTitle(tr("Snapshots"));
setAttribute(Qt::WA_MacShowFocusRect, false); setAttribute(Qt::WA_MacShowFocusRect, false);
@@ -90,12 +83,11 @@ SnapshotWindow::SnapshotWindow(DebuggerManager *manager, QWidget *parent)
SnapshotWindow::~SnapshotWindow() SnapshotWindow::~SnapshotWindow()
{ {
delete m_disassemblerAgent;
} }
void SnapshotWindow::rowActivated(const QModelIndex &index) void SnapshotWindow::rowActivated(const QModelIndex &index)
{ {
m_manager->activateSnapshot(index.row()); model()->setData(index, index.row(), RequestActivateSnapshotRole);
} }
void SnapshotWindow::removeSnapshots(const QModelIndexList &indexes) void SnapshotWindow::removeSnapshots(const QModelIndexList &indexes)
@@ -114,7 +106,7 @@ void SnapshotWindow::removeSnapshots(QList<int> list)
const int firstRow = list.front(); const int firstRow = list.front();
qSort(list.begin(), list.end()); qSort(list.begin(), list.end());
for (int i = list.size(); --i >= 0; ) 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); const int row = qMin(firstRow, model()->rowCount() - 1);
if (row >= 0) if (row >= 0)

View File

@@ -38,17 +38,14 @@ class QModelIndex;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Debugger { namespace Debugger {
class DebuggerManager;
namespace Internal { namespace Internal {
class DisassemblerViewAgent;
class SnapshotWindow : public QTreeView class SnapshotWindow : public QTreeView
{ {
Q_OBJECT Q_OBJECT
public: public:
SnapshotWindow(DebuggerManager *manager, QWidget *parent = 0); SnapshotWindow(QWidget *parent = 0);
~SnapshotWindow(); ~SnapshotWindow();
public slots: public slots:
@@ -65,8 +62,6 @@ private:
void removeSnapshots(const QModelIndexList &list); void removeSnapshots(const QModelIndexList &list);
void removeSnapshots(QList<int> rows); void removeSnapshots(QList<int> rows);
DebuggerManager *m_manager;
DisassemblerViewAgent *m_disassemblerAgent;
bool m_alwaysResizeColumnsToContents; bool m_alwaysResizeColumnsToContents;
}; };