forked from qt-creator/qt-creator
Debugger: Move more RunControl setup to factory
Reasons mentioning S60DebugControl do not apply anymore. Change-Id: Id7686ab90f2c25492685eb655403ed369bf99ee4 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -74,6 +74,8 @@ DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp);
|
|||||||
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
|
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
|
||||||
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &sp);
|
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &sp);
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
static const char *engineTypeName(DebuggerEngineType et)
|
static const char *engineTypeName(DebuggerEngineType et)
|
||||||
{
|
{
|
||||||
switch (et) {
|
switch (et) {
|
||||||
@@ -97,85 +99,50 @@ static const char *engineTypeName(DebuggerEngineType et)
|
|||||||
return "No engine";
|
return "No engine";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, DebuggerEngine *engine)
|
||||||
//
|
|
||||||
// DebuggerRunControlPrivate
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class DebuggerRunControlPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit DebuggerRunControlPrivate(RunConfiguration *runConfiguration);
|
|
||||||
|
|
||||||
public:
|
|
||||||
DebuggerEngine *m_engine;
|
|
||||||
const QPointer<RunConfiguration> m_myRunConfiguration;
|
|
||||||
bool m_running;
|
|
||||||
};
|
|
||||||
|
|
||||||
DebuggerRunControlPrivate::DebuggerRunControlPrivate(RunConfiguration *runConfiguration)
|
|
||||||
: m_engine(0)
|
|
||||||
, m_myRunConfiguration(runConfiguration)
|
|
||||||
, m_running(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
|
|
||||||
const DebuggerStartParameters &sp)
|
|
||||||
: RunControl(runConfiguration, DebugRunMode),
|
: RunControl(runConfiguration, DebugRunMode),
|
||||||
d(new DebuggerRunControlPrivate(runConfiguration))
|
m_engine(engine),
|
||||||
|
m_runConfiguration(runConfiguration),
|
||||||
|
m_running(false)
|
||||||
{
|
{
|
||||||
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL));
|
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL));
|
||||||
|
connect(this, &RunControl::finished, this, &DebuggerRunControl::handleFinished);
|
||||||
connect(this, SIGNAL(finished()), SLOT(handleFinished()));
|
|
||||||
// Create the engine. Could arguably be moved to the factory, but
|
|
||||||
// we still have a derived S60DebugControl. Should rarely fail, though.
|
|
||||||
QString errorMessage;
|
|
||||||
d->m_engine = DebuggerRunControlFactory::createEngine(sp.masterEngineType, sp, &errorMessage);
|
|
||||||
|
|
||||||
if (!d->m_engine) {
|
|
||||||
debuggingFinished();
|
|
||||||
Core::ICore::showWarningWithOptions(DebuggerRunControl::tr("Debugger"), errorMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerRunControl::~DebuggerRunControl()
|
DebuggerRunControl::~DebuggerRunControl()
|
||||||
{
|
{
|
||||||
disconnect();
|
disconnect();
|
||||||
if (DebuggerEngine *engine = d->m_engine) {
|
if (m_engine) {
|
||||||
d->m_engine = 0;
|
DebuggerEngine *engine = m_engine;
|
||||||
|
m_engine = 0;
|
||||||
engine->disconnect();
|
engine->disconnect();
|
||||||
delete engine;
|
delete engine;
|
||||||
}
|
}
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DebuggerRunControl::displayName() const
|
QString DebuggerRunControl::displayName() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_engine, return QString());
|
QTC_ASSERT(m_engine, return QString());
|
||||||
return d->m_engine->startParameters().displayName;
|
return m_engine->startParameters().displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::start()
|
void DebuggerRunControl::start()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_engine, return);
|
QTC_ASSERT(m_engine, return);
|
||||||
// User canceled input dialog asking for executable when working on library project.
|
// User canceled input dialog asking for executable when working on library project.
|
||||||
if (d->m_engine->startParameters().startMode == StartInternal
|
if (m_engine->startParameters().startMode == StartInternal
|
||||||
&& d->m_engine->startParameters().executable.isEmpty()) {
|
&& m_engine->startParameters().executable.isEmpty()) {
|
||||||
appendMessage(tr("No executable specified.") + QLatin1Char('\n'), ErrorMessageFormat);
|
appendMessage(tr("No executable specified.") + QLatin1Char('\n'), ErrorMessageFormat);
|
||||||
emit started();
|
emit started();
|
||||||
emit finished();
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_engine->startParameters().startMode == StartInternal) {
|
if (m_engine->startParameters().startMode == StartInternal) {
|
||||||
QStringList unhandledIds;
|
QStringList unhandledIds;
|
||||||
foreach (const BreakpointModelId &id, breakHandler()->allBreakpointIds()) {
|
foreach (const BreakpointModelId &id, breakHandler()->allBreakpointIds()) {
|
||||||
if (d->m_engine->breakHandler()->breakpointData(id).enabled
|
if (m_engine->breakHandler()->breakpointData(id).enabled
|
||||||
&& !d->m_engine->acceptsBreakpoint(id))
|
&& !m_engine->acceptsBreakpoint(id))
|
||||||
unhandledIds.append(id.toString());
|
unhandledIds.append(id.toString());
|
||||||
}
|
}
|
||||||
if (!unhandledIds.isEmpty()) {
|
if (!unhandledIds.isEmpty()) {
|
||||||
@@ -197,33 +164,33 @@ void DebuggerRunControl::start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debuggerCore()->runControlStarted(d->m_engine);
|
debuggerCore()->runControlStarted(m_engine);
|
||||||
|
|
||||||
// We might get a synchronous startFailed() notification on Windows,
|
// We might get a synchronous startFailed() notification on Windows,
|
||||||
// when launching the process fails. Emit a proper finished() sequence.
|
// when launching the process fails. Emit a proper finished() sequence.
|
||||||
emit started();
|
emit started();
|
||||||
d->m_running = true;
|
m_running = true;
|
||||||
|
|
||||||
d->m_engine->startDebugger(this);
|
m_engine->startDebugger(this);
|
||||||
|
|
||||||
if (d->m_running)
|
if (m_running)
|
||||||
appendMessage(tr("Debugging starts") + QLatin1Char('\n'), NormalMessageFormat);
|
appendMessage(tr("Debugging starts") + QLatin1Char('\n'), NormalMessageFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::startFailed()
|
void DebuggerRunControl::startFailed()
|
||||||
{
|
{
|
||||||
appendMessage(tr("Debugging has failed") + QLatin1Char('\n'), NormalMessageFormat);
|
appendMessage(tr("Debugging has failed") + QLatin1Char('\n'), NormalMessageFormat);
|
||||||
d->m_running = false;
|
m_running = false;
|
||||||
emit finished();
|
emit finished();
|
||||||
d->m_engine->handleStartFailed();
|
m_engine->handleStartFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::handleFinished()
|
void DebuggerRunControl::handleFinished()
|
||||||
{
|
{
|
||||||
appendMessage(tr("Debugging has finished") + QLatin1Char('\n'), NormalMessageFormat);
|
appendMessage(tr("Debugging has finished") + QLatin1Char('\n'), NormalMessageFormat);
|
||||||
if (d->m_engine)
|
if (m_engine)
|
||||||
d->m_engine->handleFinished();
|
m_engine->handleFinished();
|
||||||
debuggerCore()->runControlFinished(d->m_engine);
|
debuggerCore()->runControlFinished(m_engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::showMessage(const QString &msg, int channel)
|
void DebuggerRunControl::showMessage(const QString &msg, int channel)
|
||||||
@@ -258,31 +225,31 @@ bool DebuggerRunControl::promptToStop(bool *optionalPrompt) const
|
|||||||
|
|
||||||
RunControl::StopResult DebuggerRunControl::stop()
|
RunControl::StopResult DebuggerRunControl::stop()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_engine, return StoppedSynchronously);
|
QTC_ASSERT(m_engine, return StoppedSynchronously);
|
||||||
d->m_engine->quitDebugger();
|
m_engine->quitDebugger();
|
||||||
return AsynchronousStop;
|
return AsynchronousStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::debuggingFinished()
|
void DebuggerRunControl::debuggingFinished()
|
||||||
{
|
{
|
||||||
d->m_running = false;
|
m_running = false;
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerRunControl::isRunning() const
|
bool DebuggerRunControl::isRunning() const
|
||||||
{
|
{
|
||||||
return d->m_running;
|
return m_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerEngine *DebuggerRunControl::engine()
|
DebuggerEngine *DebuggerRunControl::engine()
|
||||||
{
|
{
|
||||||
QTC_CHECK(d->m_engine);
|
QTC_CHECK(m_engine);
|
||||||
return d->m_engine;
|
return m_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
RunConfiguration *DebuggerRunControl::runConfiguration() const
|
RunConfiguration *DebuggerRunControl::runConfiguration() const
|
||||||
{
|
{
|
||||||
return d->m_myRunConfiguration.data();
|
return m_runConfiguration.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -445,7 +412,15 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
|
|||||||
if (!fixupEngineTypes(sp, rc, errorMessage))
|
if (!fixupEngineTypes(sp, rc, errorMessage))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return new DebuggerRunControl(rc, sp);
|
QString error;
|
||||||
|
DebuggerEngine *engine = createEngine(sp.masterEngineType, sp, &error);
|
||||||
|
if (!engine) {
|
||||||
|
Core::ICore::showWarningWithOptions(DebuggerRunControl::tr("Debugger"), error);
|
||||||
|
if (errorMessage)
|
||||||
|
*errorMessage = error;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return new DebuggerRunControl(rc, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRunConfigurationAspect *DebuggerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
IRunConfigurationAspect *DebuggerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
||||||
|
|||||||
@@ -36,18 +36,12 @@
|
|||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
namespace Utils { class Environment; }
|
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
class DebuggerRunControl;
|
class DebuggerRunControl;
|
||||||
class DebuggerStartParameters;
|
class DebuggerStartParameters;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal { class DebuggerRunControlFactory; }
|
||||||
class DebuggerRunControlPrivate;
|
|
||||||
class DebuggerRunControlFactory;
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerRunControl
|
class DEBUGGER_EXPORT DebuggerRunControl
|
||||||
: public ProjectExplorer::RunControl
|
: public ProjectExplorer::RunControl
|
||||||
@@ -55,8 +49,6 @@ class DEBUGGER_EXPORT DebuggerRunControl
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
|
|
||||||
const DebuggerStartParameters &sp);
|
|
||||||
~DebuggerRunControl();
|
~DebuggerRunControl();
|
||||||
|
|
||||||
// ProjectExplorer::RunControl
|
// ProjectExplorer::RunControl
|
||||||
@@ -80,8 +72,12 @@ private slots:
|
|||||||
void handleFinished();
|
void handleFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//friend class Internal::DebuggerRunControlFactory;
|
friend class Internal::DebuggerRunControlFactory;
|
||||||
Internal::DebuggerRunControlPrivate *d;
|
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerEngine *engine);
|
||||||
|
|
||||||
|
DebuggerEngine *m_engine;
|
||||||
|
const QPointer<ProjectExplorer::RunConfiguration> m_runConfiguration;
|
||||||
|
bool m_running;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
Reference in New Issue
Block a user