Debugger: Consolidate RunControl creation

Export factory, de-export plugin, to remove one indirection

Change-Id: I13a46460d07d5ded6b26f2b5ceccd01142fb10e8
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-10-17 13:40:04 +02:00
parent ca9ed45016
commit 55b2bb16dc
28 changed files with 101 additions and 174 deletions
+2 -3
View File
@@ -36,10 +36,9 @@
#include "androidqtsupport.h"
#include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <projectexplorer/buildconfiguration.h>
@@ -121,7 +120,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
}
DebuggerRunControl * const debuggerRunControl
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage);
new AndroidDebugSupport(runConfig, debuggerRunControl);
return debuggerRunControl;
}
@@ -33,7 +33,7 @@
#include "baremetalrunconfiguration.h"
#include "baremetaldevice.h"
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerkitinformation.h>
#include <projectexplorer/buildsteplist.h>
@@ -143,7 +143,7 @@ RunControl *BareMetalRunControlFactory::create(RunConfiguration *runConfiguratio
.arg(sp.executable);
return 0;
}
return DebuggerPlugin::createDebugger(sp,runConfiguration,errorMessage);
return DebuggerRunControlFactory::doCreate(sp, runConfiguration, errorMessage);
}
} // namespace Internal
@@ -35,7 +35,6 @@
#include <projectexplorer/runconfiguration.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerrunner.h>
namespace BareMetal {
namespace Internal {
+2 -3
View File
@@ -33,7 +33,7 @@ HEADERS += \
debuggerplugin.h \
debuggerprotocol.h \
debuggerrunconfigurationaspect.h \
debuggerrunner.h \
debuggerruncontrol.h \
debuggerstartparameters.h \
debuggerstringutils.h \
debuggerkitconfigwidget.h \
@@ -65,7 +65,6 @@ HEADERS += \
threaddata.h \
threadshandler.h \
watchdelegatewidgets.h \
debuggerruncontrolfactory.h \
debuggertooltipmanager.h \
debuggersourcepathmappingwidget.h \
memoryview.h \
@@ -90,7 +89,7 @@ SOURCES += \
debuggerplugin.cpp \
debuggerprotocol.cpp \
debuggerrunconfigurationaspect.cpp \
debuggerrunner.cpp \
debuggerruncontrol.cpp \
debuggeroptionspage.cpp \
debuggerkitconfigwidget.cpp \
debuggerkitinformation.cpp \
+1 -2
View File
@@ -50,9 +50,8 @@ QtcPlugin {
"debuggeroptionspage.cpp", "debuggeroptionspage.h",
"debuggerplugin.cpp", "debuggerplugin.h",
"debuggerprotocol.cpp", "debuggerprotocol.h",
"debuggerruncontrolfactory.h",
"debuggerrunconfigurationaspect.cpp", "debuggerrunconfigurationaspect.h",
"debuggerrunner.cpp", "debuggerrunner.h",
"debuggerruncontrol.cpp", "debuggerruncontrol.h",
"debuggersourcepathmappingwidget.cpp", "debuggersourcepathmappingwidget.h",
"debuggerstartparameters.h",
"debuggerstringutils.h",
+1 -1
View File
@@ -33,7 +33,7 @@
#include "debuggerinternalconstants.h"
#include "debuggeractions.h"
#include "debuggercore.h"
#include "debuggerrunner.h"
#include "debuggerruncontrol.h"
#include "debuggerstringutils.h"
#include "debuggerstartparameters.h"
#include "debuggertooltipmanager.h"
+26 -19
View File
@@ -41,18 +41,23 @@
#include <QProcess>
#include <QUuid>
#ifdef WITH_TESTS
# include <QTest>
# include "debuggerplugin.h"
#endif
using namespace Debugger::Internal;
using namespace ProjectExplorer;
using namespace Utils;
static const char DEBUGGER_INFORMATION_COMMAND[] = "Binary";
static const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName";
static const char DEBUGGER_INFORMATION_ID[] = "Id";
static const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType";
static const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
static const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
static const char DEBUGGER_INFORMATION_VERSION[] = "Version";
static const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
const char DEBUGGER_INFORMATION_COMMAND[] = "Binary";
const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName";
const char DEBUGGER_INFORMATION_ID[] = "Id";
const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType";
const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
const char DEBUGGER_INFORMATION_VERSION[] = "Version";
const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
namespace Debugger {
@@ -165,13 +170,13 @@ void DebuggerItem::reinitializeFromFile()
QString DebuggerItem::engineTypeName() const
{
switch (m_engineType) {
case Debugger::NoEngineType:
case NoEngineType:
return DebuggerOptionsPage::tr("Not recognized");
case Debugger::GdbEngineType:
case GdbEngineType:
return QLatin1String("GDB");
case Debugger::CdbEngineType:
case CdbEngineType:
return QLatin1String("CDB");
case Debugger::LldbEngineType:
case LldbEngineType:
return QLatin1String("LLDB");
default:
return QString();
@@ -302,19 +307,16 @@ DebuggerItem::MatchLevel DebuggerItem::matchTarget(const Abi &targetAbi) const
return bestMatch;
}
bool Debugger::DebuggerItem::isValid() const
bool DebuggerItem::isValid() const
{
return !m_id.isNull();
}
} // namespace Debugger;
#ifdef WITH_TESTS
# include <QTest>
# include "debuggerplugin.h"
namespace Internal {
void Debugger::DebuggerPlugin::testDebuggerMatching_data()
void DebuggerPlugin::testDebuggerMatching_data()
{
QTest::addColumn<QStringList>("debugger");
QTest::addColumn<QString>("target");
@@ -394,7 +396,7 @@ void Debugger::DebuggerPlugin::testDebuggerMatching_data()
<< int(DebuggerItem::DoesNotMatch);
}
void Debugger::DebuggerPlugin::testDebuggerMatching()
void DebuggerPlugin::testDebuggerMatching()
{
QFETCH(QStringList, debugger);
QFETCH(QString, target);
@@ -415,4 +417,9 @@ void Debugger::DebuggerPlugin::testDebuggerMatching()
QCOMPARE(expectedLevel, level);
}
} // namespace Internal
#endif
} // namespace Debugger;
+3 -1
View File
@@ -43,6 +43,8 @@ namespace Utils { class PersistentSettingsWriter; }
namespace Debugger {
namespace Internal { class DebuggerPlugin; }
// -----------------------------------------------------------------------
// DebuggerItemManager
// -----------------------------------------------------------------------
@@ -91,7 +93,7 @@ private:
static QList<DebuggerItem> m_debuggers;
friend class Internal::DebuggerItemModel;
friend class DebuggerPlugin; // Enable constrcutor for DebuggerPlugin
friend class Internal::DebuggerPlugin; // Enable constrcutor for DebuggerPlugin
};
} // namespace Debugger
+1 -8
View File
@@ -39,9 +39,8 @@
#include "debuggerengine.h"
#include "debuggeritemmanager.h"
#include "debuggermainwindow.h"
#include "debuggerrunner.h"
#include "debuggerrunconfigurationaspect.h"
#include "debuggerruncontrolfactory.h"
#include "debuggerruncontrol.h"
#include "debuggerstringutils.h"
#include "debuggeroptionspage.h"
#include "debuggerkitinformation.h"
@@ -3482,12 +3481,6 @@ QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
return 0;
}
DebuggerRunControl *DebuggerPlugin::createDebugger
(const DebuggerStartParameters &sp, RunConfiguration *rc, QString *errorMessage)
{
return DebuggerRunControlFactory::doCreate(sp, rc, errorMessage);
}
void DebuggerPlugin::extensionsInitialized()
{
theDebuggerCore->extensionsInitialized();
+3 -17
View File
@@ -32,23 +32,12 @@
#define DEBUGGERPLUGIN_H
#include "debugger_global.h"
#include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace ProjectExplorer {
class RunConfiguration;
class RunControl;
}
namespace Debugger {
namespace Internal {
class DebuggerMainWindow;
class DebuggerRunControl;
class DebuggerStartParameters;
class DEBUGGER_EXPORT DebuggerPlugin : public ExtensionSystem::IPlugin
class DebuggerPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Debugger.json")
@@ -57,10 +46,6 @@ public:
DebuggerPlugin();
~DebuggerPlugin();
static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc,
QString *errorMessage);
private:
// IPlugin implementation.
bool initialize(const QStringList &arguments, QString *errorMessage);
@@ -78,6 +63,7 @@ private slots:
#endif
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGERPLUGIN_H
@@ -28,8 +28,7 @@
**
****************************************************************************/
#include "debuggerrunner.h"
#include "debuggerruncontrolfactory.h"
#include "debuggerruncontrol.h"
#include "debuggeractions.h"
#include "debuggercore.h"
@@ -28,9 +28,10 @@
**
****************************************************************************/
#ifndef DEBUGGERRUNCONTROLFACTORY_H
#define DEBUGGERRUNCONTROLFACTORY_H
#ifndef DEBUGGERRUNCONTROL_H
#define DEBUGGERRUNCONTROL_H
#include "debugger_global.h"
#include "debuggerconstants.h"
#include <projectexplorer/runconfiguration.h>
@@ -38,12 +39,42 @@
namespace Debugger {
class DebuggerEngine;
class DebuggerRunControl;
class DebuggerStartParameters;
namespace Internal {
class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl
{
Q_OBJECT
class DebuggerRunControlFactory
public:
~DebuggerRunControl();
// ProjectExplorer::RunControl
void start();
bool promptToStop(bool *prompt = 0) const;
StopResult stop(); // Called from SnapshotWindow.
bool isRunning() const;
QString displayName() const;
void startFailed();
void debuggingFinished();
DebuggerEngine *engine();
signals:
void engineRequestSetup();
private slots:
void handleFinished();
private:
friend class DebuggerRunControlFactory;
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerEngine *engine);
DebuggerEngine *m_engine;
bool m_running;
};
class DEBUGGER_EXPORT DebuggerRunControlFactory
: public ProjectExplorer::IRunControlFactory
{
public:
@@ -71,7 +102,6 @@ public:
ProjectExplorer::RunConfiguration *rc);
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGERRUNCONTROLFACTORY_H
#endif // DEBUGGERRUNCONTROL_H
-79
View File
@@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. 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, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef DEBUGGERRUNNER_H
#define DEBUGGERRUNNER_H
#include "debugger_global.h"
#include <projectexplorer/runconfiguration.h>
namespace Debugger {
class DebuggerEngine;
class DebuggerRunControl;
namespace Internal { class DebuggerRunControlFactory; }
class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl
{
Q_OBJECT
public:
~DebuggerRunControl();
// ProjectExplorer::RunControl
void start();
bool promptToStop(bool *prompt = 0) const;
StopResult stop(); // Called from SnapshotWindow.
bool isRunning() const;
QString displayName() const;
void startFailed();
void debuggingFinished();
DebuggerEngine *engine();
signals:
void engineRequestSetup();
private slots:
void handleFinished();
private:
friend class Internal::DebuggerRunControlFactory;
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerEngine *engine);
DebuggerEngine *m_engine;
bool m_running;
};
} // namespace Debugger
#endif // DEBUGGERRUNNER_H
+1 -1
View File
@@ -39,7 +39,7 @@
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggerruncontrolfactory.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/disassemblerlines.h>
#include <debugger/debuggeractions.h>
@@ -33,7 +33,7 @@
#include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerruncontrolfactory.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <coreplugin/icore.h>
-1
View File
@@ -35,7 +35,6 @@
#include <debugger/debuggerdialogs.h>
#include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerprotocol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h>
+1 -1
View File
@@ -30,7 +30,7 @@
#include "qmlcppengine.h"
#include "qmlengine.h"
#include <debugger/debuggerruncontrolfactory.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/stackhandler.h>
#include <debugger/watchhandler.h>
+4 -5
View File
@@ -32,12 +32,12 @@
#include "baseqmldebuggerclient.h"
#include "qmlinspectoragent.h"
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h>
#include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggermainwindow.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h>
#include <debugger/debuggertooltipmanager.h>
#include <debugger/localsandexpressionswindow.h>
@@ -47,6 +47,7 @@
#include <debugger/stackhandler.h>
#include <debugger/watchhandler.h>
#include <debugger/sourcefileshandler.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -62,12 +63,10 @@
#include <QDebug>
#include <QDir>
#include <QDockWidget>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QDockWidget>
#define DEBUG_QML 1
#if DEBUG_QML
# define SDEBUG(s) qDebug() << s
-1
View File
@@ -385,7 +385,6 @@ private slots:
void updateVimRcWidgets();
private:
friend class DebuggerPlugin;
QPointer<QWidget> m_widget;
Ui::FakeVimOptionPage m_ui;
Utils::SavedActionSet m_group;
+1 -1
View File
@@ -37,7 +37,7 @@
#include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/toolchain.h>
+2 -2
View File
@@ -37,7 +37,7 @@
#include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/toolchain.h>
@@ -171,7 +171,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
}
DebuggerRunControl * const debuggerRunControl
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage);
if (debuggerRunControl)
new IosDebugSupport(runConfig, debuggerRunControl, cppDebug, qmlDebug);
return debuggerRunControl;
+1 -1
View File
@@ -33,7 +33,7 @@
#include "blackberrydebugsupport.h"
#include "blackberryapplicationrunner.h"
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerengine.h>
#include <debugger/debuggerstartparameters.h>
@@ -42,7 +42,7 @@
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerkitinformation.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/project.h>
@@ -161,7 +161,7 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer
return runControl;
}
Debugger::DebuggerRunControl * const runControl =
Debugger::DebuggerPlugin::createDebugger(startParameters(rc), runConfiguration, errorMessage);
Debugger::DebuggerRunControlFactory::doCreate(startParameters(rc), runConfiguration, errorMessage);
if (!runControl)
return 0;
+2 -3
View File
@@ -37,8 +37,7 @@
#include <debugger/debuggerengine.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
@@ -134,7 +133,7 @@ void QnxAttachDebugSupport::attachToProcess()
sp.solibSearchPath = QnxUtils::searchPaths(qtVersion);
QString errorMessage;
Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerPlugin::createDebugger(sp, 0, &errorMessage);
Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerRunControlFactory::doCreate(sp, 0, &errorMessage);
if (!errorMessage.isEmpty()) {
handleError(errorMessage);
stopPDebug();
+1 -1
View File
@@ -38,7 +38,7 @@
#include <debugger/debuggerengine.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
+2 -3
View File
@@ -41,8 +41,7 @@
#include "qnxdeviceconfiguration.h"
#include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerkitinformation.h>
@@ -181,7 +180,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return new QnxRunControl(rc);
case DebugRunMode: {
const DebuggerStartParameters params = createDebuggerStartParameters(rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
DebuggerRunControl * const runControl = DebuggerRunControlFactory::doCreate(params, rc, errorMessage);
if (!runControl)
return 0;
@@ -36,8 +36,7 @@
#include "remotelinuxrunconfiguration.h"
#include "remotelinuxruncontrol.h"
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <analyzerbase/analyzerstartparameters.h>
#include <analyzerbase/analyzermanager.h>
@@ -108,7 +107,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
if (mode == ProjectExplorer::DebugRunModeWithBreakOnMain)
params.breakOnMain = true;
DebuggerRunControl * const runControl
= DebuggerPlugin::createDebugger(params, rc, errorMessage);
= DebuggerRunControlFactory::doCreate(params, rc, errorMessage);
if (!runControl)
return 0;
LinuxDeviceDebugSupport * const debugSupport =
+2 -3
View File
@@ -34,8 +34,7 @@
#include <debugger/debuggerengine.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
@@ -122,7 +121,7 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
}
server.close();
Debugger::DebuggerRunControl *debugRunControl
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage);
runner->setRunControl(debugRunControl);
new WinRtDebugSupport(debugRunControl, runner);
return debugRunControl;