diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index 533546fb5a71682bb1dac84c5019dddaaf69e4a2..841dec77ccd92a9c3e108f1c86e9fa1f333ea262 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -162,7 +162,12 @@ enum ModelRoles // Modules RequestReloadModulesRole, RequestModuleSymbolsRole, - RequestAllSymbolsRole + RequestAllSymbolsRole, + + // Snapshots + RequestMakeSnapshotRole, + RequestActivateSnapshotRole, + RequestRemoveSnapshotRole, }; } // namespace Debugger diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 1acffc10716bfef3634dda98b571e8212d12aefd..4188507f8dc96b80a3cf9f39a0b1355ebe2b04a3 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -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 diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 2e5157e0070f70579c027167d0bf61f693ff17b9..509b0d35cc692c443d7058a2e01acc1495c974c6 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -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; diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 58a583f2295a710b4639cd60143c829e73b48986..f98a11adfada2849fa038dfd4e01b24c237272a0 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -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(); } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 86374443af22dd32c7445c91cf98c27b764b7145..7bb1ed0582950114ccf8fe2c5c8fb05bc837e548 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -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"); diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index 6eee3850ad7a8dd779e54c1dc03009f617ddaf0e..13e321faa46144b405f70863c449796a76a31343 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -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(); diff --git a/src/plugins/debugger/snapshothandler.h b/src/plugins/debugger/snapshothandler.h index 35a42603ebae59d9d6c33aed1b7f478587207ea0..e73bb502f3b26ff7780e11396bfcf55599b39eb4 100644 --- a/src/plugins/debugger/snapshothandler.h +++ b/src/plugins/debugger/snapshothandler.h @@ -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; }; diff --git a/src/plugins/debugger/snapshotwindow.cpp b/src/plugins/debugger/snapshotwindow.cpp index 24d8a662555943b112d2b17183425b90324247f0..ef538d6067e5cce38652962ea0525d578c2435fd 100644 --- a/src/plugins/debugger/snapshotwindow.cpp +++ b/src/plugins/debugger/snapshotwindow.cpp @@ -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) diff --git a/src/plugins/debugger/snapshotwindow.h b/src/plugins/debugger/snapshotwindow.h index e737f6427c65c1fe4afb2a9089a7afb472df9321..b174add6901f59e999fd1a908180b38f2cc5536a 100644 --- a/src/plugins/debugger/snapshotwindow.h +++ b/src/plugins/debugger/snapshotwindow.h @@ -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; };