Debugger: Compactify gdb option page creation

Change-Id: I341a84795f3e4dda67d966da9cb5476f50a680dd
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-06-10 14:52:38 +02:00
parent 77a9b6d875
commit ebb62804f3
5 changed files with 57 additions and 128 deletions

View File

@@ -108,7 +108,7 @@ QtcPlugin {
"attachgdbadapter.cpp", "attachgdbadapter.h",
"coregdbadapter.cpp", "coregdbadapter.h",
"gdbengine.cpp", "gdbengine.h",
"gdboptionspage.cpp", "gdboptionspage.h",
"gdboptionspage.cpp",
"gdbplainengine.cpp", "gdbplainengine.h",
"remotegdbserveradapter.cpp", "remotegdbserveradapter.h",
"startgdbserverdialog.cpp", "startgdbserverdialog.h",

View File

@@ -1,6 +1,5 @@
HEADERS += \
$$PWD/gdbengine.h \
$$PWD/gdboptionspage.h \
$$PWD/attachgdbadapter.h \
$$PWD/coregdbadapter.h \
$$PWD/termgdbadapter.h \

View File

@@ -35,7 +35,6 @@
#include "gdbplainengine.h"
#include "termgdbadapter.h"
#include "remotegdbserveradapter.h"
#include "gdboptionspage.h"
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerinternalconstants.h>
@@ -4658,12 +4657,6 @@ DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp)
}
}
void addGdbOptionPages(QList<IOptionsPage *> *opts)
{
opts->push_back(new GdbOptionsPage());
opts->push_back(new GdbOptionsPage2());
}
void GdbEngine::doUpdateLocals(const UpdateParameters &params)
{
m_pendingBreakpointRequests = 0;

View File

@@ -28,12 +28,12 @@
**
****************************************************************************/
#include "gdboptionspage.h"
#include <debugger/commonoptionspage.h>
#include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h>
#include <debugger/debuggerinternalconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h>
#include <coreplugin/variablechooser.h>
@@ -46,16 +46,15 @@
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPointer>
#include <QSpinBox>
#include <QTextEdit>
using namespace Core;
namespace Debugger {
namespace Internal {
/////////////////////////////////////////////////////////////////////////
//
// GdbOptionsPageWidget - harmless options
@@ -65,12 +64,24 @@ namespace Internal {
class GdbOptionsPageWidget : public QWidget
{
public:
explicit GdbOptionsPageWidget(QWidget *parent = 0);
GdbOptionsPageWidget();
Utils::SavedActionSet group;
};
GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
: QWidget(parent)
class GdbOptionsPage : public Core::IOptionsPage
{
public:
GdbOptionsPage();
QWidget *widget();
void apply();
void finish();
private:
QPointer<GdbOptionsPageWidget> m_widget;
};
GdbOptionsPageWidget::GdbOptionsPageWidget()
{
auto groupBoxGeneral = new QGroupBox(this);
groupBoxGeneral->setTitle(GdbOptionsPage::tr("General"));
@@ -297,10 +308,6 @@ GdbOptionsPage::GdbOptionsPage()
setCategoryIcon(QLatin1String(Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
}
GdbOptionsPage::~GdbOptionsPage()
{
}
QWidget *GdbOptionsPage::widget()
{
if (!m_widget)
@@ -331,29 +338,17 @@ void GdbOptionsPage::finish()
class GdbOptionsPageWidget2 : public QWidget
{
public:
explicit GdbOptionsPageWidget2(QWidget *parent = 0);
QGroupBox *groupBoxDangerous;
QLabel *labelDangerous;
QCheckBox *checkBoxTargetAsync;
QCheckBox *checkBoxAutoEnrichParameters;
QCheckBox *checkBoxBreakOnWarning;
QCheckBox *checkBoxBreakOnFatal;
QCheckBox *checkBoxBreakOnAbort;
QCheckBox *checkBoxEnableReverseDebugging;
QCheckBox *checkBoxAttemptQuickStart;
QCheckBox *checkBoxMultiInferior;
GdbOptionsPageWidget2();
Utils::SavedActionSet group;
};
GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
: QWidget(parent)
GdbOptionsPageWidget2::GdbOptionsPageWidget2()
{
groupBoxDangerous = new QGroupBox(this);
auto groupBoxDangerous = new QGroupBox(this);
groupBoxDangerous->setTitle(GdbOptionsPage::tr("Extended"));
labelDangerous = new QLabel(GdbOptionsPage::tr(
auto labelDangerous = new QLabel(GdbOptionsPage::tr(
"The options below should be used with care."));
labelDangerous->setToolTip(GdbOptionsPage::tr(
"<html><head/><body>The options below give access to advanced "
@@ -363,11 +358,11 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
f.setItalic(true);
labelDangerous->setFont(f);
checkBoxTargetAsync = new QCheckBox(groupBoxDangerous);
auto checkBoxTargetAsync = new QCheckBox(groupBoxDangerous);
checkBoxTargetAsync->setText(GdbOptionsPage::tr(
"Use asynchronous mode to control the inferior"));
checkBoxAutoEnrichParameters = new QCheckBox(groupBoxDangerous);
auto checkBoxAutoEnrichParameters = new QCheckBox(groupBoxDangerous);
checkBoxAutoEnrichParameters->setText(GdbOptionsPage::tr(
"Use common locations for debug information"));
checkBoxAutoEnrichParameters->setToolTip(GdbOptionsPage::tr(
@@ -375,19 +370,20 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
"of debug information such as <i>/usr/src/debug</i> "
"when starting GDB.</body></html>"));
// #fixme: 2.7 Move to common settings page.
checkBoxBreakOnWarning = new QCheckBox(groupBoxDangerous);
// FIXME: Move to common settings page.
auto checkBoxBreakOnWarning = new QCheckBox(groupBoxDangerous);
checkBoxBreakOnWarning->setText(CommonOptionsPage::msgSetBreakpointAtFunction("qWarning"));
checkBoxBreakOnWarning->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("qWarning"));
checkBoxBreakOnFatal = new QCheckBox(groupBoxDangerous);
auto checkBoxBreakOnFatal = new QCheckBox(groupBoxDangerous);
checkBoxBreakOnFatal->setText(CommonOptionsPage::msgSetBreakpointAtFunction("qFatal"));
checkBoxBreakOnFatal->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("qFatal"));
checkBoxBreakOnAbort = new QCheckBox(groupBoxDangerous);
auto checkBoxBreakOnAbort = new QCheckBox(groupBoxDangerous);
checkBoxBreakOnAbort->setText(CommonOptionsPage::msgSetBreakpointAtFunction("abort"));
checkBoxBreakOnAbort->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("abort"));
QCheckBox *checkBoxEnableReverseDebugging = 0;
if (isReverseDebuggingEnabled()) {
checkBoxEnableReverseDebugging = new QCheckBox(groupBoxDangerous);
checkBoxEnableReverseDebugging->setText(GdbOptionsPage::tr("Enable reverse debugging"));
@@ -398,33 +394,33 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
"calls and is very likely to destroy your debugging session.</p></body></html>"));
}
checkBoxAttemptQuickStart = new QCheckBox(groupBoxDangerous);
auto checkBoxAttemptQuickStart = new QCheckBox(groupBoxDangerous);
checkBoxAttemptQuickStart->setText(GdbOptionsPage::tr("Attempt quick start"));
checkBoxAttemptQuickStart->setToolTip(GdbOptionsPage::tr(
"<html><head/><body>Postpones reading debug information as long as possible. "
"This can result in faster startup times at the price of not being able to "
"set breakpoints by file and number.</body></html>"));
checkBoxMultiInferior = new QCheckBox(groupBoxDangerous);
auto checkBoxMultiInferior = new QCheckBox(groupBoxDangerous);
checkBoxMultiInferior->setText(GdbOptionsPage::tr("Debug all children"));
checkBoxMultiInferior->setToolTip(GdbOptionsPage::tr(
"<html><head/><body>Keeps debugging all children after a fork."
"</body></html>"));
QFormLayout *formLayout = new QFormLayout(groupBoxDangerous);
auto formLayout = new QFormLayout(groupBoxDangerous);
formLayout->addRow(labelDangerous);
formLayout->addRow(checkBoxTargetAsync);
formLayout->addRow(checkBoxAutoEnrichParameters);
formLayout->addRow(checkBoxBreakOnWarning);
formLayout->addRow(checkBoxBreakOnFatal);
formLayout->addRow(checkBoxBreakOnAbort);
if (isReverseDebuggingEnabled())
if (checkBoxEnableReverseDebugging)
formLayout->addRow(checkBoxEnableReverseDebugging);
formLayout->addRow(checkBoxAttemptQuickStart);
formLayout->addRow(checkBoxMultiInferior);
QGridLayout *gridLayout = new QGridLayout(this);
auto gridLayout = new QGridLayout(this);
gridLayout->addWidget(groupBoxDangerous, 0, 0, 2, 1);
group.insert(action(AutoEnrichParameters), checkBoxAutoEnrichParameters);
@@ -434,10 +430,24 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
group.insert(action(BreakOnAbort), checkBoxBreakOnAbort);
group.insert(action(AttemptQuickStart), checkBoxAttemptQuickStart);
group.insert(action(MultiInferior), checkBoxMultiInferior);
if (isReverseDebuggingEnabled())
if (checkBoxEnableReverseDebugging)
group.insert(action(EnableReverseDebugging), checkBoxEnableReverseDebugging);
}
// The "Dangerous" options.
class GdbOptionsPage2 : public Core::IOptionsPage
{
public:
GdbOptionsPage2();
QWidget *widget();
void apply();
void finish();
private:
QPointer<GdbOptionsPageWidget2> m_widget;
};
GdbOptionsPage2::GdbOptionsPage2()
{
setId("M.Gdb2");
@@ -447,10 +457,6 @@ GdbOptionsPage2::GdbOptionsPage2()
setCategoryIcon(QLatin1String(Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
}
GdbOptionsPage2::~GdbOptionsPage2()
{
}
QWidget *GdbOptionsPage2::widget()
{
if (!m_widget)
@@ -472,5 +478,13 @@ void GdbOptionsPage2::finish()
}
}
// Registration
void addGdbOptionPages(QList<IOptionsPage *> *opts)
{
opts->push_back(new GdbOptionsPage);
opts->push_back(new GdbOptionsPage2);
}
} // namespace Internal
} // namespace Debugger

View File

@@ -1,77 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef GDBOPTIONSPAGE_H
#define GDBOPTIONSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
namespace Debugger {
namespace Internal {
class GdbOptionsPageWidget;
class GdbOptionsPageWidget2;
class GdbOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
GdbOptionsPage();
~GdbOptionsPage();
QWidget *widget();
void apply();
void finish();
private:
QPointer<GdbOptionsPageWidget> m_widget;
};
// The "Dangerous" options.
class GdbOptionsPage2 : public Core::IOptionsPage
{
Q_OBJECT
public:
GdbOptionsPage2();
~GdbOptionsPage2();
QWidget *widget();
void apply();
void finish();
private:
QPointer<GdbOptionsPageWidget2> m_widget;
};
} // namespace Internal
} // namespace Debugger
#endif // GDBOPTIONSPAGE_H