From 2161e0f6d9c69e96d79979943f9be3a97ef88f2b Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Nov 2010 11:39:01 +0100 Subject: [PATCH] debugger: refactoring of the plugin interface There's some 'external' and some 'internal' part now. Other plugins are only supposed the external interface. --- src/plugins/debugger/breakhandler.cpp | 18 +- src/plugins/debugger/breakwindow.cpp | 18 +- src/plugins/debugger/cdb/cdbstacktracecontext.cpp | 5 +- src/plugins/debugger/debugger.pro | 1 + src/plugins/debugger/debuggeragents.cpp | 5 +- src/plugins/debugger/debuggerengine.cpp | 33 +- src/plugins/debugger/debuggerengine.h | 7 +- src/plugins/debugger/debuggerplugin.cpp | 539 +++++++++++---------- src/plugins/debugger/debuggerplugin.h | 81 +--- src/plugins/debugger/debuggerrunner.cpp | 37 +- src/plugins/debugger/debuggerrunner.h | 1 + src/plugins/debugger/debuggeruiswitcher.cpp | 33 +- src/plugins/debugger/debuggeruiswitcher.h | 26 +- src/plugins/debugger/gdb/classicgdbengine.cpp | 4 +- src/plugins/debugger/gdb/gdbengine.cpp | 10 +- src/plugins/debugger/gdb/gdbengine.h | 1 - src/plugins/debugger/moduleswindow.cpp | 34 +- src/plugins/debugger/moduleswindow.h | 1 - src/plugins/debugger/qml/qmlcppengine.cpp | 4 +- src/plugins/debugger/qml/qmlengine.cpp | 26 +- src/plugins/debugger/registerwindow.cpp | 4 +- src/plugins/debugger/sourcefileswindow.cpp | 13 +- src/plugins/debugger/stackwindow.cpp | 4 +- src/plugins/debugger/threadswindow.cpp | 4 +- src/plugins/debugger/watchhandler.cpp | 14 +- src/plugins/debugger/watchwindow.cpp | 13 +- src/plugins/qmljsinspector/qmljsinspector.cpp | 4 +- .../qmlprojectmanager/qmlprojectruncontrol.cpp | 34 +- .../qt4projectmanager/qt-s60/s60manager.cpp | 10 +- 29 files changed, 437 insertions(+), 547 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index be2310effb..23e296457f 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -31,7 +31,7 @@ #include "breakpointmarker.h" #include "debuggeractions.h" -#include "debuggerplugin.h" +#include "debuggercore.h" #include "debuggerstringutils.h" #include @@ -40,17 +40,15 @@ #include -namespace Debugger { -namespace Internal { - -static DebuggerPlugin *plugin() { return DebuggerPlugin::instance(); } - ////////////////////////////////////////////////////////////////// // // BreakHandler // ////////////////////////////////////////////////////////////////// +namespace Debugger { +namespace Internal { + BreakHandler::BreakHandler() : m_breakpointIcon(_(":/debugger/images/breakpoint_16.png")), m_disabledBreakpointIcon(_(":/debugger/images/breakpoint_disabled_16.png")), @@ -148,7 +146,7 @@ bool BreakHandler::watchPointAt(quint64 address) const void BreakHandler::saveBreakpoints() { //qDebug() << "SAVING BREAKPOINTS..."; - QTC_ASSERT(plugin(), return); + QTC_ASSERT(debuggerCore(), return); QList list; for (int index = 0; index != size(); ++index) { const BreakpointData *data = at(index); @@ -178,15 +176,15 @@ void BreakHandler::saveBreakpoints() map.insert(_("usefullpath"), _("1")); list.append(map); } - plugin()->setSessionValue("Breakpoints", list); + debuggerCore()->setSessionValue("Breakpoints", list); //qDebug() << "SAVED BREAKPOINTS" << this << list.size(); } void BreakHandler::loadBreakpoints() { - QTC_ASSERT(plugin(), return); + QTC_ASSERT(debuggerCore(), return); //qDebug() << "LOADING BREAKPOINTS..."; - QVariant value = plugin()->sessionValue("Breakpoints"); + QVariant value = debuggerCore()->sessionValue("Breakpoints"); QList list = value.toList(); clear(); foreach (const QVariant &var, list) { diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 14aa6588b8..ba3ecdddde 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -31,8 +31,7 @@ #include "breakhandler.h" #include "debuggeractions.h" -#include "debuggerplugin.h" -#include "debuggerconstants.h" +#include "debuggercore.h" #include "ui_breakpoint.h" #include "ui_breakcondition.h" @@ -44,26 +43,21 @@ #include #include +#include +#include #include #include #include -#include #include #include -#include namespace Debugger { namespace Internal { -static DebuggerPlugin *plugin() -{ - return DebuggerPlugin::instance(); -} - static BreakHandler *breakHandler() { - return plugin()->breakHandler(); + return debuggerCore()->breakHandler(); } static BreakpointData *breakpointAt(int index) @@ -323,7 +317,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) QAction *synchronizeAction = new QAction(tr("Synchronize Breakpoints"), &menu); - synchronizeAction->setEnabled(plugin()->hasSnapshots()); + synchronizeAction->setEnabled(debuggerCore()->hasSnapshots()); QModelIndex idx0 = (si.size() ? si.front() : QModelIndex()); QModelIndex idx2 = idx0.sibling(idx0.row(), 2); @@ -556,7 +550,7 @@ void BreakWindow::rowActivated(const QModelIndex &index) { BreakpointData *data = breakpointAt(index.row()); QTC_ASSERT(data, return); - plugin()->gotoLocation(data->markerFileName(), + debuggerCore()->gotoLocation(data->markerFileName(), data->markerLineNumber(), false); } diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp index 3b0e7b6428..fb826f8897 100644 --- a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp @@ -33,7 +33,7 @@ #include "cdbdumperhelper.h" #include "cdbengine_p.h" #include "debuggeractions.h" -#include "debuggerplugin.h" +#include "debuggercore.h" #include "watchutils.h" #include "threadshandler.h" @@ -74,7 +74,8 @@ CdbStackTraceContext::createSymbolGroup(const CdbCore::ComInterfaces & /* cif */ QStringList uninitializedVariables; const CdbCore::StackFrame &frame = stackFrameAt(index); if (theDebuggerAction(UseCodeModel)->isChecked()) - getUninitializedVariables(DebuggerPlugin::instance()->cppCodeModelSnapshot(), frame.function, frame.fileName, frame.line, &uninitializedVariables); + getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(), + frame.function, frame.fileName, frame.line, &uninitializedVariables); if (debug) qDebug() << frame << uninitializedVariables; CdbSymbolGroupContext *sc = CdbSymbolGroupContext::create(prefix, diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 3ab43200aa..213d18abe5 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -24,6 +24,7 @@ HEADERS += breakhandler.h \ debugger_global.h \ debuggeractions.h \ debuggeragents.h \ + debuggercore.h \ debuggerconstants.h \ debuggerdialogs.h \ debuggerengine.h \ diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index cae6f70ff5..bd5161afa6 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -30,10 +30,9 @@ #include "debuggeragents.h" #include "debuggerengine.h" -#include "debuggerplugin.h" +#include "debuggercore.h" #include "debuggerstringutils.h" #include "stackframe.h" -#include "debuggerconstants.h" #include #include @@ -196,7 +195,7 @@ class LocationMark2 : public TextEditor::ITextMark public: LocationMark2() {} - QIcon icon() const { return DebuggerPlugin::instance()->locationMarkIcon(); } + QIcon icon() const { return debuggerCore()->locationMarkIcon(); } void updateLineNumber(int /*lineNumber*/) {} void updateBlock(const QTextBlock & /*block*/) {} void removedFromEditor() {} diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 776896a1b8..926326dce2 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -31,8 +31,9 @@ #include "debuggeractions.h" #include "debuggeragents.h" -#include "debuggerrunner.h" +#include "debuggercore.h" #include "debuggerplugin.h" +#include "debuggerrunner.h" #include "debuggerstringutils.h" #include "debuggertooltip.h" @@ -87,6 +88,8 @@ using namespace TextEditor; // /////////////////////////////////////////////////////////////////////// +namespace Debugger { + DebuggerStartParameters::DebuggerStartParameters() : isSnapshot(false), attachPID(-1), @@ -106,9 +109,6 @@ void DebuggerStartParameters::clear() *this = DebuggerStartParameters(); } - -namespace Debugger { - QDebug operator<<(QDebug d, DebuggerState state) { //return d << DebuggerEngine::stateName(state) << '(' << int(state) << ')'; @@ -321,7 +321,7 @@ void DebuggerEngine::showModuleSymbols it->setData(2, Qt::DisplayRole, s.state); w->addTopLevelItem(it); } - plugin()->createNewDock(w); + debuggerCore()->createNewDock(w); } void DebuggerEngine::frameUp() @@ -452,7 +452,7 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c { //if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper()) // qDebug() << qPrintable(msg) << "IN STATE" << state(); - plugin()->showMessage(msg, channel, timeout); + debuggerCore()->showMessage(msg, channel, timeout); if (d->m_runControl) { d->m_runControl->showMessage(msg, channel); } else { @@ -516,7 +516,7 @@ void DebuggerEngine::resetLocation() { d->m_disassemblerViewAgent.resetLocation(); d->m_stackHandler.setCurrentIndex(-1); - plugin()->resetLocation(); + debuggerCore()->resetLocation(); } void DebuggerEngine::gotoLocation(const QString &fileName, int lineNumber, bool setMarker) @@ -531,10 +531,10 @@ void DebuggerEngine::gotoLocation(const StackFrame &frame, bool setMarker) { if (theDebuggerBoolSetting(OperateByInstruction) || !frame.isUsable()) { if (setMarker) - plugin()->resetLocation(); + debuggerCore()->resetLocation(); d->m_disassemblerViewAgent.setFrame(frame); } else { - plugin()->gotoLocation(frame.file, frame.line, setMarker); + debuggerCore()->gotoLocation(frame.file, frame.line, setMarker); } } @@ -600,7 +600,7 @@ QStringList DebuggerEngine::qtDumperLibraryLocations() const void DebuggerEngine::showQtDumperLibraryWarning(const QString &details) { - plugin()->showQtDumperLibraryWarning(details); + debuggerCore()->showQtDumperLibraryWarning(details); } QString DebuggerEngine::qtDumperLibraryName() const @@ -1011,7 +1011,7 @@ void DebuggerEngine::updateViews() // should be coordinated by their master engine. if (isSlaveEngine()) return; - plugin()->updateState(this); + debuggerCore()->updateState(this); } bool DebuggerEngine::isSlaveEngine() const @@ -1074,14 +1074,9 @@ qint64 DebuggerEngine::inferiorPid() const return d->m_inferiorPid; } -DebuggerPlugin *DebuggerEngine::plugin() -{ - return DebuggerPlugin::instance(); -} - bool DebuggerEngine::isReverseDebugging() const { - return plugin()->isReverseDebugging(); + return debuggerCore()->isReverseDebugging(); } bool DebuggerEngine::isActive() const @@ -1130,7 +1125,7 @@ void DebuggerEngine::progressPing() QMessageBox *DebuggerEngine::showMessageBox(int icon, const QString &title, const QString &text, int buttons) { - return plugin()->showMessageBox(icon, title, text, buttons); + return debuggerCore()->showMessageBox(icon, title, text, buttons); } DebuggerRunControl *DebuggerEngine::runControl() const @@ -1394,7 +1389,7 @@ void DebuggerEngine::executeDebuggerCommand(const QString &) Internal::BreakHandler *DebuggerEngine::breakHandler() const { - return plugin()->breakHandler(); + return debuggerCore()->breakHandler(); } bool DebuggerEngine::isDying() const diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index a4d2ac5b1c..81c255caa3 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -56,8 +56,6 @@ class IOptionsPage; namespace Debugger { class DebuggerEnginePrivate; -class DebuggerPlugin; -class DebuggerPluginPrivate; class DebuggerRunControl; class QmlCppEngine; @@ -118,6 +116,8 @@ DEBUGGER_EXPORT QDebug operator<<(QDebug str, DebuggerState state); namespace Internal { +class DebuggerCore; +class DebuggerPluginPrivate; class DisassemblerViewAgent; class MemoryViewAgent; class Symbol; @@ -209,7 +209,7 @@ public: (int icon, const QString &title, const QString &text, int buttons = 0); protected: - friend class DebuggerPluginPrivate; + friend class Internal::DebuggerPluginPrivate; virtual void detachDebugger(); virtual void exitDebugger(); virtual void executeStep(); @@ -232,7 +232,6 @@ protected: virtual void frameDown(); public: - static DebuggerPlugin *plugin(); const DebuggerStartParameters &startParameters() const; DebuggerStartParameters &startParameters(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 7988270c40..2a314b12ea 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -32,6 +32,7 @@ #include "debuggeractions.h" #include "debuggeragents.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerdialogs.h" #include "debuggerengine.h" #include "debuggermainwindow.h" @@ -324,7 +325,6 @@ sg1: } using namespace Core; using namespace Debugger::Constants; -using namespace Debugger::Internal; using namespace ProjectExplorer; using namespace TextEditor; @@ -508,7 +508,7 @@ public: : BaseTextMark(fileName, linenumber) {} - QIcon icon() const { return DebuggerPlugin::instance()->locationMarkIcon(); } + QIcon icon() const { return debuggerCore()->locationMarkIcon(); } void updateLineNumber(int /*lineNumber*/) {} void updateBlock(const QTextBlock & /*block*/) {} void removedFromEditor() {} @@ -854,9 +854,8 @@ struct DebuggerActions QAction *frameDownAction; }; -} // namespace Internal +static DebuggerPluginPrivate *theDebuggerCore = 0; -using namespace Debugger::Internal; /////////////////////////////////////////////////////////////////////// // @@ -864,12 +863,13 @@ using namespace Debugger::Internal; // /////////////////////////////////////////////////////////////////////// -class DebuggerPluginPrivate : public QObject +class DebuggerPluginPrivate : public DebuggerCore { Q_OBJECT public: explicit DebuggerPluginPrivate(DebuggerPlugin *plugin); + ~DebuggerPluginPrivate(); bool initialize(const QStringList &arguments, QString *errorMessage); void connectEngine(DebuggerEngine *engine, bool notify = true); @@ -975,12 +975,35 @@ public slots: void showStatusMessage(const QString &msg, int timeout = -1); void openMemoryEditor(); - DebuggerMainWindow *mainWindow() - { return qobject_cast - (DebuggerUISwitcher::instance()->mainWindow()); } + void readSettings(); + void writeSettings() const; + + const CPlusPlus::Snapshot &cppCodeModelSnapshot() const; + + void showQtDumperLibraryWarning(const QString &details); + DebuggerMainWindow *debuggerMainWindow() const; + QWidget *mainWindow() const { return m_uiSwitcher->mainWindow(); } + + bool isRegisterViewVisible() const; + bool hasSnapshots() const { return m_snapshotHandler->size(); } + void createNewDock(QWidget *widget); + + void runControlStarted(DebuggerRunControl *runControl); + void runControlFinished(DebuggerRunControl *runControl); + DebuggerLanguages activeLanguages() const; + void remoteCommand(const QStringList &options, const QStringList &); + + bool isReverseDebugging() const; + QMessageBox *showMessageBox(int icon, const QString &title, + const QString &text, int buttons); + void ensureLogVisible(); + void extensionsInitialized(); - inline void setConfigValue(const QString &name, const QVariant &value); - inline QVariant configValue(const QString &name) const; + BreakHandler *breakHandler() const { return m_breakHandler; } + SnapshotHandler *snapshotHandler() const { return m_snapshotHandler; } + + void setConfigValue(const QString &name, const QVariant &value); + QVariant configValue(const QString &name) const; DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp, RunConfiguration *rc = 0); @@ -1172,15 +1195,20 @@ public slots: currentEngine()->stackHandler()->currentFrame(), true); } - void resetLocation() + bool isActiveDebugLanguage(int lang) const { - // FIXME: code should be moved here. - currentEngine()->resetLocation(); - //d->m_disassemblerViewAgent.resetLocation(); - //d->m_stackHandler.setCurrentIndex(-1); - //plugin()->resetLocation(); + return m_uiSwitcher->activeDebugLanguages() & lang; } + void resetLocation(); + QVariant sessionValue(const QString &name); + void setSessionValue(const QString &name, const QVariant &value); + QIcon locationMarkIcon() const { return m_locationMarkIcon; } + + void openTextEditor(const QString &titlePattern0, const QString &contents); + void clearCppCodeModelSnapshot(); + void showMessage(const QString &msg, int channel, int timeout = -1); + public: DebuggerState m_state; DebuggerUISwitcher *m_uiSwitcher; @@ -1248,7 +1276,7 @@ public: QTimer m_statusTimer; QString m_lastPermanentStatusMessage; - CPlusPlus::Snapshot m_codeModelSnapshot; + mutable CPlusPlus::Snapshot m_codeModelSnapshot; DebuggerPlugin *m_plugin; SnapshotHandler *m_snapshotHandler; @@ -1256,8 +1284,12 @@ public: DebuggerEngine *m_currentEngine; }; + DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) { + QTC_ASSERT(!theDebuggerCore, /**/); + theDebuggerCore = this; + m_plugin = plugin; m_shuttingDown = false; @@ -1304,7 +1336,27 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) m_currentEngine = 0; } -bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *errorMessage) +DebuggerPluginPrivate::~DebuggerPluginPrivate() +{ + m_plugin->removeObject(theDebuggerCore->m_debugMode); + delete m_debugMode; + m_debugMode = 0; + + m_plugin->removeObject(m_uiSwitcher); + delete m_uiSwitcher; + m_uiSwitcher = 0; + + delete m_snapshotHandler; + m_snapshotHandler = 0; +} + +DebuggerCore *debuggerCore() +{ + return theDebuggerCore; +} + +bool DebuggerPluginPrivate::initialize(const QStringList &arguments, + QString *errorMessage) { m_continuableContext = Core::Context("Gdb.Continuable"); m_interruptibleContext = Core::Context("Gdb.Interruptible"); @@ -1475,7 +1527,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), SLOT(executeDebuggerCommand())); - m_plugin->readSettings(); + readSettings(); // Cpp/Qml ui setup m_uiSwitcher = new DebuggerUISwitcher(m_debugMode, this); @@ -2307,6 +2359,7 @@ DebuggerRunControl *DebuggerPluginPrivate::createDebugger return m_debuggerRunControlFactory->create(sp, rc); } +// If updateEngine is set, the engine will update its threads/modules and so forth. void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateEngine) { QTC_ASSERT(engine, return); @@ -2344,7 +2397,7 @@ public: void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine, bool notify) { - static Debugger::DummyEngine dummyEngine; + static DummyEngine dummyEngine; if (!engine) engine = &dummyEngine; @@ -2398,7 +2451,6 @@ void DebuggerPluginPrivate::fontSettingsChanged void DebuggerPluginPrivate::cleanupViews() { - m_plugin->resetLocation(); m_actions.reverseDirectionAction->setChecked(false); m_actions.reverseDirectionAction->setEnabled(false); hideDebuggerToolTip(); @@ -2451,8 +2503,8 @@ void DebuggerPluginPrivate::setBusyCursor(bool busy) void DebuggerPluginPrivate::setSimpleDockWidgetArrangement (Debugger::DebuggerLanguages activeLanguages) { - Debugger::DebuggerUISwitcher *uiSwitcher = DebuggerUISwitcher::instance(); - DebuggerMainWindow *mw = mainWindow(); + DebuggerMainWindow *mw = debuggerMainWindow(); + QTC_ASSERT(mw, return); mw->setTrackingEnabled(false); QList dockWidgets = mw->dockWidgets(); @@ -2483,8 +2535,8 @@ void DebuggerPluginPrivate::setSimpleDockWidgetArrangement m_breakDock->show(); m_watchDock->show(); m_scriptConsoleDock->show(); - if (uiSwitcher->qmlInspectorWindow()) - uiSwitcher->qmlInspectorWindow()->show(); + if (m_uiSwitcher->qmlInspectorWindow()) + m_uiSwitcher->qmlInspectorWindow()->show(); } mw->splitDockWidget(mw->toolBarDockWidget(), m_stackDock, Qt::Vertical); mw->splitDockWidget(m_stackDock, m_watchDock, Qt::Horizontal); @@ -2495,8 +2547,8 @@ void DebuggerPluginPrivate::setSimpleDockWidgetArrangement mw->tabifyDockWidget(m_watchDock, m_sourceFilesDock); mw->tabifyDockWidget(m_watchDock, m_snapshotDock); mw->tabifyDockWidget(m_watchDock, m_scriptConsoleDock); - if (uiSwitcher->qmlInspectorWindow()) - mw->tabifyDockWidget(m_watchDock, uiSwitcher->qmlInspectorWindow()); + if (m_uiSwitcher->qmlInspectorWindow()) + mw->tabifyDockWidget(m_watchDock, m_uiSwitcher->qmlInspectorWindow()); mw->setTrackingEnabled(true); } @@ -2800,7 +2852,7 @@ void DebuggerPluginPrivate::executeDebuggerCommand() void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout) { - m_plugin->showMessage(msg0, LogStatus); + showMessage(msg0, LogStatus); QString msg = msg0; msg.replace(QLatin1Char('\n'), QString()); m_statusLabel->setText(msg); @@ -2830,90 +2882,58 @@ void DebuggerPluginPrivate::coreShutdown() m_shuttingDown = true; } -/////////////////////////////////////////////////////////////////////// -// -// DebuggerPlugin -// -/////////////////////////////////////////////////////////////////////// - -DebuggerPlugin *theInstance = 0; - -DebuggerPlugin *DebuggerPlugin::instance() +void DebuggerPluginPrivate::writeSettings() const { - return theInstance; + QSettings *s = settings(); + DebuggerSettings::instance()->writeSettings(s); + if (m_uiSwitcher) + m_uiSwitcher->writeSettings(s); } -DebuggerPlugin::DebuggerPlugin() +void DebuggerPluginPrivate::readSettings() { - d = new DebuggerPluginPrivate(this); - theInstance = this; + //qDebug() << "PLUGIN READ SETTINGS"; + QSettings *s = settings(); + DebuggerSettings::instance()->readSettings(s); + if (m_uiSwitcher) + m_uiSwitcher->writeSettings(s); } -DebuggerPlugin::~DebuggerPlugin() +const CPlusPlus::Snapshot &DebuggerPluginPrivate::cppCodeModelSnapshot() const { - theInstance = 0; - delete DebuggerSettings::instance(); - - removeObject(d->m_debugMode); - - delete d->m_debugMode; - d->m_debugMode = 0; - - removeObject(d->m_uiSwitcher); - delete d->m_uiSwitcher; - d->m_uiSwitcher = 0; - - delete d->m_snapshotHandler; - d->m_snapshotHandler = 0; - - delete d; + if (m_codeModelSnapshot.isEmpty() + && theDebuggerAction(UseCodeModel)->isChecked()) + m_codeModelSnapshot = CppTools::CppModelManagerInterface::instance()->snapshot(); + return m_codeModelSnapshot; } -bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage) +void DebuggerPluginPrivate::resetLocation() { - return d->initialize(arguments, errorMessage); + currentEngine()->resetLocation(); + // FIXME: code should be moved here from the engine implementation. + //d->m_disassemblerViewAgent.resetLocation(); + //d->m_stackHandler.setCurrentIndex(-1); + m_locationMark.reset(); } -void DebuggerPlugin::setSessionValue(const QString &name, const QVariant &value) +void DebuggerPluginPrivate::setSessionValue(const QString &name, const QVariant &value) { QTC_ASSERT(sessionManager(), return); sessionManager()->setValue(name, value); //qDebug() << "SET SESSION VALUE: " << name; } -QVariant DebuggerPlugin::sessionValue(const QString &name) +QVariant DebuggerPluginPrivate::sessionValue(const QString &name) { QTC_ASSERT(sessionManager(), return QVariant()); //qDebug() << "GET SESSION VALUE: " << name; return sessionManager()->value(name); } -void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value) -{ - QTC_ASSERT(d->m_debugMode, return); - settings()->setValue(name, value); -} - -QVariant DebuggerPlugin::configValue(const QString &name) const -{ - QTC_ASSERT(d->m_debugMode, return QVariant()); - return settings()->value(name); -} - -void DebuggerPlugin::resetLocation() -{ - d->m_locationMark.reset(); -} - -void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker) -{ - d->gotoLocation(file, line, setMarker); -} - -void DebuggerPlugin::openTextEditor(const QString &titlePattern0, +void DebuggerPluginPrivate::openTextEditor(const QString &titlePattern0, const QString &contents) { - if (d->m_shuttingDown) + if (m_shuttingDown) return; QString titlePattern = titlePattern0; EditorManager *editorManager = EditorManager::instance(); @@ -2924,84 +2944,150 @@ void DebuggerPlugin::openTextEditor(const QString &titlePattern0, editorManager->activateEditor(editor, EditorManager::IgnoreNavigationHistory); } -void DebuggerPlugin::writeSettings() const -{ - QSettings *s = settings(); - DebuggerSettings::instance()->writeSettings(s); -} - -void DebuggerPlugin::readSettings() -{ - //qDebug() << "PLUGIN READ SETTINGS"; - QSettings *s = settings(); - DebuggerSettings::instance()->readSettings(s); -} - -const CPlusPlus::Snapshot &DebuggerPlugin::cppCodeModelSnapshot() const -{ - if (d->m_codeModelSnapshot.isEmpty() && theDebuggerAction(UseCodeModel)->isChecked()) - d->m_codeModelSnapshot = CppTools::CppModelManagerInterface::instance()->snapshot(); - return d->m_codeModelSnapshot; -} - -void DebuggerPlugin::clearCppCodeModelSnapshot() -{ - d->m_codeModelSnapshot = CPlusPlus::Snapshot(); -} -ExtensionSystem::IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown() +void DebuggerPluginPrivate::clearCppCodeModelSnapshot() { - disconnect(sessionManager(), - SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), d, 0); - writeSettings(); - if (d->m_uiSwitcher) - d->m_uiSwitcher->aboutToShutdown(); - return SynchronousShutdown; + m_codeModelSnapshot = CPlusPlus::Snapshot(); } -void DebuggerPlugin::showMessage(const QString &msg, int channel, int timeout) +void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int timeout) { //qDebug() << "PLUGIN OUTPUT: " << channel << msg; - LogWindow *ow = d->m_logWindow; - //ConsoleWindow *cw = d->m_consoleWindow; - QTC_ASSERT(ow, return); + //ConsoleWindow *cw = m_consoleWindow; + QTC_ASSERT(m_logWindow, return); switch (channel) { case StatusBar: - // This will append to ow's output pane, too. - d->showStatusMessage(msg, timeout); + // This will append to m_logWindow's output pane, too. + showStatusMessage(msg, timeout); break; case LogMiscInput: - ow->showInput(LogMisc, msg); - ow->showOutput(LogMisc, msg); + m_logWindow->showInput(LogMisc, msg); + m_logWindow->showOutput(LogMisc, msg); break; case LogInput: - ow->showInput(LogInput, msg); - ow->showOutput(LogInput, msg); + m_logWindow->showInput(LogInput, msg); + m_logWindow->showOutput(LogInput, msg); break; case ScriptConsoleOutput: - d->m_scriptConsoleWindow->appendResult(msg); + m_scriptConsoleWindow->appendResult(msg); + break; + case LogError: + m_logWindow->showOutput(channel, msg); + ensureLogVisible(); break; default: - ow->showOutput(channel, msg); - if (channel == LogError) - ensureLogVisible(); + m_logWindow->showOutput(channel, msg); break; } } +DebuggerMainWindow *DebuggerPluginPrivate::debuggerMainWindow() const +{ + return qobject_cast(mainWindow()); +} -////////////////////////////////////////////////////////////////////// -// -// Register specific stuff -// -////////////////////////////////////////////////////////////////////// +void DebuggerPluginPrivate::showQtDumperLibraryWarning(const QString &details) +{ + QMessageBox dialog(mainWindow()); + QPushButton *qtPref = dialog.addButton(tr("Open Qt4 Options"), + QMessageBox::ActionRole); + QPushButton *helperOff = dialog.addButton(tr("Turn off Helper Usage"), + QMessageBox::ActionRole); + QPushButton *justContinue = dialog.addButton(tr("Continue Anyway"), + QMessageBox::AcceptRole); + dialog.setDefaultButton(justContinue); + dialog.setWindowTitle(tr("Debugging Helper Missing")); + dialog.setText(tr("The debugger could not load the debugging helper library.")); + dialog.setInformativeText(tr( + "The debugging helper is used to nicely format the values of some Qt " + "and Standard Library data types. " + "It must be compiled for each used Qt version separately. " + "On the Qt4 options page, select a Qt installation " + "and click Rebuild.")); + if (!details.isEmpty()) + dialog.setDetailedText(details); + dialog.exec(); + if (dialog.clickedButton() == qtPref) { + Core::ICore::instance()->showOptionsDialog( + _(Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY), + _(Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID)); + } else if (dialog.clickedButton() == helperOff) { + theDebuggerAction(UseDebuggingHelpers) + ->setValue(qVariantFromValue(false), false); + } +} + +bool DebuggerPluginPrivate::isRegisterViewVisible() const +{ + return m_registerDock->toggleViewAction()->isChecked(); +} + +void DebuggerPluginPrivate::createNewDock(QWidget *widget) +{ + QDockWidget *dockWidget = + m_uiSwitcher->createDockWidget(CppLanguage, widget); + dockWidget->setWindowTitle(widget->windowTitle()); + dockWidget->setObjectName(widget->windowTitle()); + dockWidget->setFeatures(QDockWidget::DockWidgetClosable); + //dockWidget->setWidget(widget); + //mainWindow()->addDockWidget(Qt::TopDockWidgetArea, dockWidget); + dockWidget->show(); +} + +void DebuggerPluginPrivate::runControlStarted(DebuggerRunControl *runControl) +{ + activateDebugMode(); + if (!hasSnapshots()) + m_uiSwitcher->updateActiveLanguages(); + + const QString message = runControl->idString(); + showMessage(message, StatusBar); + showMessage(DebuggerSettings::instance()->dump(), LogDebug); + m_snapshotHandler->appendSnapshot(runControl); + connectEngine(runControl->engine()); +} + +void DebuggerPluginPrivate::runControlFinished(DebuggerRunControl *runControl) +{ + m_snapshotHandler->removeSnapshot(runControl); + disconnectEngine(); + if (theDebuggerBoolSetting(SwitchModeOnExit)) + if (m_snapshotHandler->size() == 0) + activatePreviousMode(); +} + +void DebuggerPluginPrivate::remoteCommand(const QStringList &options, + const QStringList &) +{ + if (options.isEmpty()) + return; + + unsigned enabledEngines = 0; + QString errorMessage; + + if (!parseArguments(options, + &m_attachRemoteParameters, &enabledEngines, &errorMessage)) { + qWarning("%s", qPrintable(errorMessage)); + return; + } + + if (!attachCmdLine()) + qWarning("%s", qPrintable( + _("Incomplete remote attach command received: %1"). + arg(options.join(QString(QLatin1Char(' ')))))); +} -bool DebuggerPlugin::isReverseDebugging() const +DebuggerLanguages DebuggerPluginPrivate::activeLanguages() const { - return d->m_actions.reverseDirectionAction->isChecked(); + return m_uiSwitcher->activeDebugLanguages(); } -QMessageBox *DebuggerPlugin::showMessageBox(int icon, const QString &title, +bool DebuggerPluginPrivate::isReverseDebugging() const +{ + return m_actions.reverseDirectionAction->isChecked(); +} + +QMessageBox *DebuggerPluginPrivate::showMessageBox(int icon, const QString &title, const QString &text, int buttons) { QMessageBox *mb = new QMessageBox(QMessageBox::Icon(icon), @@ -3011,182 +3097,125 @@ QMessageBox *DebuggerPlugin::showMessageBox(int icon, const QString &title, return mb; } -void DebuggerPlugin::ensureLogVisible() +void DebuggerPluginPrivate::ensureLogVisible() { - QAction *action = d->m_outputDock->toggleViewAction(); + QAction *action = m_outputDock->toggleViewAction(); if (!action->isChecked()) action->trigger(); } -QIcon DebuggerPlugin::locationMarkIcon() const -{ - return d->m_locationMarkIcon; -} - -void DebuggerPlugin::extensionsInitialized() +void DebuggerPluginPrivate::extensionsInitialized() { - d->m_uiSwitcher->initialize(); - d->m_watchersWindow->setVisible(false); - d->m_returnWindow->setVisible(false); - connect(d->m_uiSwitcher, SIGNAL(memoryEditorRequested()), - d, SLOT(openMemoryEditor())); + m_uiSwitcher->initialize(settings()); + m_watchersWindow->setVisible(false); + m_returnWindow->setVisible(false); + connect(m_uiSwitcher, SIGNAL(memoryEditorRequested()), + SLOT(openMemoryEditor())); // time gdb -i mi -ex 'debuggerplugin.cpp:800' -ex r -ex q bin/qtcreator.bin const QByteArray env = qgetenv("QTC_DEBUGGER_TEST"); //qDebug() << "EXTENSIONS INITIALIZED:" << env; // if (!env.isEmpty()) // m_plugin->runTest(QString::fromLocal8Bit(env)); - if (d->m_attachRemoteParameters.attachPid - || !d->m_attachRemoteParameters.attachTarget.isEmpty()) - QTimer::singleShot(0, d, SLOT(attachCmdLine())); + if (m_attachRemoteParameters.attachPid + || !m_attachRemoteParameters.attachTarget.isEmpty()) + QTimer::singleShot(0, this, SLOT(attachCmdLine())); } -QWidget *DebuggerPlugin::mainWindow() const -{ - return d->m_uiSwitcher->mainWindow(); -} +} // namespace Internal -DebuggerRunControl *DebuggerPlugin::createDebugger - (const DebuggerStartParameters &sp, RunConfiguration *rc) -{ - return instance()->d->createDebugger(sp, rc); -} +using namespace Debugger::Internal; -void DebuggerPlugin::startDebugger(RunControl *runControl) -{ - instance()->d->startDebugger(runControl); -} +/////////////////////////////////////////////////////////////////////// +// +// DebuggerPlugin +// +/////////////////////////////////////////////////////////////////////// -void DebuggerPlugin::displayDebugger(RunControl *runControl) +DebuggerPlugin::DebuggerPlugin() { - DebuggerRunControl *rc = qobject_cast(runControl); - QTC_ASSERT(rc, return); - instance()->d->displayDebugger(rc->engine()); + theDebuggerCore = new DebuggerPluginPrivate(this); } -// if updateEngine is set, the engine will update its threads/modules and so forth. -void DebuggerPlugin::displayDebugger(DebuggerEngine *engine, bool updateEngine) +DebuggerPlugin::~DebuggerPlugin() { - instance()->d->displayDebugger(engine, updateEngine); + delete DebuggerSettings::instance(); + delete theDebuggerCore; + theDebuggerCore = 0; } -void DebuggerPlugin::updateState(DebuggerEngine *engine) +bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - d->updateState(engine); + return theDebuggerCore->initialize(arguments, errorMessage); } -void DebuggerPlugin::activateDebugMode() +void DebuggerPlugin::readSettings() { - d->activateDebugMode(); + theDebuggerCore->readSettings(); } -void DebuggerPlugin::createNewDock(QWidget *widget) +void DebuggerPlugin::writeSettings() const { - QDockWidget *dockWidget = - DebuggerUISwitcher::instance()->createDockWidget(CppLanguage, widget); - dockWidget->setWindowTitle(widget->windowTitle()); - dockWidget->setObjectName(widget->windowTitle()); - dockWidget->setFeatures(QDockWidget::DockWidgetClosable); - //dockWidget->setWidget(widget); - //mainWindow()->addDockWidget(Qt::TopDockWidgetArea, dockWidget); - dockWidget->show(); + theDebuggerCore->writeSettings(); } -void DebuggerPlugin::runControlStarted(DebuggerRunControl *runControl) +ExtensionSystem::IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown() { - d->connectEngine(runControl->engine()); - d->m_snapshotHandler->appendSnapshot(runControl); + disconnect(sessionManager(), + SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), + theDebuggerCore, 0); + writeSettings(); + return SynchronousShutdown; } -void DebuggerPlugin::runControlFinished(DebuggerRunControl *runControl) +void DebuggerPlugin::remoteCommand(const QStringList &options, + const QStringList &list) { - Q_UNUSED(runControl); - d->m_snapshotHandler->removeSnapshot(runControl); - d->disconnectEngine(); - if (theDebuggerBoolSetting(SwitchModeOnExit)) - if (d->m_snapshotHandler->size() == 0) - d->activatePreviousMode(); + theDebuggerCore->remoteCommand(options, list); } -DebuggerLanguages DebuggerPlugin::activeLanguages() const + +DebuggerRunControl *DebuggerPlugin::createDebugger + (const DebuggerStartParameters &sp, RunConfiguration *rc) { - return DebuggerUISwitcher::instance()->activeDebugLanguages(); + return theDebuggerCore->createDebugger(sp, rc); } -bool DebuggerPlugin::isRegisterViewVisible() const +void DebuggerPlugin::startDebugger(RunControl *runControl) { - return d->m_registerDock->toggleViewAction()->isChecked(); + theDebuggerCore->startDebugger(runControl); } -bool DebuggerPlugin::hasSnapshots() const +void DebuggerPlugin::displayDebugger(RunControl *runControl) { - return d->m_snapshotHandler->size(); + DebuggerRunControl *rc = qobject_cast(runControl); + QTC_ASSERT(rc, return); + theDebuggerCore->displayDebugger(rc->engine()); } -Internal::BreakHandler *DebuggerPlugin::breakHandler() const +void DebuggerPlugin::runControlStarted(DebuggerRunControl *runControl) { - return d->m_breakHandler; + theDebuggerCore->runControlStarted(runControl); } -Internal::SnapshotHandler *DebuggerPlugin::snapshotHandler() const +void DebuggerPlugin::runControlFinished(DebuggerRunControl *runControl) { - return d->m_snapshotHandler; + theDebuggerCore->runControlFinished(runControl); } -DebuggerEngine *DebuggerPlugin::currentEngine() const +void DebuggerPlugin::extensionsInitialized() { - return d->m_currentEngine; + theDebuggerCore->extensionsInitialized(); } -void DebuggerPlugin::remoteCommand(const QStringList &options, const QStringList &) +bool DebuggerPlugin::isActiveDebugLanguage(int language) { - if (options.isEmpty()) - return; - - unsigned enabledEngines = 0; - QString errorMessage; - - if (!parseArguments(options, - &d->m_attachRemoteParameters, &enabledEngines, &errorMessage)) { - qWarning("%s", qPrintable(errorMessage)); - return; - } - - if (!d->attachCmdLine()) - qWarning("%s", qPrintable( - _("Incomplete remote attach command received: %1"). - arg(options.join(QString(QLatin1Char(' ')))))); + return theDebuggerCore->isActiveDebugLanguage(language); } -void DebuggerPlugin::showQtDumperLibraryWarning(const QString &details) +DebuggerUISwitcher *DebuggerPlugin::uiSwitcher() { - QMessageBox dialog(mainWindow()); - QPushButton *qtPref = dialog.addButton(tr("Open Qt4 Options"), - QMessageBox::ActionRole); - QPushButton *helperOff = dialog.addButton(tr("Turn off Helper Usage"), - QMessageBox::ActionRole); - QPushButton *justContinue = dialog.addButton(tr("Continue Anyway"), - QMessageBox::AcceptRole); - dialog.setDefaultButton(justContinue); - dialog.setWindowTitle(tr("Debugging Helper Missing")); - dialog.setText(tr("The debugger could not load the debugging helper library.")); - dialog.setInformativeText(tr( - "The debugging helper is used to nicely format the values of some Qt " - "and Standard Library data types. " - "It must be compiled for each used Qt version separately. " - "On the Qt4 options page, select a Qt installation " - "and click Rebuild.")); - if (!details.isEmpty()) - dialog.setDetailedText(details); - dialog.exec(); - if (dialog.clickedButton() == qtPref) { - Core::ICore::instance()->showOptionsDialog( - _(Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY), - _(Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID)); - } else if (dialog.clickedButton() == helperOff) { - theDebuggerAction(UseDebuggingHelpers) - ->setValue(qVariantFromValue(false), false); - } + return theDebuggerCore->m_uiSwitcher; } ////////////////////////////////////////////////////////////////////// diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index 200259bbf3..6b0175a6e5 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -31,18 +31,10 @@ #define DEBUGGERPLUGIN_H #include "debugger_global.h" -#include "debuggerconstants.h" #include -QT_BEGIN_NAMESPACE -class QIcon; -class QMessageBox; -QT_END_NAMESPACE - -namespace CPlusPlus { -class Snapshot; -} +#include namespace ProjectExplorer { class RunConfiguration; @@ -50,15 +42,15 @@ class RunControl; } namespace Debugger { -class DebuggerEngine; -class DebuggerPluginPrivate; + class DebuggerRunControl; class DebuggerStartParameters; +class DebuggerUISwitcher; -namespace Internal { -class BreakHandler; -class SnapshotHandler; -} +// This is the "external" interface of the debugger plugin that's +// visible from Creator core. The internal interfact to global +// functionality to be used by debugger views and debugger engines +// is DebuggerCore, implemented in DebuggerPluginPrivate. class DEBUGGER_EXPORT DebuggerPlugin : public ExtensionSystem::IPlugin { @@ -68,68 +60,23 @@ public: DebuggerPlugin(); ~DebuggerPlugin(); - static DebuggerPlugin *instance(); - static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp, ProjectExplorer::RunConfiguration *rc = 0); static void startDebugger(ProjectExplorer::RunControl *runControl); static void displayDebugger(ProjectExplorer::RunControl *runControl); - static void displayDebugger(DebuggerEngine *engine, bool updateEngine = true); - - QVariant sessionValue(const QString &name); - void setSessionValue(const QString &name, const QVariant &value); - QVariant configValue(const QString &name) const; - void setConfigValue(const QString &name, const QVariant &value); - void updateState(DebuggerEngine *engine); - virtual void remoteCommand(const QStringList &options, const QStringList &arguments); - void showQtDumperLibraryWarning(const QString &details); - - QIcon locationMarkIcon() const; - void activateDebugMode(); - - const CPlusPlus::Snapshot &cppCodeModelSnapshot() const; - bool isRegisterViewVisible() const; - bool hasSnapshots() const; - - void openTextEditor(const QString &titlePattern, const QString &contents); - Internal::BreakHandler *breakHandler() const; - Internal::SnapshotHandler *snapshotHandler() const; - DebuggerEngine *currentEngine() const; - -public slots: - void clearCppCodeModelSnapshot(); - void ensureLogVisible(); - - // void runTest(const QString &fileName); - void showMessage(const QString &msg, int channel, int timeout = -1); - void gotoLocation(const QString &fileName, int lineNumber = -1, - bool setMarker = false); + static bool isActiveDebugLanguage(int language); + static DebuggerUISwitcher *uiSwitcher(); private: - friend class DebuggerEngine; - friend class DebuggerPluginPrivate; - friend class DebuggerRunControl; - - void resetLocation(); + // IPlugin implementation. + bool initialize(const QStringList &arguments, QString *errorMessage); + void remoteCommand(const QStringList &options, const QStringList &arguments); + ShutdownFlag aboutToShutdown(); + void extensionsInitialized(); void readSettings(); void writeSettings() const; - - bool isReverseDebugging() const; - void createNewDock(QWidget *widget); void runControlStarted(DebuggerRunControl *runControl); void runControlFinished(DebuggerRunControl *runControl); - DebuggerLanguages activeLanguages() const; - - QMessageBox *showMessageBox(int icon, const QString &title, - const QString &text, int buttons = 0); - - bool initialize(const QStringList &arguments, QString *errorMessage); - ShutdownFlag aboutToShutdown(); - void extensionsInitialized(); - - QWidget *mainWindow() const; - - DebuggerPluginPrivate *d; }; } // namespace Debugger diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index aa095193cd..7077286c49 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -30,6 +30,7 @@ #include "debuggerrunner.h" #include "debuggeractions.h" +#include "debuggercore.h" #include "debuggerengine.h" #include "debuggerplugin.h" #include "debuggerstringutils.h" @@ -112,8 +113,6 @@ static QString msgEngineNotAvailable(const char *engine) "which is disabled.").arg(QLatin1String(engine)); } -static DebuggerPlugin *plugin() { return DebuggerPlugin::instance(); } - // A factory to create DebuggerRunControls DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent, unsigned enabledEngines) @@ -180,16 +179,17 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu sp.dumperLibrary = rc->dumperLibrary(); sp.dumperLibraryLocations = rc->dumperLibraryLocations(); - DebuggerLanguages activeLangs = DebuggerUISwitcher::instance()->activeDebugLanguages(); - if (activeLangs & QmlLanguage) { + if (debuggerCore()->isActiveDebugLanguage(QmlLanguage)) { sp.qmlServerAddress = QLatin1String("127.0.0.1"); sp.qmlServerPort = runConfiguration->qmlDebugServerPort(); sp.projectDir = runConfiguration->target()->project()->projectDirectory(); if (runConfiguration->target()->activeBuildConfiguration()) - sp.projectBuildDir = runConfiguration->target()->activeBuildConfiguration()->buildDirectory(); + sp.projectBuildDir = runConfiguration->target() + ->activeBuildConfiguration()->buildDirectory(); - sp.processArgs.append(QLatin1String("-qmljsdebugger=port:") + QString::number(sp.qmlServerPort)); + sp.processArgs.append(QLatin1String("-qmljsdebugger=port:") + + QString::number(sp.qmlServerPort)); } // FIXME: If it's not yet build this will be empty and not filled @@ -413,7 +413,7 @@ void DebuggerRunControl::createEngine(const DebuggerStartParameters &startParams // Figure out engine according to toolchain, executable, attach or default. DebuggerEngineType engineType = NoEngineType; - DebuggerLanguages activeLangs = DebuggerPlugin::instance()->activeLanguages(); + DebuggerLanguages activeLangs = debuggerCore()->activeLanguages(); const unsigned enabledEngineTypes = d->enabledEngines(); if (sp.executable.endsWith(_(".js"))) engineType = ScriptEngineType; @@ -540,7 +540,7 @@ bool DebuggerRunControl::checkDebugConfiguration(int toolChain, bool success = true; - if (!(DebuggerPlugin::instance()->activeLanguages() & CppLanguage)) + if (!(debuggerCore()->activeLanguages() & CppLanguage)) return success; switch(toolChain) { @@ -589,14 +589,7 @@ void DebuggerRunControl::start() return; } - plugin()->activateDebugMode(); - DebuggerUISwitcher::instance()->aboutToStartDebugger(); - - const QString message = tr("Starting debugger '%1' for tool chain '%2'..."). - arg(d->m_engine->objectName(), toolChainName(sp.toolChainType)); - plugin()->showMessage(message, StatusBar); - plugin()->showMessage(DebuggerSettings::instance()->dump(), LogDebug); - plugin()->runControlStarted(this); + debuggerCore()->runControlStarted(this); // We might get a synchronous startFailed() notification on Windows, // when launching the process fails. Emit a proper finished() sequence. @@ -611,6 +604,13 @@ void DebuggerRunControl::start() } } +QString DebuggerRunControl::idString() const +{ + return tr("Starting debugger '%1' for tool chain '%2'...") + .arg(d->m_engine->objectName()) + .arg(toolChainName(d->m_engine->startParameters().toolChainType)); +} + void DebuggerRunControl::startFailed() { emit addToOutputWindowInline(this, tr("Debugging has failed"), false); @@ -624,7 +624,7 @@ void DebuggerRunControl::handleFinished() emit addToOutputWindowInline(this, tr("Debugging has finished"), false); if (engine()) engine()->handleFinished(); - plugin()->runControlFinished(this); + debuggerCore()->runControlFinished(this); } void DebuggerRunControl::showMessage(const QString &msg, int channel) @@ -652,7 +652,7 @@ bool DebuggerRunControl::aboutToStop() const " Would you still like to terminate it?"); const QMessageBox::StandardButton answer = - QMessageBox::question(DebuggerUISwitcher::instance()->mainWindow(), + QMessageBox::question(debuggerCore()->mainWindow(), tr("Close Debugging Session"), question, QMessageBox::Yes|QMessageBox::No); return answer == QMessageBox::Yes; @@ -754,4 +754,5 @@ RunConfiguration *DebuggerRunControl::runConfiguration() const { return d->m_myRunConfiguration.data(); } + } // namespace Debugger diff --git a/src/plugins/debugger/debuggerrunner.h b/src/plugins/debugger/debuggerrunner.h index 2288161eff..ff97fbb05c 100644 --- a/src/plugins/debugger/debuggerrunner.h +++ b/src/plugins/debugger/debuggerrunner.h @@ -120,6 +120,7 @@ public: QString *errorMessage, QString *settingsCategory = 0, QString *settingsPage = 0); + QString idString() const; signals: void engineRequestSetup(); diff --git a/src/plugins/debugger/debuggeruiswitcher.cpp b/src/plugins/debugger/debuggeruiswitcher.cpp index cc2e6a0c3e..80aa00fb91 100644 --- a/src/plugins/debugger/debuggeruiswitcher.cpp +++ b/src/plugins/debugger/debuggeruiswitcher.cpp @@ -140,8 +140,6 @@ struct DebuggerUISwitcherPrivate QWeakPointer m_previousRunConfiguration; bool m_initialized; - - static DebuggerUISwitcher *m_instance; }; DebuggerUISwitcherPrivate::DebuggerUISwitcherPrivate(DebuggerUISwitcher *q) @@ -160,8 +158,6 @@ DebuggerUISwitcherPrivate::DebuggerUISwitcherPrivate(DebuggerUISwitcher *q) { } -DebuggerUISwitcher *DebuggerUISwitcherPrivate::m_instance = 0; - DebuggerUISwitcher::DebuggerUISwitcher(BaseMode *mode, QObject* parent) : QObject(parent), d(new DebuggerUISwitcherPrivate(this)) { @@ -180,13 +176,10 @@ DebuggerUISwitcher::DebuggerUISwitcher(BaseMode *mode, QObject* parent) d->m_debugMenu = am->actionContainer(ProjectExplorer::Constants::M_DEBUG); d->m_viewsMenu = am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS)); QTC_ASSERT(d->m_viewsMenu, return) - - DebuggerUISwitcherPrivate::m_instance = this; } DebuggerUISwitcher::~DebuggerUISwitcher() { - DebuggerUISwitcherPrivate::m_instance = 0; delete d; } @@ -345,11 +338,6 @@ void DebuggerUISwitcher::createViewsMenuItems() d->m_viewsMenu->addAction(cmd); } -DebuggerUISwitcher *DebuggerUISwitcher::instance() -{ - return DebuggerUISwitcherPrivate::m_instance; -} - void DebuggerUISwitcher::addLanguage(const DebuggerLanguage &languageId, const Context &context) { bool activate = (d->m_supportedLanguages == AnyLanguage); @@ -595,20 +583,8 @@ QWidget *DebuggerUISwitcher::createContents(BaseMode *mode) return splitter; } -void DebuggerUISwitcher::aboutToStartDebugger() -{ - if (!DebuggerPlugin::instance()->hasSnapshots()) - updateActiveLanguages(); -} - -void DebuggerUISwitcher::aboutToShutdown() -{ - writeSettings(); -} - -void DebuggerUISwitcher::writeSettings() const +void DebuggerUISwitcher::writeSettings(QSettings *settings) const { - QSettings *settings = ICore::instance()->settings(); { settings->beginGroup(QLatin1String("DebugMode.CppMode")); QHashIterator it(d->m_dockWidgetActiveStateCpp); @@ -629,9 +605,8 @@ void DebuggerUISwitcher::writeSettings() const } } -void DebuggerUISwitcher::readSettings() +void DebuggerUISwitcher::readSettings(QSettings *settings) { - QSettings *settings = ICore::instance()->settings(); d->m_dockWidgetActiveStateCpp.clear(); d->m_dockWidgetActiveStateQmlCpp.clear(); @@ -660,12 +635,12 @@ void DebuggerUISwitcher::readSettings() d->m_activeDebugLanguages = langs; } -void DebuggerUISwitcher::initialize() +void DebuggerUISwitcher::initialize(QSettings *settings) { createViewsMenuItems(); emit dockResetRequested(AnyLanguage); - readSettings(); + readSettings(settings); updateUi(); diff --git a/src/plugins/debugger/debuggeruiswitcher.h b/src/plugins/debugger/debuggeruiswitcher.h index b7ec212119..4b243db843 100644 --- a/src/plugins/debugger/debuggeruiswitcher.h +++ b/src/plugins/debugger/debuggeruiswitcher.h @@ -37,13 +37,14 @@ QT_BEGIN_NAMESPACE class QDockWidget; +class QSettings; QT_END_NAMESPACE namespace Core { - class Command; - class Context; - class IMode; - class BaseMode; +class Command; +class Context; +class IMode; +class BaseMode; } namespace Utils { @@ -51,9 +52,9 @@ class FancyMainWindow; } namespace ProjectExplorer { - class Project; - class Target; - class RunConfiguration; +class Project; +class Target; +class RunConfiguration; } namespace Debugger { @@ -71,8 +72,6 @@ public: explicit DebuggerUISwitcher(Core::BaseMode *mode, QObject *parent = 0); virtual ~DebuggerUISwitcher(); - static DebuggerUISwitcher *instance(); - // debuggable languages are registered with this function. void addLanguage(const DebuggerLanguage &language, const Core::Context &context); @@ -90,10 +89,8 @@ public: DebuggerLanguages activeDebugLanguages() const; // called when all dependent plugins have loaded - void initialize(); + void initialize(QSettings *settings); - void aboutToStartDebugger(); - void aboutToShutdown(); void onModeChanged(Core::IMode *mode); // most common debugger windows @@ -130,8 +127,11 @@ private slots: void updateUiForCurrentRunConfiguration(); void updateUiOnFileListChange(); +public slots: void updateActiveLanguages(); void updateDockWidgetSettings(); + void readSettings(QSettings *settings); + void writeSettings(QSettings *settings) const; private: // Used by MainWindow @@ -143,8 +143,6 @@ private: void hideInactiveWidgets(); void createViewsMenuItems(); - void readSettings(); - void writeSettings() const; bool isQmlCppActive() const; bool isQmlActive() const; diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index 9cc0ed3b77..8f227d2f53 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -32,8 +32,8 @@ #include "abstractgdbadapter.h" #include "debuggeractions.h" +#include "debuggercore.h" #include "debuggerstringutils.h" -#include "debuggerplugin.h" #include "stackhandler.h" #include "watchhandler.h" @@ -664,7 +664,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response) ? qVariantValue(response.cookie) : stackHandler()->currentFrame(); if (frame.isUsable()) - getUninitializedVariables(plugin()->cppCodeModelSnapshot(), + getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(), frame.function, frame.file, frame.line, &uninitializedVariables); } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 02776557d3..089322f019 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -34,6 +34,7 @@ #include "gdboptionspage.h" #include "debuggeruiswitcher.h" #include "debuggermainwindow.h" +#include "debuggercore.h" #include "debuggerplugin.h" #include "debuggerrunner.h" @@ -203,11 +204,6 @@ DebuggerStartMode GdbEngine::startMode() const return startParameters().startMode; } -QMainWindow *GdbEngine::mainWindow() const -{ - return DebuggerUISwitcher::instance()->mainWindow(); -} - AbstractGdbProcess *GdbEngine::gdbProc() const { return m_gdbAdapter->gdbProc(); @@ -3077,7 +3073,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response) void GdbEngine::reloadRegisters() { - if (!plugin()->isRegisterViewVisible()) + if (!debuggerCore()->isRegisterViewVisible()) return; if (state() != InferiorStopOk && state() != InferiorUnrunnable) @@ -4371,7 +4367,7 @@ void GdbEngine::createFullBacktrace() void GdbEngine::handleCreateFullBacktrace(const GdbResponse &response) { if (response.resultClass == GdbResultDone) { - plugin()->openTextEditor(_("Backtrace $"), + debuggerCore()->openTextEditor(_("Backtrace $"), _(response.data.findChild("consolestreamoutput").data())); } } diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 529d9abff0..396693ee8b 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -525,7 +525,6 @@ private: ////////// View & Data Stuff ////////// // Convenience Functions // QString errorMessage(QProcess::ProcessError error); - QMainWindow *mainWindow() const; AbstractGdbProcess *gdbProc() const; void showExecutionError(const QString &message); diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp index 8cff2955ff..e73cab44a6 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -31,8 +31,8 @@ #include "debuggeractions.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include #include @@ -53,16 +53,6 @@ namespace Debugger { namespace Internal { -static DebuggerPlugin *plugin() -{ - return DebuggerPlugin::instance(); -} - -static DebuggerEngine *currentEngine() -{ - return DebuggerPlugin::instance()->currentEngine(); -} - ModulesWindow::ModulesWindow(QWidget *parent) : QTreeView(parent), m_alwaysResizeColumnsToContents(false) { @@ -82,23 +72,7 @@ ModulesWindow::ModulesWindow(QWidget *parent) void ModulesWindow::moduleActivated(const QModelIndex &index) { - plugin()->gotoLocation(index.data().toString()); -} - -void ModulesWindow::resizeEvent(QResizeEvent *event) -{ - //QHeaderView *hv = header(); - //int totalSize = event->size().width() - 110; - //hv->resizeSection(0, totalSize / 4); - //hv->resizeSection(1, totalSize / 4); - //hv->resizeSection(2, totalSize / 4); - //hv->resizeSection(3, totalSize / 4); - //hv->resizeSection(0, 60); - //hv->resizeSection(1, (totalSize * 50) / 100); - //hv->resizeSection(2, (totalSize * 50) / 100); - //hv->resizeSection(3, 50); - //setColumnHidden(3, true); - QTreeView::resizeEvent(event); + debuggerCore()->gotoLocation(index.data().toString()); } void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) @@ -110,7 +84,7 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) if (index.isValid()) name = index.data().toString(); - DebuggerEngine *engine = currentEngine(); + DebuggerEngine *engine = debuggerCore()->currentEngine(); const bool enabled = engine->debuggerActionsEnabled(); const unsigned capabilities = engine->debuggerCapabilities(); @@ -191,7 +165,7 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actLoadSymbolsForModule) { engine->loadSymbols(name); } else if (act == actEditFile) { - plugin()->gotoLocation(name); + debuggerCore()->gotoLocation(name); } else if (act == actShowSymbols) { // FIXME setModelData(RequestModuleSymbolsRole, name); } diff --git a/src/plugins/debugger/moduleswindow.h b/src/plugins/debugger/moduleswindow.h index 49976ecc0e..87fc191ed7 100644 --- a/src/plugins/debugger/moduleswindow.h +++ b/src/plugins/debugger/moduleswindow.h @@ -49,7 +49,6 @@ private slots: void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); } private: - void resizeEvent(QResizeEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); void setModel(QAbstractItemModel *model); diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index 20b3901ea7..8cd04b7557 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -1,7 +1,7 @@ #include "qmlcppengine.h" #include "qmlengine.h" #include "debuggeruiswitcher.h" -#include "debuggerplugin.h" +#include "debuggercore.h" #include #include @@ -124,7 +124,7 @@ void QmlCppEngine::setActiveEngine(DebuggerLanguage language) } if (previousEngine != d->m_activeEngine) { showStatusMessage(tr("%1 debugger activated").arg(engineName)); - plugin()->displayDebugger(d->m_activeEngine, updateEngine); + Internal::debuggerCore()->displayDebugger(d->m_activeEngine, updateEngine); } } diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 99232c51fc..b41b0a5f04 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -33,7 +33,6 @@ #include "debuggeractions.h" #include "debuggertooltip.h" #include "debuggerconstants.h" -#include "debuggerplugin.h" #include "debuggerdialogs.h" #include "debuggerstringutils.h" #include "debuggeruiswitcher.h" @@ -236,36 +235,37 @@ void QmlEngine::connectionEstablished() { attemptBreakpointSynchronization(); - ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); + ExtensionSystem::PluginManager *pluginManager = + ExtensionSystem::PluginManager::instance(); pluginManager->addObject(d->m_adapter); pluginManager->addObject(this); d->m_addedAdapterToObjectPool = true; - plugin()->showMessage(tr("QML Debugger connected."), StatusBar); + showMessage(tr("QML Debugger connected."), StatusBar); notifyEngineRunAndInferiorRunOk(); } void QmlEngine::connectionStartupFailed() { - QMessageBox::critical(0, - tr("Failed to connect to debugger"), - tr("Could not connect to QML debugger server at %1:%2.") - .arg(startParameters().qmlServerAddress) - .arg(startParameters().qmlServerPort)); + QMessageBox::critical(0, tr("Failed to connect to debugger"), + tr("Could not connect to QML debugger server at %1:%2.") + .arg(startParameters().qmlServerAddress) + .arg(startParameters().qmlServerPort)); notifyEngineRunFailed(); } void QmlEngine::connectionError(QAbstractSocket::SocketError socketError) { if (socketError ==QAbstractSocket::RemoteHostClosedError) - plugin()->showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar); + showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar); } void QmlEngine::serviceConnectionError(const QString &serviceName) { - showMessage(tr("QML Debugger: Could not connect to service '%1'.").arg(serviceName), StatusBar); + showMessage(tr("QML Debugger: Could not connect to service '%1'.") + .arg(serviceName), StatusBar); } void QmlEngine::runEngine() @@ -371,7 +371,7 @@ void QmlEngine::shutdownEngine() shutdownEngineAsSlave(); notifyEngineShutdownOk(); - plugin()->showMessage(QString(), StatusBar); + showMessage(QString(), StatusBar); } void QmlEngine::setupEngine() @@ -756,7 +756,7 @@ void QmlEngine::messageReceived(const QByteArray &message) if (iname.startsWith("watch.")) { watchHandler()->insertData(data); } else if(iname == "console") { - plugin()->showMessage(data.value, ScriptConsoleOutput); + showMessage(data.value, ScriptConsoleOutput); } else { qWarning() << "QmlEngine: Unexcpected result: " << iname << data.value; } @@ -807,7 +807,7 @@ void QmlEngine::messageReceived(const QByteArray &message) void QmlEngine::disconnected() { - plugin()->showMessage(tr("QML Debugger disconnected."), StatusBar); + showMessage(tr("QML Debugger disconnected."), StatusBar); notifyInferiorExited(); } diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index c893957684..053b23719f 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -30,9 +30,9 @@ #include "registerwindow.h" #include "debuggeractions.h" -#include "debuggerplugin.h" #include "debuggeragents.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerengine.h" #include "registerhandler.h" #include "watchdelegatewidgets.h" @@ -54,7 +54,7 @@ namespace Internal { static DebuggerEngine *currentEngine() { - return DebuggerPlugin::instance()->currentEngine(); + return debuggerCore()->currentEngine(); } static RegisterHandler *currentHandler() diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp index 0267ca89f3..f7bcadf213 100644 --- a/src/plugins/debugger/sourcefileswindow.cpp +++ b/src/plugins/debugger/sourcefileswindow.cpp @@ -31,8 +31,8 @@ #include "debuggeractions.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include #include @@ -54,14 +54,9 @@ namespace Debugger { namespace Internal { -static DebuggerPlugin *plugin() -{ - return DebuggerPlugin::instance(); -} - static DebuggerEngine *currentEngine() { - return DebuggerPlugin::instance()->currentEngine(); + return debuggerCore()->currentEngine(); } SourceFilesWindow::SourceFilesWindow(QWidget *parent) @@ -86,7 +81,7 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent) void SourceFilesWindow::sourceFileActivated(const QModelIndex &index) { - plugin()->gotoLocation(index.data().toString()); + debuggerCore()->gotoLocation(index.data().toString()); } void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) @@ -120,7 +115,7 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) if (act == act1) currentEngine()->reloadSourceFiles(); else if (act == act2) - plugin()->gotoLocation(name); + debuggerCore()->gotoLocation(name); } } // namespace Internal diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index d7e61330b3..f5720e2644 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -33,8 +33,8 @@ #include "debuggeractions.h" #include "debuggeragents.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include #include @@ -52,7 +52,7 @@ namespace Internal { static DebuggerEngine *currentEngine() { - return DebuggerPlugin::instance()->currentEngine(); + return debuggerCore()->currentEngine(); } StackWindow::StackWindow(QWidget *parent) diff --git a/src/plugins/debugger/threadswindow.cpp b/src/plugins/debugger/threadswindow.cpp index 622251ec80..e63ba6656e 100644 --- a/src/plugins/debugger/threadswindow.cpp +++ b/src/plugins/debugger/threadswindow.cpp @@ -32,8 +32,8 @@ #include "threadshandler.h" #include "debuggeractions.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include @@ -66,7 +66,7 @@ ThreadsWindow::ThreadsWindow(QWidget *parent) void ThreadsWindow::rowActivated(const QModelIndex &index) { - DebuggerPlugin::instance()->currentEngine()->selectThread(index.row()); + debuggerCore()->currentEngine()->selectThread(index.row()); } void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 38ca032426..46b2cb4f2f 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -32,8 +32,8 @@ #include "breakhandler.h" #include "debuggeractions.h" #include "debuggeragents.h" +#include "debuggercore.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include "watchutils.h" #if USE_MODEL_TEST @@ -75,8 +75,6 @@ static const QString strNotInScope = static int watcherCounter = 0; static int generationCounter = 0; -static DebuggerPlugin *plugin() { return DebuggerPlugin::instance(); } - QHash WatchHandler::m_watcherNames; QHash WatchHandler::m_typeFormats; @@ -1461,7 +1459,7 @@ void WatchHandler::removeWatchExpression(const QString &exp0) void WatchHandler::updateWatchersWindow() { // Force show/hide of watchers and return view. - plugin()->updateState(m_engine); + debuggerCore()->updateState(m_engine); } void WatchHandler::updateWatchers() @@ -1480,7 +1478,7 @@ void WatchHandler::updateWatchers() void WatchHandler::loadWatchers() { - QVariant value = plugin()->sessionValue("Watchers"); + QVariant value = debuggerCore()->sessionValue("Watchers"); foreach (const QString &exp, value.toStringList()) m_watcherNames[exp.toLatin1()] = watcherCounter++; @@ -1504,12 +1502,12 @@ QStringList WatchHandler::watchedExpressions() void WatchHandler::saveWatchers() { //qDebug() << "SAVE WATCHERS: " << m_watchers; - plugin()->setSessionValue("Watchers", QVariant(watchedExpressions())); + debuggerCore()->setSessionValue("Watchers", QVariant(watchedExpressions())); } void WatchHandler::loadTypeFormats() { - QVariant value = plugin()->sessionValue("DefaultFormats"); + QVariant value = debuggerCore()->sessionValue("DefaultFormats"); QMap typeFormats = value.toMap(); QMapIterator it(typeFormats); while (it.hasNext()) { @@ -1532,7 +1530,7 @@ void WatchHandler::saveTypeFormats() typeFormats.insert(key, format); } } - plugin()->setSessionValue("DefaultFormats", QVariant(typeFormats)); + debuggerCore()->setSessionValue("DefaultFormats", QVariant(typeFormats)); } void WatchHandler::saveSessionData() diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 10e01f5d23..bcab265b8f 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -33,9 +33,9 @@ #include "debuggeragents.h" #include "debuggeractions.h" #include "debuggerconstants.h" +#include "debuggercore.h" #include "debuggerdialogs.h" #include "debuggerengine.h" -#include "debuggerplugin.h" #include "watchdelegatewidgets.h" #include "watchhandler.h" @@ -63,14 +63,9 @@ namespace Debugger { namespace Internal { -static DebuggerPlugin *plugin() -{ - return DebuggerPlugin::instance(); -} - static DebuggerEngine *currentEngine() { - return DebuggerPlugin::instance()->currentEngine(); + return debuggerCore()->currentEngine(); } class WatchDelegate : public QItemDelegate @@ -461,14 +456,14 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actRemoveWatchExpression) { removeWatchExpression(exp); } else if (act == actClearCodeModelSnapshot) { - plugin()->clearCppCodeModelSnapshot(); + debuggerCore()->clearCppCodeModelSnapshot(); } else if (act == clearTypeFormatAction) { setModelData(LocalsTypeFormatRole, -1, mi1); } else if (act == clearIndividualFormatAction) { setModelData(LocalsIndividualFormatRole, -1, mi1); } else if (act == actShowInEditor) { QString contents = handler->editorContents(); - plugin()->openTextEditor(tr("Locals & Watchers"), contents); + debuggerCore()->openTextEditor(tr("Locals & Watchers"), contents); } else { for (int i = 0; i != typeFormatActions.size(); ++i) { if (act == typeFormatActions.at(i)) diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 66c9b4333a..8cbc61e87d 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -463,7 +463,7 @@ void InspectorUi::reloadQmlViewer() void InspectorUi::setSimpleDockWidgetArrangement(const Debugger::DebuggerLanguages &activeLanguages) { - Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerUISwitcher::instance(); + Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerPlugin::uiSwitcher(); Utils::FancyMainWindow *mw = uiSwitcher->mainWindow(); mw->setTrackingEnabled(false); @@ -592,7 +592,7 @@ bool InspectorUi::addQuotesForData(const QVariant &value) const void InspectorUi::setupDockWidgets() { - Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerUISwitcher::instance(); + Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerPlugin::uiSwitcher(); m_toolbar->createActions(Core::Context(Debugger::Constants::C_QMLDEBUGGER)); m_toolbar->setObjectName("QmlInspectorToolbar"); diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp index d1876648e3..3e5b1b22ae 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp @@ -144,23 +144,22 @@ QmlRunControlFactory::~QmlRunControlFactory() bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const { - QmlProjectRunConfiguration *config = qobject_cast(runConfiguration); - if (mode == ProjectExplorer::Constants::RUNMODE) { + QmlProjectRunConfiguration *config = + qobject_cast(runConfiguration); + if (mode == ProjectExplorer::Constants::RUNMODE) return config != 0 && !config->viewerPath().isEmpty(); - } else { - bool qmlDebugSupportInstalled = Debugger::DebuggerUISwitcher::instance()->supportedLanguages() - & Debugger::QmlLanguage; - - if (config && qmlDebugSupportInstalled) { - if (!config->observerPath().isEmpty()) { - return true; - } - - if (config->qtVersion() && Qt4ProjectManager::QmlObserverTool::canBuild(config->qtVersion())) { - return true; - } else { - return false; - } + + bool qmlDebugSupportInstalled = + Debugger::DebuggerPlugin::isActiveDebugLanguage(Debugger::QmlLanguage); + + if (config && qmlDebugSupportInstalled) { + if (!config->observerPath().isEmpty()) + return true; + + if (config->qtVersion() && Qt4ProjectManager::QmlObserverTool::canBuild(config->qtVersion())) { + return true; + } else { + return false; } } @@ -212,8 +211,7 @@ ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProj return 0; } - Debugger::DebuggerRunControl *debuggerRunControl = Debugger::DebuggerPlugin::createDebugger(params, runConfig); - return debuggerRunControl; + return Debugger::DebuggerPlugin::createDebugger(params, runConfig); } void QmlRunControlFactory::showQmlObserverToolWarning() { diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp index cb0dae8594..7f963d8d33 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -122,11 +121,10 @@ S60Manager::S60Manager(QObject *parent) addAutoReleasedObject(new S60CreatePackageStepFactory); addAutoReleasedObject(new S60DeployStepFactory); - if (Debugger::DebuggerPlugin::instance()) - addAutoReleasedObject(new RunControlFactory - (QLatin1String(ProjectExplorer::Constants::DEBUGMODE), - tr("Debug on Device"), parent)); + addAutoReleasedObject(new RunControlFactory + (QLatin1String(ProjectExplorer::Constants::DEBUGMODE), + tr("Debug on Device"), parent)); updateQtVersions(); connect(m_devices, SIGNAL(qtVersionsChanged()), this, SLOT(updateQtVersions())); -- 2.11.0