From 91ba3949d55a3ad46c673f7de6a39e960a7ed905 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 4 Nov 2010 18:11:09 +0100 Subject: [PATCH] debugger: remove sessionengine --- src/plugins/debugger/debugger.pro | 2 - src/plugins/debugger/debuggerengine.cpp | 31 +------ src/plugins/debugger/debuggerengine.h | 1 - src/plugins/debugger/debuggerplugin.cpp | 104 +++++++++++++---------- src/plugins/debugger/debuggerplugin.h | 5 -- src/plugins/debugger/sessionengine.cpp | 77 ----------------- src/plugins/debugger/sessionengine.h | 66 -------------- src/plugins/debugger/snapshothandler.cpp | 1 - src/plugins/debugger/watchhandler.cpp | 13 +-- src/plugins/debugger/watchhandler.h | 21 ++--- 10 files changed, 78 insertions(+), 243 deletions(-) delete mode 100644 src/plugins/debugger/sessionengine.cpp delete mode 100644 src/plugins/debugger/sessionengine.h diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 39b78dd2a15..5a4cc3a4497 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -41,7 +41,6 @@ HEADERS += breakhandler.h \ procinterrupt.h \ registerhandler.h \ registerwindow.h \ - sessionengine.h \ snapshothandler.h \ snapshotwindow.h \ sourcefileshandler.h \ @@ -79,7 +78,6 @@ SOURCES += breakhandler.cpp \ procinterrupt.cpp \ registerhandler.cpp \ registerwindow.cpp \ - sessionengine.cpp \ snapshothandler.cpp \ snapshotwindow.cpp \ sourcefileshandler.cpp \ diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index c2bb02489c0..884c1a897eb 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -614,17 +614,6 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value) executeDebuggerCommand(value.toString()); break; -/* - case RequestToggleBreakpointRole: { - QList<QVariant> list = value.toList(); - QTC_ASSERT(list.size() == 2, break); - const QString fileName = list.at(0).toString(); - const int lineNumber = list.at(1).toInt(); - breakHandler()->toggleBreakpoint(fileName, lineNumber); - break; - } -*/ - case RequestToolTipByExpressionRole: { QList<QVariant> list = value.toList(); QTC_ASSERT(list.size() == 3, break); @@ -817,7 +806,7 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) { - if (!isSessionEngine() && !isSlaveEngine()) { + if (!isSlaveEngine()) { d->m_progress.setProgressRange(0, 1000); Core::FutureProgress *fp = Core::ICore::instance()->progressManager() ->addTask(d->m_progress.future(), @@ -828,12 +817,6 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) QTC_ASSERT(runControl, notifyEngineSetupFailed(); return); QTC_ASSERT(!d->m_runControl, notifyEngineSetupFailed(); return); - DebuggerEngine *sessionTemplate = plugin()->sessionTemplate(); - QTC_ASSERT(sessionTemplate, notifyEngineSetupFailed(); return); - QTC_ASSERT(sessionTemplate != this, notifyEngineSetupFailed(); return); - - watchHandler()->initializeFromTemplate(sessionTemplate->watchHandler()); - d->m_runControl = runControl; d->m_inferiorPid = d->m_startParameters.attachPID > 0 @@ -1028,11 +1011,6 @@ void DebuggerEngine::handleFinished() threadsHandler()->removeAll(); watchHandler()->cleanup(); - DebuggerEngine *sessionTemplate = plugin()->sessionTemplate(); - QTC_ASSERT(sessionTemplate != this, /**/); - breakHandler()->storeToTemplate(sessionTemplate->breakHandler()); - watchHandler()->storeToTemplate(sessionTemplate->watchHandler()); - d->m_progress.setProgressValue(1000); d->m_progress.reportFinished(); } @@ -1593,7 +1571,7 @@ bool DebuggerEngine::isReverseDebugging() const bool DebuggerEngine::isActive() const { - return d->m_isActive && !isSessionEngine(); + return d->m_isActive; } void DebuggerEngine::setActive(bool on) @@ -1653,11 +1631,6 @@ void DebuggerEngine::updateWatchData(const Internal::WatchData &, const Internal { } -bool DebuggerEngine::isSessionEngine() const -{ - return false; -} - void DebuggerEngine::watchPoint(const QPoint &) { } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 3f24410c06f..7364abe1b18 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -154,7 +154,6 @@ public: virtual void updateWatchData(const Internal::WatchData &data, const Internal::WatchUpdateFlags & flags = Internal::WatchUpdateFlags()); void startDebugger(DebuggerRunControl *runControl); - virtual bool isSessionEngine() const; virtual void watchPoint(const QPoint &); virtual void fetchMemory(Internal::MemoryViewAgent *, QObject *, diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 1f4c9669694..a2057662406 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -51,9 +51,9 @@ #include "stackwindow.h" #include "sourcefileswindow.h" #include "threadswindow.h" +#include "watchhandler.h" #include "watchwindow.h" -#include "sessionengine.h" #include "snapshothandler.h" #include "threadshandler.h" @@ -853,7 +853,7 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage); void notifyCurrentEngine(int role, const QVariant &value = QVariant()); void connectEngine(DebuggerEngine *engine, bool notify = true); - void disconnectEngine() { connectEngine(m_sessionEngine); } + void disconnectEngine() { connectEngine(0); } public slots: void updateWatchersHeader(int section, int, int newSize) @@ -876,6 +876,16 @@ public slots: } } + void synchronizeWatchers() + { + for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) { + if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) { + DebuggerEngine *engine = runControl->engine(); + engine->watchHandler()->synchronizeWatchers(); + } + } + } + void onAction(); void setSimpleDockWidgetArrangement(Debugger::DebuggerLanguages activeLanguages); @@ -1008,8 +1018,6 @@ public: LogWindow *m_logWindow; ScriptConsole *m_scriptConsoleWindow; - SessionEngine *m_sessionEngine; - bool m_busy; QTimer m_statusTimer; QString m_lastPermanentStatusMessage; @@ -1019,13 +1027,14 @@ public: SnapshotHandler *m_snapshotHandler; bool m_shuttingDown; + DebuggerEngine *m_currentEngine; }; -DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) : - m_shuttingDown(false) +DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) { m_plugin = plugin; + m_shuttingDown = false; m_statusLabel = 0; m_threadBox = 0; @@ -1054,7 +1063,6 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) : m_logWindow = 0; m_scriptConsoleWindow = 0; - m_sessionEngine = 0; m_debugMode = 0; m_continuableContext = Core::Context(0); @@ -1067,6 +1075,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) : m_uiSwitcher = 0; m_state = DebuggerNotReady; m_snapshotHandler = 0; + m_currentEngine = 0; } bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *errorMessage) @@ -1113,6 +1122,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er SLOT(synchronizeBreakpoints())); m_breakWindow = new BreakWindow; m_breakWindow->setObjectName(QLatin1String("CppDebugBreakpoints")); + m_breakWindow->setModel(m_breakHandler->model()); + //m_consoleWindow = new ConsoleWindow; //m_consoleWindow->setObjectName(QLatin1String("CppDebugConsole")); m_modulesWindow = new ModulesWindow; @@ -1143,9 +1154,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er connect(m_scriptConsoleWindow, SIGNAL(expressionEntered(QString)), SLOT(scriptExpressionEntered(QString))); - // Session related data - m_sessionEngine = new SessionEngine; - // Snapshot m_snapshotHandler = new SnapshotHandler; m_snapshotWindow->setModel(m_snapshotHandler->model()); @@ -1652,7 +1660,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er SLOT(languagesChanged(Debugger::DebuggerLanguages))); setInitialState(); - connectEngine(m_sessionEngine, false); + connectEngine(0, false); connect(sessionManager(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), @@ -1758,8 +1766,9 @@ void DebuggerPluginPrivate::startExternalApplication() void DebuggerPluginPrivate::notifyCurrentEngine(int role, const QVariant &value) { - QTC_ASSERT(m_commandWindow && m_commandWindow->model(), return); - m_commandWindow->model()->setData(QModelIndex(), value, role); + QTC_ASSERT(m_commandWindow, return); + if (m_commandWindow->model()) + m_commandWindow->model()->setData(QModelIndex(), value, role); } void DebuggerPluginPrivate::attachExternalApplication() @@ -2052,32 +2061,38 @@ void DebuggerPluginPrivate::startDebugger(RunControl *rc) void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine, bool notify) { - const QAbstractItemModel *oldCommandModel = m_commandWindow->model(); - if (oldCommandModel == engine->commandModel()) { - // qDebug("RECONNECTING ENGINE %s", qPrintable(engine->objectName())); + if (m_currentEngine == engine) return; - } - - if (notify) - notifyCurrentEngine(RequestActivationRole, false); - // qDebug("CONNECTING ENGINE %s (OLD ENGINE: %s)", qPrintable(engine->objectName()), - // (oldCommandModel ? qPrintable(oldCommandModel->objectName()) : "")); - - m_breakWindow->setModel(m_breakHandler->model()); - m_commandWindow->setModel(engine->commandModel()); - m_localsWindow->setModel(engine->localsModel()); - m_modulesWindow->setModel(engine->modulesModel()); - m_registerWindow->setModel(engine->registerModel()); - m_returnWindow->setModel(engine->returnModel()); - m_sourceFilesWindow->setModel(engine->sourceFilesModel()); - m_stackWindow->setModel(engine->stackModel()); - m_threadsWindow->setModel(engine->threadsModel()); - m_threadBox->setModel(engine->threadsModel()); - m_threadBox->setModelColumn(ThreadData::NameColumn); - m_watchersWindow->setModel(engine->watchersModel()); - if (notify) - notifyCurrentEngine(RequestActivationRole, true); + if (engine) { + if (notify) + notifyCurrentEngine(RequestActivationRole, false); + m_commandWindow->setModel(engine->commandModel()); + m_localsWindow->setModel(engine->localsModel()); + m_modulesWindow->setModel(engine->modulesModel()); + m_registerWindow->setModel(engine->registerModel()); + m_returnWindow->setModel(engine->returnModel()); + m_sourceFilesWindow->setModel(engine->sourceFilesModel()); + m_stackWindow->setModel(engine->stackModel()); + m_threadsWindow->setModel(engine->threadsModel()); + m_threadBox->setModel(engine->threadsModel()); + m_threadBox->setModelColumn(ThreadData::NameColumn); + m_watchersWindow->setModel(engine->watchersModel()); + if (notify) + notifyCurrentEngine(RequestActivationRole, true); + } else { + m_commandWindow->setModel(0); + m_localsWindow->setModel(0); + m_modulesWindow->setModel(0); + m_registerWindow->setModel(0); + m_returnWindow->setModel(0); + m_sourceFilesWindow->setModel(0); + m_stackWindow->setModel(0); + m_threadsWindow->setModel(0); + m_threadBox->setModel(0); + m_threadBox->setModelColumn(ThreadData::NameColumn); + m_watchersWindow->setModel(0); + } } static void changeFontSize(QWidget *widget, qreal size) @@ -2478,7 +2493,9 @@ void DebuggerPluginPrivate::activateDebugMode() void DebuggerPluginPrivate::sessionLoaded() { - m_sessionEngine->loadSessionData(); + m_breakHandler->loadSessionData(); + WatchHandler::loadSessionData(); + synchronizeWatchers(); } void DebuggerPluginPrivate::aboutToUnloadSession() @@ -2494,7 +2511,8 @@ void DebuggerPluginPrivate::aboutToUnloadSession() void DebuggerPluginPrivate::aboutToSaveSession() { - m_sessionEngine->saveSessionData(); + WatchHandler::saveSessionData(); + m_breakHandler->saveSessionData(); } void DebuggerPluginPrivate::executeDebuggerCommand() @@ -2559,9 +2577,6 @@ DebuggerPlugin::DebuggerPlugin() DebuggerPlugin::~DebuggerPlugin() { - delete d->m_sessionEngine; - d->m_sessionEngine = 0; - theInstance = 0; delete DebuggerSettings::instance(); @@ -2826,11 +2841,6 @@ DebuggerLanguages DebuggerPlugin::activeLanguages() const return DebuggerUISwitcher::instance()->activeDebugLanguages(); } -DebuggerEngine *DebuggerPlugin::sessionTemplate() -{ - return d->m_sessionEngine; -} - bool DebuggerPlugin::isRegisterViewVisible() const { return d->m_registerDock->toggleViewAction()->isChecked(); diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index a3b35821cf0..57ec1356b62 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -56,7 +56,6 @@ class DebuggerRunControl; class DebuggerStartParameters; namespace Internal { -class DebuggerListener; class BreakHandler; } @@ -116,10 +115,6 @@ private: void runControlFinished(DebuggerRunControl *runControl); DebuggerLanguages activeLanguages() const; - // This contains per-session data like breakpoints and watched - // expression. It serves as a template for new engine instantiations. - DebuggerEngine *sessionTemplate(); - QMessageBox *showMessageBox(int icon, const QString &title, const QString &text, int buttons = 0); diff --git a/src/plugins/debugger/sessionengine.cpp b/src/plugins/debugger/sessionengine.cpp deleted file mode 100644 index 9ec4632cee3..00000000000 --- a/src/plugins/debugger/sessionengine.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "sessionengine.h" -#include "breakhandler.h" -#include "watchhandler.h" - -#include <utils/qtcassert.h> - -#include <QtCore/QDebug> - -namespace Debugger { -namespace Internal { - -// This class contains data serving as a template for debugger engines -// started during a session. - -SessionEngine::SessionEngine() - : DebuggerEngine(DebuggerStartParameters()) -{ - setObjectName(QLatin1String("SessionEngine")); -} - -void SessionEngine::executeDebuggerCommand(const QString &command) -{ - QTC_ASSERT(false, qDebug() << command) -} - -void SessionEngine::loadSessionData() -{ - breakHandler()->loadSessionData(); - watchHandler()->loadSessionData(); -} - -void SessionEngine::saveSessionData() -{ - watchHandler()->saveSessionData(); - breakHandler()->saveSessionData(); -} - -unsigned SessionEngine::debuggerCapabilities() const -{ - return DebuggerEngine::debuggerCapabilities() - | AddWatcherCapability - | BreakOnThrowAndCatchCapability - | WatchpointCapability; -} - -} // namespace Internal -} // namespace Debugger - diff --git a/src/plugins/debugger/sessionengine.h b/src/plugins/debugger/sessionengine.h deleted file mode 100644 index c00d6f52c90..00000000000 --- a/src/plugins/debugger/sessionengine.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef DEBUGGER_SESSIONENGINE_H -#define DEBUGGER_SESSIONENGINE_H - -#include "debuggerengine.h" - -namespace Debugger { -namespace Internal { - -// This class contains data serving as a template for debugger engines -// started during a session. - -class SessionEngine : public DebuggerEngine -{ - Q_OBJECT - -public: - SessionEngine(); - - virtual void setupEngine() {} - virtual void setupInferior() {} - virtual void runEngine() {} - virtual void shutdownEngine() {} - virtual void shutdownInferior() {} - virtual void executeDebuggerCommand(const QString &command); - virtual unsigned debuggerCapabilities() const; - - virtual bool isSessionEngine() const { return true; } - - void loadSessionData(); - void saveSessionData(); -}; - - -} // namespace Internal -} // namespace Debugger - -#endif // DEBUGGER_SESSIONENGINE_H diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index e4fa0767ff4..e465713a020 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -29,7 +29,6 @@ #include "snapshothandler.h" -#include "sessionengine.h" #include "debuggerconstants.h" #include "debuggerengine.h" #include "debuggerrunner.h" diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index e6ff28c4c1f..7b4c86b6994 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -78,6 +78,9 @@ static int generationCounter = 0; static DebuggerPlugin *plugin() { return DebuggerPlugin::instance(); } +QHash<QByteArray, int> WatchHandler::m_watcherNames; +QHash<QByteArray, int> WatchHandler::m_typeFormats; + //////////////////////////////////////////////////////////////////// // // WatchItem @@ -1383,7 +1386,7 @@ void WatchHandler::watchExpression(const QString &exp) if (exp.isEmpty()) data.setAllUnneeded(); data.iname = watcherName(data.exp); - if (m_engine->isSynchronous() && !m_engine->isSessionEngine()) + if (m_engine->isSynchronous()) m_engine->updateWatchData(data); else insertData(data); @@ -1531,7 +1534,7 @@ void WatchHandler::loadWatchers() //qDebug() << "LOAD WATCHERS: " << m_watchers; } -QStringList WatchHandler::watchedExpressions() const +QStringList WatchHandler::watchedExpressions() { // Filter out invalid watchers. QStringList watcherNames; @@ -1581,17 +1584,18 @@ void WatchHandler::saveTypeFormats() void WatchHandler::saveSessionData() { - QTC_ASSERT(m_engine->isSessionEngine(), return); saveWatchers(); saveTypeFormats(); } void WatchHandler::loadSessionData() { - QTC_ASSERT(m_engine->isSessionEngine(), return); loadWatchers(); loadTypeFormats(); +} +void WatchHandler::synchronizeWatchers() +{ foreach (const QByteArray &exp, m_watcherNames.keys()) { WatchData data; data.iname = watcherName(exp); @@ -1600,7 +1604,6 @@ void WatchHandler::loadSessionData() data.exp = exp; insertData(data); } - updateWatchersWindow(); } void WatchHandler::initializeFromTemplate(WatchHandler *other) diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index c4dc70b4af2..b0c83f3ac6e 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -153,8 +153,8 @@ public: void removeData(const QByteArray &iname); WatchData *findItem(const QByteArray &iname) const; - void loadSessionData(); - void saveSessionData(); + static void loadSessionData(); + static void saveSessionData(); void removeTooltip(); void initializeFromTemplate(WatchHandler *other); @@ -164,8 +164,8 @@ public: { return m_expandedINames.contains(iname); } QSet<QByteArray> expandedINames() const { return m_expandedINames; } - QStringList watchedExpressions() const; - QHash<QByteArray, int> watcherNames() const + static QStringList watchedExpressions(); + static QHash<QByteArray, int> watcherNames() { return m_watcherNames; } QByteArray expansionRequests() const; @@ -177,15 +177,16 @@ public: void addTypeFormats(const QByteArray &type, const QStringList &formats); QByteArray watcherName(const QByteArray &exp); + void synchronizeWatchers(); private: friend class WatchModel; - void loadWatchers(); - void saveWatchers(); + static void loadWatchers(); + static void saveWatchers(); + static void loadTypeFormats(); + static void saveTypeFormats(); - void loadTypeFormats(); - void saveTypeFormats(); void setFormat(const QByteArray &type, int format); void updateWatchersWindow(); void showInEditor(); @@ -197,8 +198,8 @@ private: typedef QMap<QString, QPointer<QObject> > EditHandlers; EditHandlers m_editHandlers; - QHash<QByteArray, int> m_watcherNames; - QHash<QByteArray, int> m_typeFormats; + static QHash<QByteArray, int> m_watcherNames; + static QHash<QByteArray, int> m_typeFormats; QHash<QByteArray, int> m_individualFormats; // Indexed by iname. QHash<QString, QStringList> m_reportedTypeFormats; -- GitLab