diff options
Diffstat (limited to 'src/plugins/debugger/debuggerplugin.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 539 |
1 files changed, 284 insertions, 255 deletions
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<DebuggerMainWindow*> - (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<QDockWidget *> 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<DebuggerMainWindow*>(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<DebuggerRunControl *>(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<DebuggerRunControl *>(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; } ////////////////////////////////////////////////////////////////////// |