From 7d41e04884e11ec7a1e4e1d84d5967a725aefa21 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri, 17 Apr 2009 09:03:32 +0200 Subject: [PATCH] Split apart debugger options pages, allow specifying a path to CDB. Modify engine creation funcs to populate a list of option pages to be able to handle engine enabling independently of the actual engine creation. --- src/libs/utils/pathchooser.cpp | 45 +++--- src/libs/utils/pathchooser.h | 2 + src/plugins/debugger/Debugger.pluginspec | 2 +- src/plugins/debugger/cdb/cdb.pri | 14 +- src/plugins/debugger/cdb/cdbdebugengine.cpp | 68 ++++++--- src/plugins/debugger/cdb/cdbdebugengine.h | 10 +- src/plugins/debugger/cdb/cdbdebugengine_p.h | 10 +- src/plugins/debugger/cdb/cdboptions.cpp | 113 +++++++++++++++ src/plugins/debugger/cdb/cdboptions.h | 68 +++++++++ src/plugins/debugger/cdb/cdboptionspage.cpp | 135 ++++++++++++++++++ src/plugins/debugger/cdb/cdboptionspage.h | 95 ++++++++++++ .../debugger/cdb/cdboptionspagewidget.ui | 94 ++++++++++++ src/plugins/debugger/commonoptionspage.ui | 110 ++++++++++++++ src/plugins/debugger/debugger.pro | 9 +- src/plugins/debugger/debuggerconstants.h | 4 + src/plugins/debugger/debuggermanager.cpp | 31 ++-- src/plugins/debugger/debuggermanager.h | 10 +- src/plugins/debugger/debuggerplugin.cpp | 95 ++++-------- src/plugins/debugger/debuggerplugin.h | 5 - src/plugins/debugger/gdbengine.cpp | 4 +- src/plugins/debugger/gdboptionspage.cpp | 85 +++++++++++ src/plugins/debugger/gdboptionspage.h | 37 +++++ .../{gdboptionpage.ui => gdboptionspage.ui} | 82 +---------- src/plugins/debugger/scriptengine.cpp | 2 +- 24 files changed, 914 insertions(+), 216 deletions(-) create mode 100644 src/plugins/debugger/cdb/cdboptions.cpp create mode 100644 src/plugins/debugger/cdb/cdboptions.h create mode 100644 src/plugins/debugger/cdb/cdboptionspage.cpp create mode 100644 src/plugins/debugger/cdb/cdboptionspage.h create mode 100644 src/plugins/debugger/cdb/cdboptionspagewidget.ui create mode 100644 src/plugins/debugger/commonoptionspage.ui create mode 100644 src/plugins/debugger/gdboptionspage.cpp create mode 100644 src/plugins/debugger/gdboptionspage.h rename src/plugins/debugger/{gdboptionpage.ui => gdboptionspage.ui} (61%) diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 1e246fda9c4..efc49881c98 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -44,15 +44,17 @@ #include <QtGui/QToolButton> #include <QtGui/QPushButton> -namespace Core { -namespace Utils { - #ifdef Q_OS_MAC -/*static*/ const char * const PathChooser::browseButtonLabel = "Choose..."; +/*static*/ const char * const Core::Utils::PathChooser::browseButtonLabel = + QT_TRANSLATE_NOOP("Core::Utils::PathChooser", "Choose..."); #else -/*static*/ const char * const PathChooser::browseButtonLabel = "Browse..."; +/*static*/ const char * const Core::Utils::PathChooser::browseButtonLabel = + QT_TRANSLATE_NOOP("Core::Utils::PathChooser", "Browse..."); #endif +namespace Core { +namespace Utils { + // ------------------ PathValidatingLineEdit class PathValidatingLineEdit : public BaseValidatingLineEdit { @@ -83,6 +85,7 @@ struct PathChooserPrivate { PathChooserPrivate(PathChooser *chooser); + QHBoxLayout *m_hLayout; PathValidatingLineEdit *m_lineEdit; PathChooser::Kind m_acceptingKind; QString m_dialogTitleOverride; @@ -90,6 +93,7 @@ struct PathChooserPrivate }; PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) : + m_hLayout(new QHBoxLayout), m_lineEdit(new PathValidatingLineEdit(chooser)), m_acceptingKind(PathChooser::Directory) { @@ -99,8 +103,8 @@ PathChooser::PathChooser(QWidget *parent) : QWidget(parent), m_d(new PathChooserPrivate(this)) { - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setContentsMargins(0, 0, 0, 0); + + m_d->m_hLayout->setContentsMargins(0, 0, 0, 0); connect(m_d->m_lineEdit, SIGNAL(validReturnPressed()), this, SIGNAL(returnPressed())); connect(m_d->m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); @@ -108,19 +112,12 @@ PathChooser::PathChooser(QWidget *parent) : connect(m_d->m_lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); m_d->m_lineEdit->setMinimumWidth(200); - hLayout->addWidget(m_d->m_lineEdit); - hLayout->setSizeConstraint(QLayout::SetMinimumSize); + m_d->m_hLayout->addWidget(m_d->m_lineEdit); + m_d->m_hLayout->setSizeConstraint(QLayout::SetMinimumSize); -#ifdef Q_OS_MAC - QPushButton *browseButton = new QPushButton; -#else - QToolButton *browseButton = new QToolButton; -#endif - browseButton->setText(tr(browseButtonLabel)); - connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse())); + addButton(tr(browseButtonLabel), this, SLOT(slotBrowse())); - hLayout->addWidget(browseButton); - setLayout(hLayout); + setLayout(m_d->m_hLayout); setFocusProxy(m_d->m_lineEdit); } @@ -129,6 +126,18 @@ PathChooser::~PathChooser() delete m_d; } +void PathChooser::addButton(const QString &text, QObject *receiver, const char *slotFunc) +{ +#ifdef Q_OS_MAC + QPushButton *button = new QPushButton; +#else + QToolButton *button = new QToolButton; +#endif + button->setText(text); + connect(button, SIGNAL(clicked()), receiver, slotFunc); + m_d->m_hLayout->addWidget(button); +} + QString PathChooser::path() const { return m_d->m_lineEdit->text(); diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index 04607ef700a..24c33fe6215 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -82,6 +82,8 @@ public: /** Return the home directory, which needs some fixing under Windows. */ static QString homePath(); + void addButton(const QString &text, QObject *receiver, const char *slotFunc); + private: // Returns overridden title or the one from <title> QString makeDialogTitle(const QString &title); diff --git a/src/plugins/debugger/Debugger.pluginspec b/src/plugins/debugger/Debugger.pluginspec index da8d04450ff..d8e1d86c6cf 100644 --- a/src/plugins/debugger/Debugger.pluginspec +++ b/src/plugins/debugger/Debugger.pluginspec @@ -25,6 +25,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> <dependency name="Find" version="1.1.80"/> </dependencyList> <argumentList> - <argument name="-enable-cdb"/> + <argument name="-disable-cdb">Disable CDB debugger engine</argument> </argumentList> </plugin> diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri index 97932b31026..7e78763dfe5 100644 --- a/src/plugins/debugger/cdb/cdb.pri +++ b/src/plugins/debugger/cdb/cdb.pri @@ -10,6 +10,10 @@ CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk" CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows (x86)/sdk" } +!exists ($$CDB_PATH) { + CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows (x64)/sdk" +} + exists ($$CDB_PATH) { message("Experimental: Adding support for $$CDB_PATH") @@ -31,7 +35,9 @@ HEADERS += \ $$PWD/cdbstacktracecontext.h \ $$PWD/cdbbreakpoint.h \ $$PWD/cdbmodules.h \ - $$PWD/cdbassembler.h + $$PWD/cdbassembler.h \ + $$PWD/cdboptions.h \ + $$PWD/cdboptionspage.h SOURCES += \ $$PWD/cdbdebugengine.cpp \ @@ -41,7 +47,11 @@ SOURCES += \ $$PWD/cdbstacktracecontext.cpp \ $$PWD/cdbbreakpoint.cpp \ $$PWD/cdbmodules.cpp \ - $$PWD/cdbassembler.cpp + $$PWD/cdbassembler.cpp \ + $$PWD/cdboptions.cpp \ + $$PWD/cdboptionspage.cpp + +FORMS += $$PWD/cdboptionspagewidget.ui } else { message("Debugging Tools for Windows could not be found in $$CDB_PATH") diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index a71aa2ac721..d84d08dacfd 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -34,6 +34,8 @@ #include "cdbbreakpoint.h" #include "cdbmodules.h" #include "cdbassembler.h" +#include "cdboptionspage.h" +#include "cdboptions.h" #include "debuggeractions.h" #include "debuggermanager.h" @@ -45,6 +47,7 @@ #include "disassemblerhandler.h" #include "watchutils.h" +#include <coreplugin/icore.h> #include <utils/qtcassert.h> #include <utils/winutils.h> #include <utils/consoleprocess.h> @@ -140,10 +143,15 @@ DebuggerEngineLibrary::DebuggerEngineLibrary() : { } -bool DebuggerEngineLibrary::init(QString *errorMessage) +bool DebuggerEngineLibrary::init(const QString &path, QString *errorMessage) { - // Load - QLibrary lib(QLatin1String(dbgEngineDllC), 0); + // Load from path + QString dllPath = path; + if (!dllPath.isEmpty()) + dllPath += QDir::separator(); + dllPath += QLatin1String(dbgEngineDllC); + + QLibrary lib(dllPath, 0); if (!lib.isLoaded() && !lib.load()) { *errorMessage = CdbDebugEngine::tr("Unable to load the debugger engine library '%1': %2"). @@ -191,7 +199,10 @@ SyntaxSetter::~SyntaxSetter() // --- CdbDebugEnginePrivate -CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *parent, CdbDebugEngine* engine) : +CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *parent, + const QSharedPointer<CdbOptions> &options, + CdbDebugEngine* engine) : + m_options(options), m_hDebuggeeProcess(0), m_hDebuggeeThread(0), m_breakEventMode(BreakEventHandle), @@ -215,7 +226,7 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage) { // Load the DLL DebuggerEngineLibrary lib; - if (!lib.init(errorMessage)) + if (!lib.init(m_options->path, errorMessage)) return false; // Initialize the COM interfaces @@ -259,18 +270,15 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage) return true; } -IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *parent) +IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *parent, + const QSharedPointer<CdbOptions> &options, + QString *errorMessage) { - QString errorMessage; - IDebuggerEngine *rc = 0; - CdbDebugEngine *e = new CdbDebugEngine(parent); - if (e->m_d->init(&errorMessage)) { - rc = e; - } else { - delete e; - qWarning("%s", qPrintable(errorMessage)); - } - return rc; + CdbDebugEngine *rc = new CdbDebugEngine(parent, options); + if (rc->m_d->init(errorMessage)) + return rc; + delete rc; + return 0; } CdbDebugEnginePrivate::~CdbDebugEnginePrivate() @@ -306,9 +314,9 @@ void CdbDebugEnginePrivate::cleanStackTrace() } } -CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent) : +CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent, const QSharedPointer<CdbOptions> &options) : IDebuggerEngine(parent), - m_d(new CdbDebugEnginePrivate(parent, this)) + m_d(new CdbDebugEnginePrivate(parent, options, this)) { // m_d->m_consoleStubProc.setDebug(true); connect(&m_d->m_consoleStubProc, SIGNAL(processError(QString)), this, SLOT(slotConsoleStubError(QString))); @@ -1327,8 +1335,24 @@ void CdbDebugEngine::reloadSourceFiles() } // namespace Debugger // Accessed by DebuggerManager -Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::DebuggerManager *parent) -{ - return Debugger::Internal::CdbDebugEngine::create(parent); +Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::DebuggerManager *parent, + bool cmdLineDisabled, + QList<Core::IOptionsPage*> *opts) +{ + // Create options page + QSharedPointer<Debugger::Internal::CdbOptions> options(new Debugger::Internal::CdbOptions); + options->fromSettings(Core::ICore::instance()->settings()); + Debugger::Internal::CdbOptionsPage *optionsPage = new Debugger::Internal::CdbOptionsPage(options); + opts->push_back(optionsPage); + if (cmdLineDisabled || !options->enabled) + return 0; + // Create engine + QString errorMessage; + Debugger::Internal::IDebuggerEngine *engine = + Debugger::Internal::CdbDebugEngine::create(parent, options, &errorMessage); + if (!engine) { + optionsPage->setFailureMessage(errorMessage); + qWarning("%s", qPrintable(errorMessage)); + } + return engine; } - diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h index fe91fef5df8..35fce47f66f 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.h +++ b/src/plugins/debugger/cdb/cdbdebugengine.h @@ -33,6 +33,8 @@ #include "idebuggerengine.h" #include "debuggermanager.h" +#include <QtCore/QSharedPointer> + namespace Debugger { namespace Internal { @@ -40,18 +42,22 @@ class DebuggerManager; class CdbDebugEventCallback; class CdbDebugOutput; struct CdbDebugEnginePrivate; +struct CdbOptions; class CdbDebugEngine : public IDebuggerEngine { Q_DISABLE_COPY(CdbDebugEngine) Q_OBJECT - explicit CdbDebugEngine(DebuggerManager *parent); + explicit CdbDebugEngine(DebuggerManager *parent, + const QSharedPointer<CdbOptions> &options); public: ~CdbDebugEngine(); // Factory function that returns 0 if the debug engine library cannot be found. - static IDebuggerEngine *create(DebuggerManager *parent); + static IDebuggerEngine *create(DebuggerManager *parent, + const QSharedPointer<CdbOptions> &options, + QString *errorMessage); virtual void shutdown(); virtual void setToolTipExpression(const QPoint &pos, const QString &exp); diff --git a/src/plugins/debugger/cdb/cdbdebugengine_p.h b/src/plugins/debugger/cdb/cdbdebugengine_p.h index ce9c2e381bf..ae4812d7d81 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine_p.h +++ b/src/plugins/debugger/cdb/cdbdebugengine_p.h @@ -32,9 +32,12 @@ #include "cdbdebugeventcallback.h" #include "cdbdebugoutput.h" +#include "cdboptions.h" #include "stackhandler.h" #include "debuggermanager.h" + #include <utils/consoleprocess.h> +#include <QtCore/QSharedPointer> namespace Debugger { namespace Internal { @@ -52,7 +55,7 @@ class DebuggerEngineLibrary { public: DebuggerEngineLibrary(); - bool init(QString *errorMessage); + bool init(const QString &path, QString *errorMessage); inline HRESULT debugCreate(REFIID interfaceId, PVOID *interfaceHandle) const { return m_debugCreate(interfaceId, interfaceHandle); } @@ -72,7 +75,9 @@ struct CdbDebugEnginePrivate BreakEventSyncBreakPoints, }; - explicit CdbDebugEnginePrivate(DebuggerManager *parent, CdbDebugEngine* engine); + explicit CdbDebugEnginePrivate(DebuggerManager *parent, + const QSharedPointer<CdbOptions> &options, + CdbDebugEngine* engine); bool init(QString *errorMessage); ~CdbDebugEnginePrivate(); @@ -98,6 +103,7 @@ struct CdbDebugEnginePrivate bool attemptBreakpointSynchronization(QString *errorMessage); + const QSharedPointer<CdbOptions> m_options; HANDLE m_hDebuggeeProcess; HANDLE m_hDebuggeeThread; int m_currentThreadId; diff --git a/src/plugins/debugger/cdb/cdboptions.cpp b/src/plugins/debugger/cdb/cdboptions.cpp new file mode 100644 index 00000000000..b26053beee8 --- /dev/null +++ b/src/plugins/debugger/cdb/cdboptions.cpp @@ -0,0 +1,113 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + +#include "cdboptions.h" +#include <QtCore/QSettings> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> + +static const char *settingsGroupC = "CDB"; +static const char *enabledKeyC = "enabled"; +static const char *pathKeyC = "path"; + +namespace Debugger { +namespace Internal { + +CdbOptions::CdbOptions() : + enabled(false) +{ +} + +void CdbOptions::clear() +{ + enabled = false; + path.clear(); +} + +void CdbOptions::fromSettings(const QSettings *s) +{ + clear(); + // Is this the first time we are called -> + // try to find automatically + const QString keyRoot = QLatin1String(settingsGroupC) + QLatin1Char('/'); + const QString enabledKey = keyRoot + QLatin1String(enabledKeyC); + const bool firstTime = !s->contains(enabledKey); + if (firstTime) { + enabled = autoDetectPath(&path); + return; + } + enabled = s->value(enabledKey, false).toBool(); + path = s->value(keyRoot + QLatin1String(pathKeyC), QString()).toString(); +} + +void CdbOptions::toSettings(QSettings *s) const +{ + s->beginGroup(QLatin1String(settingsGroupC)); + s->setValue(QLatin1String(enabledKeyC), enabled); + s->setValue(QLatin1String(pathKeyC), path); + s->endGroup(); +} + +bool CdbOptions::autoDetectPath(QString *outPath) +{ + // Look for $ProgramFiles/"Debugging Tools For Windows" and its + // :" (x86)", " (x64)" variations + static const char *postFixes[] = { " (x86)", " (x64)" }; + + outPath->clear(); + const QByteArray programDirB = qgetenv("ProgramFiles"); + if (programDirB.isEmpty()) + return false; + + const QString programDir = QString::fromLocal8Bit(programDirB) + QDir::separator(); + const QString installDir = QLatin1String("Debugging Tools For Windows"); + QString path = programDir + installDir; + if (QFileInfo(path).isDir()) { + *outPath = QDir::toNativeSeparators(path); + return true; + } + const int rootLength = path.size(); + for (int i = 0; i < sizeof(postFixes)/sizeof(const char*); i++) { + path.truncate(rootLength); + path += QLatin1String(postFixes[i]); + if (QFileInfo(path).isDir()) { + *outPath = QDir::toNativeSeparators(path); + return true; + } + } + return false; +} + +bool CdbOptions::equals(const CdbOptions &rhs) const +{ + return enabled == rhs.enabled && path == rhs.path; +} + +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/cdb/cdboptions.h b/src/plugins/debugger/cdb/cdboptions.h new file mode 100644 index 00000000000..f9853008e86 --- /dev/null +++ b/src/plugins/debugger/cdb/cdboptions.h @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + +#ifndef CDBSETTINGS_H +#define CDBSETTINGS_H + +#include <QtCore/QString> + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace Debugger { +namespace Internal { + +struct CdbOptions +{ +public: + CdbOptions(); + void clear(); + + void fromSettings(const QSettings *s); + void toSettings(QSettings *s) const; + + bool equals(const CdbOptions &s) const; + + // Locate the debugging tools + static bool autoDetectPath(QString *path); + + bool enabled; + QString path; +}; + +inline bool operator==(const CdbOptions &s1, const CdbOptions &s2) +{ return s1.equals(s2); } +inline bool operator!=(const CdbOptions &s1, const CdbOptions &s2) +{ return !s1.equals(s2); } + +} // namespace Internal +} // namespace Debugger + +#endif // CDBSETTINGS_H diff --git a/src/plugins/debugger/cdb/cdboptionspage.cpp b/src/plugins/debugger/cdb/cdboptionspage.cpp new file mode 100644 index 00000000000..c57149cf09f --- /dev/null +++ b/src/plugins/debugger/cdb/cdboptionspage.cpp @@ -0,0 +1,135 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + +#include "cdboptionspage.h" +#include "cdboptions.h" +#include "debuggerconstants.h" + +#include <coreplugin/icore.h> +#include <QtCore/QCoreApplication> + +const char * const CDB_SETTINGS_ID = QT_TRANSLATE_NOOP("Debugger::Internal::CdbOptionsPageWidget", "CDB"); + +namespace Debugger { +namespace Internal { + +CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) : + QWidget(parent) +{ + m_ui.setupUi(this); + m_ui.pathChooser->setExpectedKind(Core::Utils::PathChooser::Directory); + m_ui.pathChooser->addButton(tr("Autodetect"), this, SLOT(autoDetect())); + m_ui.failureLabel->setVisible(false); +} + + +void CdbOptionsPageWidget::setOptions(CdbOptions &o) +{ + m_ui.pathChooser->setPath(o.path); + m_ui.cdbOptionsGroupBox->setChecked(o.enabled); +} + +CdbOptions CdbOptionsPageWidget::options() const +{ + CdbOptions rc; + rc.path = m_ui.pathChooser->path(); + rc.enabled = m_ui.cdbOptionsGroupBox->isChecked(); + return rc; +} + +void CdbOptionsPageWidget::autoDetect() +{ + QString path; + const bool ok = CdbOptions::autoDetectPath(&path); + m_ui.cdbOptionsGroupBox->setChecked(ok); + if (ok) + m_ui.pathChooser->setPath(path); +} + +void CdbOptionsPageWidget::setFailureMessage(const QString &msg) +{ + m_ui.failureLabel->setText(msg); + m_ui.failureLabel->setVisible(!msg.isEmpty()); +} + +// ---------- CdbOptionsPage +CdbOptionsPage::CdbOptionsPage(const QSharedPointer<CdbOptions> &options) : + m_options(options) +{ +} + +CdbOptionsPage::~CdbOptionsPage() +{ +} + +QString CdbOptionsPage::settingsId() +{ + return QLatin1String(CDB_SETTINGS_ID); +} + +QString CdbOptionsPage::trName() const +{ + return tr(CDB_SETTINGS_ID); +} + +QString CdbOptionsPage::category() const +{ + return QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); +} + +QString CdbOptionsPage::trCategory() const +{ + return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); +} + +QWidget *CdbOptionsPage::createPage(QWidget *parent) +{ + m_widget = new CdbOptionsPageWidget(parent); + m_widget->setOptions(*m_options); + m_widget->setFailureMessage(m_failureMessage); + return m_widget; +} + +void CdbOptionsPage::apply() +{ + if (!m_widget) + return; + const CdbOptions newOptions = m_widget->options(); + if (newOptions != *m_options) { + *m_options = newOptions; + m_options->toSettings(Core::ICore::instance()->settings()); + } +} + +void CdbOptionsPage::finish() +{ +} + +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/cdb/cdboptionspage.h b/src/plugins/debugger/cdb/cdboptionspage.h new file mode 100644 index 00000000000..ed92ced6c23 --- /dev/null +++ b/src/plugins/debugger/cdb/cdboptionspage.h @@ -0,0 +1,95 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + +#ifndef CDBSETTINGSPAGE_H +#define CDBSETTINGSPAGE_H + +#include <coreplugin/dialogs/ioptionspage.h> +#include "ui_cdboptionspagewidget.h" + +#include <QtGui/QWidget> +#include <QtCore/QPointer> +#include <QtCore/QSharedPointer> + +namespace Debugger { +namespace Internal { + +struct CdbOptions; + +class CdbOptionsPageWidget : public QWidget +{ + Q_OBJECT +public: + explicit CdbOptionsPageWidget(QWidget *parent); + + void setOptions(CdbOptions &o); + CdbOptions options() const; + + void setFailureMessage(const QString &); + +private slots: + void autoDetect(); + +private: + Ui::CdbOptionsPageWidget m_ui; +}; + +class CdbOptionsPage : public Core::IOptionsPage +{ + Q_DISABLE_COPY(CdbOptionsPage) + Q_OBJECT +public: + explicit CdbOptionsPage(const QSharedPointer<CdbOptions> &options); + virtual ~CdbOptionsPage(); + + // IOptionsPage + virtual QString id() const { return settingsId(); } + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + + static QString settingsId(); + + // Load failure messages can be displayed here + void setFailureMessage(const QString &msg) { m_failureMessage = msg; } + +private: + const QSharedPointer<CdbOptions> m_options; + QPointer<CdbOptionsPageWidget> m_widget; + QString m_failureMessage; +}; + +} // namespace Internal +} // namespace Debugger + +#endif // CDBSETTINGSPAGE_H diff --git a/src/plugins/debugger/cdb/cdboptionspagewidget.ui b/src/plugins/debugger/cdb/cdboptionspagewidget.ui new file mode 100644 index 00000000000..9afbb318321 --- /dev/null +++ b/src/plugins/debugger/cdb/cdboptionspagewidget.ui @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CdbOptionsPageWidget</class> + <widget class="QWidget" name="CdbOptionsPageWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>369</width> + <height>281</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGroupBox" name="cdbOptionsGroupBox"> + <property name="title"> + <string>CDB</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Path to "Debugging Tools for Windows":</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>223</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="failureLabel"> + <property name="styleSheet"> + <string notr="true">background-color: 'red';</string> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>Core::Utils::PathChooser</class> + <extends>QWidget</extends> + <header location="global">utils/pathchooser.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/debugger/commonoptionspage.ui b/src/plugins/debugger/commonoptionspage.ui new file mode 100644 index 00000000000..53751824b31 --- /dev/null +++ b/src/plugins/debugger/commonoptionspage.ui @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CommonOptionsPage</class> + <widget class="QWidget" name="CommonOptionsPage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>429</width> + <height>452</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>User interface</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="checkBoxListSourceFiles"> + <property name="toolTip"> + <string>Checking this will populate the source file view automatically but might slow down debugger startup considerably.</string> + </property> + <property name="text"> + <string>Populate source file view automatically</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxSkipKnownFrames"> + <property name="toolTip"> + <string>When this option is checked, 'Step Into' compresses several steps into one in certain situations, leading to 'less noisy' debugging. So will, e.g., the atomic + reference counting code be skipped, and a single 'Step Into' for a signal emission will end up directly in the slot connected to it.</string> + </property> + <property name="text"> + <string>Skip known frames when stepping</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxUseToolTips"> + <property name="toolTip"> + <string>Checking this will make enable tooltips for variable values during debugging. Since this can slow down debugging and does not provide reliable information as it does not use scope information, it is switched off by default.</string> + </property> + <property name="text"> + <string>Use tooltips while debugging</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="labelMaximalStackDepth"> + <property name="text"> + <string>Maximal stack depth:</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxMaximalStackDepth"> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="frame"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="specialValueText"> + <string><unlimited></string> + </property> + <property name="maximum"> + <number>999</number> + </property> + <property name="singleStep"> + <number>5</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 13b367dd7ec..8d0cb9ddbdd 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -43,7 +43,8 @@ HEADERS += \ sourcefileswindow.h \ threadswindow.h \ watchhandler.h \ - watchwindow.h + watchwindow.h \ + gdboptionspage.h SOURCES += \ breakhandler.cpp \ @@ -72,7 +73,8 @@ SOURCES += \ sourcefileswindow.cpp \ threadswindow.cpp \ watchhandler.cpp \ - watchwindow.cpp + watchwindow.cpp \ + gdboptionspage.cpp FORMS += attachexternaldialog.ui \ attachremotedialog.ui \ @@ -80,7 +82,8 @@ FORMS += attachexternaldialog.ui \ breakbyfunction.ui \ breakcondition.ui \ dumperoptionpage.ui \ - gdboptionpage.ui \ + gdboptionspage.ui \ + commonoptionspage.ui \ startexternaldialog.ui \ RESOURCES += debugger.qrc diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index a17d1bb060c..f4e2ae6e04c 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -30,6 +30,8 @@ #ifndef DEBUGGERCONSTANTS_H #define DEBUGGERCONSTANTS_H +#include <QtCore/QtGlobal> + namespace Debugger { namespace Constants { @@ -51,6 +53,8 @@ const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug"; const char * const C_GDBDEBUGGER = "Gdb Debugger"; const char * const GDBRUNNING = "Gdb.Running"; +const char * const DEBUGGER_SETTINGS_CATEGORY = QT_TRANSLATE_NOOP("Debugger", "Debugger"); + namespace Internal { enum { debug = 0 }; } diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index fc5f3371f57..6c6bb90ea0b 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -139,18 +139,21 @@ static IDebuggerEngine *gdbEngine = 0; static IDebuggerEngine *winEngine = 0; static IDebuggerEngine *scriptEngine = 0; -extern IDebuggerEngine *createGdbEngine(DebuggerManager *parent); -extern IDebuggerEngine *createWinEngine(DebuggerManager *) +// The creation functions take a list of options pages they can add to. +// This allows for having a "enabled" toggle on the page indepently +// of the engine. +extern IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *); +extern IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineDisabled */, QList<Core::IOptionsPage*> *) #ifdef CDB_ENABLED ; #else { return 0; } #endif -extern IDebuggerEngine *createScriptEngine(DebuggerManager *parent); +extern IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *); -DebuggerManager::DebuggerManager(const QStringList &arguments) +DebuggerManager::DebuggerManager() { - init(arguments); + init(); } DebuggerManager::~DebuggerManager() @@ -160,7 +163,7 @@ DebuggerManager::~DebuggerManager() delete scriptEngine; } -void DebuggerManager::init(const QStringList &arguments) +void DebuggerManager::init() { m_status = -1; m_busy = false; @@ -426,13 +429,19 @@ void DebuggerManager::init(const QStringList &arguments) m_threadsDock = createDockForWidget(m_threadsWindow); setStatus(DebuggerProcessNotReady); - gdbEngine = createGdbEngine(this); - if (arguments.contains(QLatin1String("-enable-cdb"))) - winEngine = createWinEngine(this); - scriptEngine = createScriptEngine(this); +} + +QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(const QStringList &arguments) +{ + QList<Core::IOptionsPage*> rc; + gdbEngine = createGdbEngine(this, &rc); + const bool cdbDisabled = arguments.contains(QLatin1String("-disable-cdb")); + winEngine = createWinEngine(this, cdbDisabled, &rc); + scriptEngine = createScriptEngine(this, &rc); setDebuggerType(GdbDebugger); if (Debugger::Constants::Internal::debug) - qDebug() << Q_FUNC_INFO << gdbEngine << winEngine << scriptEngine; + qDebug() << Q_FUNC_INFO << gdbEngine << winEngine << scriptEngine << rc.size(); + return rc; } void DebuggerManager::setDebuggerType(DebuggerType type) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index b6cf4b78f40..4062be169dc 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -48,6 +48,10 @@ class QTimer; class QWidget; QT_END_NAMESPACE +namespace Core { + class IOptionsPage; +} + namespace Debugger { namespace Internal { @@ -178,7 +182,9 @@ class DebuggerManager : public QObject, Q_OBJECT public: - DebuggerManager(const QStringList &arguments); + DebuggerManager(); + QList<Core::IOptionsPage*> initializeEngines(const QStringList &arguments); + ~DebuggerManager(); IDebuggerManagerAccessForEngines *engineInterface(); @@ -341,7 +347,7 @@ public: bool m_useTerminal; private: - void init(const QStringList &arguments); + void init(); void setDebuggerType(DebuggerType type); void runTest(const QString &fileName); QDockWidget *createDockForWidget(QWidget *widget); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 4d88db88c3a..de6c264b2f2 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -35,7 +35,7 @@ #include "debuggerrunner.h" #include "gdbengine.h" -#include "ui_gdboptionpage.h" +#include "ui_commonoptionspage.h" #include "ui_dumperoptionpage.h" #include <coreplugin/actionmanager/actionmanager.h> @@ -75,6 +75,7 @@ #include <QtCore/QPoint> #include <QtCore/QSettings> #include <QtCore/QtPlugin> +#include <QtCore/QCoreApplication> #include <QtGui/QLineEdit> #include <QtGui/QDockWidget> @@ -230,62 +231,40 @@ QIcon LocationMark::icon() const /////////////////////////////////////////////////////////////////////// // -// GdbOptionPage +// CommonOptionsPage // /////////////////////////////////////////////////////////////////////// namespace Debugger { namespace Internal { -class GdbOptionPage : public Core::IOptionsPage +class CommonOptionsPage : public Core::IOptionsPage { Q_OBJECT public: - GdbOptionPage() {} + CommonOptionsPage() {} // IOptionsPage - QString id() const { return QLatin1String("General"); } - QString trName() const { return tr("General"); } - QString category() const { return QLatin1String("Debugger"); } - QString trCategory() const { return tr("Debugger"); } + QString id() const { return QLatin1String("Common"); } + QString trName() const { return tr("Common"); } + QString category() const { return QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); } + QString trCategory() const { return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); } QWidget *createPage(QWidget *parent); void apply() { m_group.apply(ICore::instance()->settings()); } void finish() { m_group.finish(); } private: - friend class DebuggerPlugin; - Ui::GdbOptionPage m_ui; - + Ui::CommonOptionsPage m_ui; Core::Utils::SavedActionSet m_group; }; -QWidget *GdbOptionPage::createPage(QWidget *parent) +QWidget *CommonOptionsPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); m_ui.setupUi(w); - m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command); - m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location")); - m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File); - m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); - m_group.clear(); - m_group.insert(theDebuggerAction(GdbLocation), - m_ui.gdbLocationChooser); - m_group.insert(theDebuggerAction(GdbScriptFile), - m_ui.scriptFileChooser); - m_group.insert(theDebuggerAction(GdbEnvironment), - m_ui.environmentEdit); - - m_group.insert(theDebuggerAction(AllPluginBreakpoints), - m_ui.radioButtonAllPluginBreakpoints); - m_group.insert(theDebuggerAction(SelectedPluginBreakpoints), - m_ui.radioButtonSelectedPluginBreakpoints); - m_group.insert(theDebuggerAction(NoPluginBreakpoints), - m_ui.radioButtonNoPluginBreakpoints); - m_group.insert(theDebuggerAction(SelectedPluginBreakpointsPattern), - m_ui.lineEditSelectedPluginBreakpointsPattern); m_group.insert(theDebuggerAction(ListSourceFiles), m_ui.checkBoxListSourceFiles); @@ -296,18 +275,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_group.insert(theDebuggerAction(MaximalStackDepth), m_ui.spinBoxMaximalStackDepth); - m_ui.lineEditSelectedPluginBreakpointsPattern-> - setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); - connect(m_ui.radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)), - m_ui.lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool))); - - // FIXME - m_ui.environmentEdit->hide(); - m_ui.labelEnvironment->hide(); - - //m_dumpLogAction = new QAction(this); - //m_dumpLogAction->setText(tr("Dump Log File for Debugging Purposes")); - return w; } @@ -334,8 +301,8 @@ public: // IOptionsPage QString id() const { return QLatin1String("DebuggingHelper"); } QString trName() const { return tr("Debugging Helper"); } - QString category() const { return QLatin1String("Debugger"); } - QString trCategory() const { return tr("Debugger"); } + QString category() const { return QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); } + QString trCategory() const { return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); } QWidget *createPage(QWidget *parent); void apply() { m_group.apply(ICore::instance()->settings()); } @@ -404,20 +371,21 @@ void DebuggingHelperOptionPage::updateState() } // namespace Internal } // namespace Debugger - /////////////////////////////////////////////////////////////////////// // // DebuggerPlugin // /////////////////////////////////////////////////////////////////////// -DebuggerPlugin::DebuggerPlugin() -{ - m_generalOptionPage = 0; - m_dumperOptionPage = 0; - m_locationMark = 0; - m_manager = 0; - m_debugMode = 0; +DebuggerPlugin::DebuggerPlugin() : + m_manager(0), + m_debugMode(0), + m_locationMark(0), + m_gdbRunningContext(0), + m_breakpointMarginAction(0), + m_toggleLockedAction(0), + m_breakpointMarginActionLineNumber(0) +{ } DebuggerPlugin::~DebuggerPlugin() @@ -440,20 +408,12 @@ void DebuggerPlugin::shutdown() //qDebug() << "DebuggerPlugin::~DebuggerPlugin"; removeObject(m_debugMode); - removeObject(m_generalOptionPage); - removeObject(m_dumperOptionPage); // FIXME: when using the line below, BreakWindow etc gets deleted twice. // so better leak for now... delete m_debugMode; m_debugMode = 0; - delete m_generalOptionPage; - m_generalOptionPage = 0; - - delete m_dumperOptionPage; - m_dumperOptionPage = 0; - delete m_locationMark; m_locationMark = 0; @@ -466,7 +426,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess Q_UNUSED(arguments); Q_UNUSED(errorMessage); - m_manager = new DebuggerManager(arguments); + m_manager = new DebuggerManager; + const QList<Core::IOptionsPage *> engineOptionPages = m_manager->initializeEngines(arguments); ICore *core = ICore::instance(); QTC_ASSERT(core, return false); @@ -660,10 +621,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess m_manager, SLOT(reloadRegisters())); // FIXME: - m_generalOptionPage = new GdbOptionPage; - addObject(m_generalOptionPage); - m_dumperOptionPage = new DebuggingHelperOptionPage; - addObject(m_dumperOptionPage); + addAutoReleasedObject(new CommonOptionsPage); + addAutoReleasedObject(new DebuggingHelperOptionPage); + foreach (Core::IOptionsPage* op, engineOptionPages) + addAutoReleasedObject(op); m_locationMark = 0; diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index 286ee5aa8bc..5b0e631ddb1 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -56,8 +56,6 @@ namespace Internal { class DebuggerManager; class DebugMode; -class GdbOptionPage; -class DebuggingHelperOptionPage; class LocationMark; class DebuggerPlugin : public ExtensionSystem::IPlugin @@ -108,9 +106,6 @@ private: DebuggerManager *m_manager; DebugMode *m_debugMode; - GdbOptionPage *m_generalOptionPage; - DebuggingHelperOptionPage *m_dumperOptionPage; - QString m_previousMode; LocationMark *m_locationMark; int m_gdbRunningContext; diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 0e161f10795..c4cbbc4cf71 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "gdbengine.h" +#include "gdboptionspage.h" #include "watchutils.h" #include "debuggeractions.h" @@ -4197,7 +4198,8 @@ void GdbEngine::recheckDebuggingHelperAvailability() sendCommand("p (char*)qDumpOutBuffer", GdbQueryDebuggingHelper); } -IDebuggerEngine *createGdbEngine(DebuggerManager *parent) +IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *opts) { + opts->push_back(new GdbOptionsPage); return new GdbEngine(parent); } diff --git a/src/plugins/debugger/gdboptionspage.cpp b/src/plugins/debugger/gdboptionspage.cpp new file mode 100644 index 00000000000..b3a42810926 --- /dev/null +++ b/src/plugins/debugger/gdboptionspage.cpp @@ -0,0 +1,85 @@ +#include "gdboptionspage.h" +#include "debuggeractions.h" +#include "debuggerconstants.h" + +#include <coreplugin/icore.h> +#include <QtCore/QCoreApplication> + +const char * const GDB_SETTINGS_ID = QT_TRANSLATE_NOOP("Debugger::Internal::GdbOptionsPage", "Gdb"); + +namespace Debugger { +namespace Internal { + +GdbOptionsPage::GdbOptionsPage() +{ +} + +QString GdbOptionsPage::settingsId() +{ + return QLatin1String(GDB_SETTINGS_ID); +} + +QString GdbOptionsPage::trName() const +{ + return tr(GDB_SETTINGS_ID); +} + +QString GdbOptionsPage::category() const +{ + return QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); +} + +QString GdbOptionsPage::trCategory() const +{ + return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY); +} + +QWidget *GdbOptionsPage::createPage(QWidget *parent) +{ + QWidget *w = new QWidget(parent); + m_ui.setupUi(w); + m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command); + m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location")); + m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File); + m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); + + m_group.clear(); + m_group.insert(theDebuggerAction(GdbLocation), + m_ui.gdbLocationChooser); + m_group.insert(theDebuggerAction(GdbScriptFile), + m_ui.scriptFileChooser); + m_group.insert(theDebuggerAction(GdbEnvironment), + m_ui.environmentEdit); + + m_group.insert(theDebuggerAction(AllPluginBreakpoints), + m_ui.radioButtonAllPluginBreakpoints); + m_group.insert(theDebuggerAction(SelectedPluginBreakpoints), + m_ui.radioButtonSelectedPluginBreakpoints); + m_group.insert(theDebuggerAction(NoPluginBreakpoints), + m_ui.radioButtonNoPluginBreakpoints); + m_group.insert(theDebuggerAction(SelectedPluginBreakpointsPattern), + m_ui.lineEditSelectedPluginBreakpointsPattern); + + m_ui.lineEditSelectedPluginBreakpointsPattern-> + setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); + connect(m_ui.radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)), + m_ui.lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool))); + + // FIXME + m_ui.environmentEdit->hide(); + m_ui.labelEnvironment->hide(); + + return w; +} +void GdbOptionsPage::apply() +{ + m_group.apply(Core::ICore::instance()->settings()); +} + +void GdbOptionsPage::finish() +{ + m_group.finish(); +} + +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/gdboptionspage.h b/src/plugins/debugger/gdboptionspage.h new file mode 100644 index 00000000000..bd70ed68ec6 --- /dev/null +++ b/src/plugins/debugger/gdboptionspage.h @@ -0,0 +1,37 @@ +#ifndef GDBOPTIONSPAGE_H +#define GDBOPTIONSPAGE_H + +#include <coreplugin/dialogs/ioptionspage.h> +#include <utils/savedaction.h> + +#include "ui_gdboptionspage.h" + +namespace Debugger { +namespace Internal { + +class GdbOptionsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + GdbOptionsPage(); + + virtual QString id() const { return settingsId(); } + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + + static QString settingsId(); + +private: + Ui::GdbOptionsPage m_ui; + Core::Utils::SavedActionSet m_group; +}; + +} // namespace Internal +} // namespace Debugger + +#endif // GDBOPTIONSPAGE_H diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionspage.ui similarity index 61% rename from src/plugins/debugger/gdboptionpage.ui rename to src/plugins/debugger/gdboptionspage.ui index baf91e4667d..5abd9866daf 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionspage.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>GdbOptionPage</class> - <widget class="QWidget" name="GdbOptionPage"> + <class>GdbOptionsPage</class> + <widget class="QWidget" name="GdbOptionsPage"> <property name="geometry"> <rect> <x>0</x> @@ -13,7 +13,7 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QGroupBox" name="groupBoxLocations"> <property name="title"> @@ -131,82 +131,6 @@ </layout> </widget> </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>User interface</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="checkBoxListSourceFiles"> - <property name="toolTip"> - <string>Checking this will populate the source file view automatically but might slow down debugger startup considerably.</string> - </property> - <property name="text"> - <string>Populate source file view automatically</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxSkipKnownFrames"> - <property name="toolTip"> - <string>When this option is checked, 'Step Into' compresses several steps into one in certain situations, leading to 'less noisy' debugging. So will, e.g., the atomic - reference counting code be skipped, and a single 'Step Into' for a signal emission will end up directly in the slot connected to it.</string> - </property> - <property name="text"> - <string>Skip known frames when stepping</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxUseToolTips"> - <property name="toolTip"> - <string>Checking this will make enable tooltips for variable values during debugging. Since this can slow down debugging and does not provide reliable information as it does not use scope information, it is switched off by default.</string> - </property> - <property name="text"> - <string>Use tooltips while debugging</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="labelMaximalStackDepth"> - <property name="text"> - <string>Maximal stack depth:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBoxMaximalStackDepth"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="frame"> - <bool>false</bool> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="specialValueText"> - <string><unlimited></string> - </property> - <property name="maximum"> - <number>999</number> - </property> - <property name="singleStep"> - <number>5</number> - </property> - <property name="value"> - <number>10</number> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> diff --git a/src/plugins/debugger/scriptengine.cpp b/src/plugins/debugger/scriptengine.cpp index 4ab74e2154a..6bd86e826af 100644 --- a/src/plugins/debugger/scriptengine.cpp +++ b/src/plugins/debugger/scriptengine.cpp @@ -740,7 +740,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0) QTC_ASSERT(false, return); } -IDebuggerEngine *createScriptEngine(DebuggerManager *parent) +IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *) { return new ScriptEngine(parent); } -- GitLab