Commit 55b2bb16 authored by hjk's avatar hjk

Debugger: Consolidate RunControl creation

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

Change-Id: I13a46460d07d5ded6b26f2b5ceccd01142fb10e8
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent ca9ed450
...@@ -36,10 +36,9 @@ ...@@ -36,10 +36,9 @@
#include "androidqtsupport.h" #include "androidqtsupport.h"
#include <debugger/debuggerengine.h> #include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunconfigurationaspect.h> #include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerrunner.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
...@@ -121,7 +120,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration * ...@@ -121,7 +120,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
} }
DebuggerRunControl * const debuggerRunControl DebuggerRunControl * const debuggerRunControl
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage); = DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage);
new AndroidDebugSupport(runConfig, debuggerRunControl); new AndroidDebugSupport(runConfig, debuggerRunControl);
return debuggerRunControl; return debuggerRunControl;
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "baremetalrunconfiguration.h" #include "baremetalrunconfiguration.h"
#include "baremetaldevice.h" #include "baremetaldevice.h"
#include <debugger/debuggerplugin.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
...@@ -143,7 +143,7 @@ RunControl *BareMetalRunControlFactory::create(RunConfiguration *runConfiguratio ...@@ -143,7 +143,7 @@ RunControl *BareMetalRunControlFactory::create(RunConfiguration *runConfiguratio
.arg(sp.executable); .arg(sp.executable);
return 0; return 0;
} }
return DebuggerPlugin::createDebugger(sp,runConfiguration,errorMessage); return DebuggerRunControlFactory::doCreate(sp, runConfiguration, errorMessage);
} }
} // namespace Internal } // namespace Internal
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerrunner.h>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
......
...@@ -33,7 +33,7 @@ HEADERS += \ ...@@ -33,7 +33,7 @@ HEADERS += \
debuggerplugin.h \ debuggerplugin.h \
debuggerprotocol.h \ debuggerprotocol.h \
debuggerrunconfigurationaspect.h \ debuggerrunconfigurationaspect.h \
debuggerrunner.h \ debuggerruncontrol.h \
debuggerstartparameters.h \ debuggerstartparameters.h \
debuggerstringutils.h \ debuggerstringutils.h \
debuggerkitconfigwidget.h \ debuggerkitconfigwidget.h \
...@@ -65,7 +65,6 @@ HEADERS += \ ...@@ -65,7 +65,6 @@ HEADERS += \
threaddata.h \ threaddata.h \
threadshandler.h \ threadshandler.h \
watchdelegatewidgets.h \ watchdelegatewidgets.h \
debuggerruncontrolfactory.h \
debuggertooltipmanager.h \ debuggertooltipmanager.h \
debuggersourcepathmappingwidget.h \ debuggersourcepathmappingwidget.h \
memoryview.h \ memoryview.h \
...@@ -90,7 +89,7 @@ SOURCES += \ ...@@ -90,7 +89,7 @@ SOURCES += \
debuggerplugin.cpp \ debuggerplugin.cpp \
debuggerprotocol.cpp \ debuggerprotocol.cpp \
debuggerrunconfigurationaspect.cpp \ debuggerrunconfigurationaspect.cpp \
debuggerrunner.cpp \ debuggerruncontrol.cpp \
debuggeroptionspage.cpp \ debuggeroptionspage.cpp \
debuggerkitconfigwidget.cpp \ debuggerkitconfigwidget.cpp \
debuggerkitinformation.cpp \ debuggerkitinformation.cpp \
......
...@@ -50,9 +50,8 @@ QtcPlugin { ...@@ -50,9 +50,8 @@ QtcPlugin {
"debuggeroptionspage.cpp", "debuggeroptionspage.h", "debuggeroptionspage.cpp", "debuggeroptionspage.h",
"debuggerplugin.cpp", "debuggerplugin.h", "debuggerplugin.cpp", "debuggerplugin.h",
"debuggerprotocol.cpp", "debuggerprotocol.h", "debuggerprotocol.cpp", "debuggerprotocol.h",
"debuggerruncontrolfactory.h",
"debuggerrunconfigurationaspect.cpp", "debuggerrunconfigurationaspect.h", "debuggerrunconfigurationaspect.cpp", "debuggerrunconfigurationaspect.h",
"debuggerrunner.cpp", "debuggerrunner.h", "debuggerruncontrol.cpp", "debuggerruncontrol.h",
"debuggersourcepathmappingwidget.cpp", "debuggersourcepathmappingwidget.h", "debuggersourcepathmappingwidget.cpp", "debuggersourcepathmappingwidget.h",
"debuggerstartparameters.h", "debuggerstartparameters.h",
"debuggerstringutils.h", "debuggerstringutils.h",
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "debuggerinternalconstants.h" #include "debuggerinternalconstants.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggercore.h" #include "debuggercore.h"
#include "debuggerrunner.h" #include "debuggerruncontrol.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "debuggerstartparameters.h" #include "debuggerstartparameters.h"
#include "debuggertooltipmanager.h" #include "debuggertooltipmanager.h"
......
...@@ -41,18 +41,23 @@ ...@@ -41,18 +41,23 @@
#include <QProcess> #include <QProcess>
#include <QUuid> #include <QUuid>
#ifdef WITH_TESTS
# include <QTest>
# include "debuggerplugin.h"
#endif
using namespace Debugger::Internal; using namespace Debugger::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
static const char DEBUGGER_INFORMATION_COMMAND[] = "Binary"; const char DEBUGGER_INFORMATION_COMMAND[] = "Binary";
static const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName"; const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName";
static const char DEBUGGER_INFORMATION_ID[] = "Id"; const char DEBUGGER_INFORMATION_ID[] = "Id";
static const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType"; const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType";
static const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected"; const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
static const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource"; const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
static const char DEBUGGER_INFORMATION_VERSION[] = "Version"; const char DEBUGGER_INFORMATION_VERSION[] = "Version";
static const char DEBUGGER_INFORMATION_ABIS[] = "Abis"; const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
namespace Debugger { namespace Debugger {
...@@ -165,13 +170,13 @@ void DebuggerItem::reinitializeFromFile() ...@@ -165,13 +170,13 @@ void DebuggerItem::reinitializeFromFile()
QString DebuggerItem::engineTypeName() const QString DebuggerItem::engineTypeName() const
{ {
switch (m_engineType) { switch (m_engineType) {
case Debugger::NoEngineType: case NoEngineType:
return DebuggerOptionsPage::tr("Not recognized"); return DebuggerOptionsPage::tr("Not recognized");
case Debugger::GdbEngineType: case GdbEngineType:
return QLatin1String("GDB"); return QLatin1String("GDB");
case Debugger::CdbEngineType: case CdbEngineType:
return QLatin1String("CDB"); return QLatin1String("CDB");
case Debugger::LldbEngineType: case LldbEngineType:
return QLatin1String("LLDB"); return QLatin1String("LLDB");
default: default:
return QString(); return QString();
...@@ -302,19 +307,16 @@ DebuggerItem::MatchLevel DebuggerItem::matchTarget(const Abi &targetAbi) const ...@@ -302,19 +307,16 @@ DebuggerItem::MatchLevel DebuggerItem::matchTarget(const Abi &targetAbi) const
return bestMatch; return bestMatch;
} }
bool Debugger::DebuggerItem::isValid() const bool DebuggerItem::isValid() const
{ {
return !m_id.isNull(); return !m_id.isNull();
} }
} // namespace Debugger;
#ifdef WITH_TESTS #ifdef WITH_TESTS
# include <QTest> namespace Internal {
# include "debuggerplugin.h"
void Debugger::DebuggerPlugin::testDebuggerMatching_data() void DebuggerPlugin::testDebuggerMatching_data()
{ {
QTest::addColumn<QStringList>("debugger"); QTest::addColumn<QStringList>("debugger");
QTest::addColumn<QString>("target"); QTest::addColumn<QString>("target");
...@@ -394,7 +396,7 @@ void Debugger::DebuggerPlugin::testDebuggerMatching_data() ...@@ -394,7 +396,7 @@ void Debugger::DebuggerPlugin::testDebuggerMatching_data()
<< int(DebuggerItem::DoesNotMatch); << int(DebuggerItem::DoesNotMatch);
} }
void Debugger::DebuggerPlugin::testDebuggerMatching() void DebuggerPlugin::testDebuggerMatching()
{ {
QFETCH(QStringList, debugger); QFETCH(QStringList, debugger);
QFETCH(QString, target); QFETCH(QString, target);
...@@ -415,4 +417,9 @@ void Debugger::DebuggerPlugin::testDebuggerMatching() ...@@ -415,4 +417,9 @@ void Debugger::DebuggerPlugin::testDebuggerMatching()
QCOMPARE(expectedLevel, level); QCOMPARE(expectedLevel, level);
} }
} // namespace Internal
#endif #endif
} // namespace Debugger;
...@@ -43,6 +43,8 @@ namespace Utils { class PersistentSettingsWriter; } ...@@ -43,6 +43,8 @@ namespace Utils { class PersistentSettingsWriter; }
namespace Debugger { namespace Debugger {
namespace Internal { class DebuggerPlugin; }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// DebuggerItemManager // DebuggerItemManager
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -91,7 +93,7 @@ private: ...@@ -91,7 +93,7 @@ private:
static QList<DebuggerItem> m_debuggers; static QList<DebuggerItem> m_debuggers;
friend class Internal::DebuggerItemModel; friend class Internal::DebuggerItemModel;
friend class DebuggerPlugin; // Enable constrcutor for DebuggerPlugin friend class Internal::DebuggerPlugin; // Enable constrcutor for DebuggerPlugin
}; };
} // namespace Debugger } // namespace Debugger
......
...@@ -39,9 +39,8 @@ ...@@ -39,9 +39,8 @@
#include "debuggerengine.h" #include "debuggerengine.h"
#include "debuggeritemmanager.h" #include "debuggeritemmanager.h"
#include "debuggermainwindow.h" #include "debuggermainwindow.h"
#include "debuggerrunner.h"
#include "debuggerrunconfigurationaspect.h" #include "debuggerrunconfigurationaspect.h"
#include "debuggerruncontrolfactory.h" #include "debuggerruncontrol.h"
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "debuggeroptionspage.h" #include "debuggeroptionspage.h"
#include "debuggerkitinformation.h" #include "debuggerkitinformation.h"
...@@ -3482,12 +3481,6 @@ QObject *DebuggerPlugin::remoteCommand(const QStringList &options, ...@@ -3482,12 +3481,6 @@ QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
return 0; return 0;
} }
DebuggerRunControl *DebuggerPlugin::createDebugger
(const DebuggerStartParameters &sp, RunConfiguration *rc, QString *errorMessage)
{
return DebuggerRunControlFactory::doCreate(sp, rc, errorMessage);
}
void DebuggerPlugin::extensionsInitialized() void DebuggerPlugin::extensionsInitialized()
{ {
theDebuggerCore->extensionsInitialized(); theDebuggerCore->extensionsInitialized();
......
...@@ -32,23 +32,12 @@ ...@@ -32,23 +32,12 @@
#define DEBUGGERPLUGIN_H #define DEBUGGERPLUGIN_H
#include "debugger_global.h" #include "debugger_global.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace ProjectExplorer {
class RunConfiguration;
class RunControl;
}
namespace Debugger { namespace Debugger {
namespace Internal {
class DebuggerMainWindow; class DebuggerPlugin : public ExtensionSystem::IPlugin
class DebuggerRunControl;
class DebuggerStartParameters;
class DEBUGGER_EXPORT DebuggerPlugin : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Debugger.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Debugger.json")
...@@ -57,10 +46,6 @@ public: ...@@ -57,10 +46,6 @@ public:
DebuggerPlugin(); DebuggerPlugin();
~DebuggerPlugin(); ~DebuggerPlugin();
static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc,
QString *errorMessage);
private: private:
// IPlugin implementation. // IPlugin implementation.
bool initialize(const QStringList &arguments, QString *errorMessage); bool initialize(const QStringList &arguments, QString *errorMessage);
...@@ -78,6 +63,7 @@ private slots: ...@@ -78,6 +63,7 @@ private slots:
#endif #endif
}; };
} // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif // DEBUGGERPLUGIN_H #endif // DEBUGGERPLUGIN_H
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "debuggerrunner.h" #include "debuggerruncontrol.h"
#include "debuggerruncontrolfactory.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggercore.h" #include "debuggercore.h"
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef DEBUGGERRUNCONTROLFACTORY_H #ifndef DEBUGGERRUNCONTROL_H
#define DEBUGGERRUNCONTROLFACTORY_H #define DEBUGGERRUNCONTROL_H
#include "debugger_global.h"
#include "debuggerconstants.h" #include "debuggerconstants.h"
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
...@@ -38,12 +39,42 @@ ...@@ -38,12 +39,42 @@
namespace Debugger { namespace Debugger {
class DebuggerEngine; class DebuggerEngine;
class DebuggerRunControl;
class DebuggerStartParameters; class DebuggerStartParameters;
namespace Internal { 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 DebuggerRunControlFactory;
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerEngine *engine);
DebuggerEngine *m_engine;
bool m_running;
};
class DebuggerRunControlFactory class DEBUGGER_EXPORT DebuggerRunControlFactory
: public ProjectExplorer::IRunControlFactory : public ProjectExplorer::IRunControlFactory
{ {
public: public:
...@@ -71,7 +102,6 @@ public: ...@@ -71,7 +102,6 @@ public:
ProjectExplorer::RunConfiguration *rc); ProjectExplorer::RunConfiguration *rc);
}; };
} // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif // DEBUGGERRUNCONTROLFACTORY_H #endif // DEBUGGERRUNCONTROL_H
/****************************************************************************
**
** 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
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerinternalconstants.h> #include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggerruncontrolfactory.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/disassemblerlines.h> #include <debugger/disassemblerlines.h>
#include <debugger/debuggeractions.h> #include <debugger/debuggeractions.h>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <debugger/debuggermainwindow.h> #include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h> #include <debugger/debuggerplugin.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerruncontrolfactory.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <debugger/debuggerdialogs.h> #include <debugger/debuggerdialogs.h>
#include <debugger/debuggerinternalconstants.h> #include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggermainwindow.h> #include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerprotocol.h> #include <debugger/debuggerprotocol.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h> #include <debugger/debuggerstringutils.h>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "qmlcppengine.h" #include "qmlcppengine.h"
#include "qmlengine.h" #include "qmlengine.h"
#include <debugger/debuggerruncontrolfactory.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/stackhandler.h> #include <debugger/stackhandler.h>
#include <debugger/watchhandler.h> #include <debugger/watchhandler.h>
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
#include "baseqmldebuggerclient.h" #include "baseqmldebuggerclient.h"
#include "qmlinspectoragent.h" #include "qmlinspectoragent.h"
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggeractions.h> #include <debugger/debuggeractions.h>
#include <debugger/debuggercore.h> #include <debugger/debuggercore.h>
#include <debugger/debuggerinternalconstants.h> #include <debugger/debuggerinternalconstants.h>
#include <debugger/debuggermainwindow.h> #include <debugger/debuggermainwindow.h>
#include <debugger/debuggerrunner.h>