Commit 8184d8e7 authored by hjk's avatar hjk

debugger: simplify DebuggerEngine construction

The master engine pointer can be given later.

Change-Id: I4d72679dcbd5fe7291067a5e78c984d26cc187aa
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 081fb1f0
......@@ -327,8 +327,7 @@ static inline bool validMode(DebuggerStartMode sm)
}
// Accessed by RunControlFactory
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine, QString *errorMessage)
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *errorMessage)
{
#ifdef Q_OS_WIN
CdbOptionsPage *op = CdbOptionsPage::instance();
......@@ -336,9 +335,8 @@ DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp,
*errorMessage = QLatin1String("Internal error: Invalid start parameters passed for thre CDB engine.");
return 0;
}
return new CdbEngine(sp, masterEngine, op->options());
return new CdbEngine(sp, op->options());
#else
Q_UNUSED(masterEngine)
Q_UNUSED(sp)
#endif
*errorMessage = QString::fromLatin1("Unsupported debug mode");
......@@ -426,9 +424,8 @@ static inline Utils::SavedAction *theAssemblerAction()
return debuggerCore()->action(OperateByInstruction);
}
CdbEngine::CdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine, const OptionsPtr &options) :
DebuggerEngine(sp, masterEngine),
CdbEngine::CdbEngine(const DebuggerStartParameters &sp, const OptionsPtr &options) :
DebuggerEngine(sp),
m_creatorExtPrefix("<qtcreatorcdbext>|"),
m_tokenPrefix("<token>"),
m_options(options),
......
......@@ -79,11 +79,9 @@ public:
typedef void (CdbEngine::*BuiltinCommandHandler)(const CdbBuiltinCommandPtr &);
typedef void (CdbEngine::*ExtensionCommandHandler)(const CdbExtensionCommandPtr &);
explicit CdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine,
const OptionsPtr &options);
CdbEngine(const DebuggerStartParameters &sp, const OptionsPtr &options);
~CdbEngine();
virtual ~CdbEngine();
// Factory function that returns 0 if the debug engine library cannot be found.
virtual bool setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor,
......
......@@ -153,11 +153,9 @@ class DebuggerEnginePrivate : public QObject
Q_OBJECT
public:
DebuggerEnginePrivate(DebuggerEngine *engine,
DebuggerEngine *masterEngine,
const DebuggerStartParameters &sp)
DebuggerEnginePrivate(DebuggerEngine *engine, const DebuggerStartParameters &sp)
: m_engine(engine),
m_masterEngine(masterEngine),
m_masterEngine(0),
m_runControl(0),
m_startParameters(sp),
m_state(DebuggerNotReady),
......@@ -330,9 +328,8 @@ public:
//
//////////////////////////////////////////////////////////////////////
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *parentEngine)
: d(new DebuggerEnginePrivate(this, parentEngine, startParameters))
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters)
: d(new DebuggerEnginePrivate(this, startParameters))
{}
DebuggerEngine::~DebuggerEngine()
......@@ -1264,6 +1261,11 @@ bool DebuggerEngine::isMasterEngine() const
return d->m_masterEngine == 0;
}
void DebuggerEngine::setMasterEngine(DebuggerEngine *masterEngine)
{
d->m_masterEngine = masterEngine;
}
DebuggerEngine *DebuggerEngine::masterEngine() const
{
return d->m_masterEngine;
......
......@@ -139,8 +139,7 @@ class DEBUGGER_EXPORT DebuggerEngine : public QObject
Q_OBJECT
public:
explicit DebuggerEngine(const DebuggerStartParameters &sp,
DebuggerEngine *parentEngine = 0);
explicit DebuggerEngine(const DebuggerStartParameters &sp);
virtual ~DebuggerEngine();
const DebuggerStartParameters &startParameters() const;
......@@ -360,6 +359,7 @@ protected:
virtual void frameDown();
void setTargetState(DebuggerState state);
void setMasterEngine(DebuggerEngine *masterEngine);
DebuggerRunControl *runControl() const;
......
......@@ -57,7 +57,6 @@ public:
static DebuggerEngine *createEngine(DebuggerEngineType et,
const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine,
QString *errorMessage);
static DebuggerRunControl *createAndScheduleRun(
......
......@@ -42,7 +42,6 @@
#include "debuggerprofileinformation.h"
#include "lldb/lldbenginehost.h"
#include "debuggertooltipmanager.h"
#include "qml/qmlengine.h"
#ifdef Q_OS_WIN
# include "peutils.h"
......@@ -85,19 +84,14 @@ namespace Internal {
bool isCdbEngineEnabled(); // Check the configuration page
//bool checkCdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck *check);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine, QString *error);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *error);
//bool checkGdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck *check);
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine);
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createScriptEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &sp);
QmlEngine *createQmlEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
QString *errorMessage);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &sp);
extern QString msgNoBinaryForToolChain(const Abi &abi);
......@@ -326,7 +320,7 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
// 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, 0, &errorMessage);
d->m_engine = DebuggerRunControlFactory::createEngine(sp.masterEngineType, sp, &errorMessage);
if (d->m_engine) {
DebuggerToolTipManager::instance()->registerEngine(d->m_engine);
......@@ -757,23 +751,20 @@ RunConfigWidget *DebuggerRunControlFactory::createConfigurationWidget
return new DebuggerRunConfigWidget(runConfiguration);
}
DebuggerEngine *DebuggerRunControlFactory::createEngine
(DebuggerEngineType et,
const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine,
QString *errorMessage)
DebuggerEngine *DebuggerRunControlFactory::createEngine(DebuggerEngineType et,
const DebuggerStartParameters &sp, QString *errorMessage)
{
switch (et) {
case GdbEngineType:
return createGdbEngine(sp, masterEngine);
return createGdbEngine(sp);
case ScriptEngineType:
return createScriptEngine(sp);
case CdbEngineType:
return createCdbEngine(sp, masterEngine, errorMessage);
return createCdbEngine(sp, errorMessage);
case PdbEngineType:
return createPdbEngine(sp);
case QmlEngineType:
return createQmlEngine(sp, masterEngine);
return createQmlEngine(sp);
case LldbEngineType:
return createLldbEngine(sp);
case QmlCppEngineType:
......
......@@ -49,9 +49,8 @@ namespace Internal {
static_cast<GdbEngine::GdbCommandCallback>(&GdbAbstractPlainEngine::callback), \
STRINGIFY(callback)
GdbAbstractPlainEngine::GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine)
GdbAbstractPlainEngine::GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{}
void GdbAbstractPlainEngine::setupInferior()
......
......@@ -42,8 +42,7 @@ class GdbAbstractPlainEngine : public GdbEngine
Q_OBJECT
public:
GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbAbstractPlainEngine(const DebuggerStartParameters &startParameters);
void setupInferior();
void runEngine();
......
......@@ -52,9 +52,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbAttachEngine::GdbAttachEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine)
GdbAttachEngine::GdbAttachEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{
}
......
......@@ -48,8 +48,7 @@ class GdbAttachEngine : public GdbEngine
Q_OBJECT
public:
GdbAttachEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbAttachEngine(const DebuggerStartParameters &startParameters);
private:
DumperHandling dumperHandling() const { return DumperLoadedByGdb; }
......
......@@ -116,9 +116,8 @@ static inline QString startMsg(const Coda::Session &session)
* - Stop all threads once one stops?
* - Breakpoints do not trigger in threads other than the main thread. */
GdbCodaEngine:: GdbCodaEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine),
GdbCodaEngine:: GdbCodaEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters),
m_running(false),
m_stopReason(0),
m_gdbAckMode(true),
......
......@@ -80,8 +80,7 @@ public:
typedef Coda::Callback<const Coda::CodaCommandResult &> CodaCallback;
typedef Coda::Callback<const GdbResponse &> GdbCallback;
GdbCodaEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbCodaEngine(const DebuggerStartParameters &startParameters);
~GdbCodaEngine();
void setGdbServerName(const QString &name);
......
......@@ -63,9 +63,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbCoreEngine::GdbCoreEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine)
GdbCoreEngine::GdbCoreEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{}
GdbCoreEngine::~GdbCoreEngine()
......
......@@ -48,8 +48,7 @@ class GdbCoreEngine : public GdbEngine
Q_OBJECT
public:
GdbCoreEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbCoreEngine(const DebuggerStartParameters &startParameters);
~GdbCoreEngine();
private:
......
......@@ -237,9 +237,8 @@ private:
//
///////////////////////////////////////////////////////////////////////
GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: DebuggerEngine(startParameters, masterEngine)
GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters)
{
setObjectName(_("GdbEngine"));
......@@ -5399,27 +5398,24 @@ void GdbEngine::interruptLocalInferior(qint64 pid)
// Factory
//
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine)
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp)
{
if (sp.toolChainAbi.os() == Abi::SymbianOS) {
// FIXME: 1 of 3 testing hacks.
return new GdbCodaEngine(sp, masterEngine);
}
if (sp.toolChainAbi.os() == Abi::SymbianOS)
return new GdbCodaEngine(sp);
switch (sp.startMode) {
case AttachCore:
return new GdbCoreEngine(sp, masterEngine);
return new GdbCoreEngine(sp);
case AttachToRemoteServer:
return new GdbRemoteServerEngine(sp, masterEngine);
return new GdbRemoteServerEngine(sp);
case StartRemoteGdb:
return new GdbRemotePlainEngine(sp, masterEngine);
return new GdbRemotePlainEngine(sp);
case AttachExternal:
return new GdbAttachEngine(sp, masterEngine);
return new GdbAttachEngine(sp);
default:
if (sp.useTerminal)
return new GdbTermEngine(sp, masterEngine);
return new GdbLocalPlainEngine(sp, masterEngine);
return new GdbTermEngine(sp);
return new GdbLocalPlainEngine(sp);
}
}
......
......@@ -195,8 +195,7 @@ class GdbEngine : public Debugger::DebuggerEngine
Q_OBJECT
public:
GdbEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbEngine(const DebuggerStartParameters &startParameters);
~GdbEngine();
private: ////////// General Interface //////////
......
......@@ -51,9 +51,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbLocalPlainEngine::GdbLocalPlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbAbstractPlainEngine(startParameters, masterEngine)
GdbLocalPlainEngine::GdbLocalPlainEngine(const DebuggerStartParameters &startParameters)
: GdbAbstractPlainEngine(startParameters)
{
// Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
......
......@@ -49,8 +49,7 @@ class GdbLocalPlainEngine : public GdbAbstractPlainEngine
Q_OBJECT
public:
GdbLocalPlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbLocalPlainEngine(const DebuggerStartParameters &startParameters);
private:
void setupEngine();
......
......@@ -57,9 +57,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine)
GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{
connect(&m_uploadProc, SIGNAL(error(QProcess::ProcessError)),
SLOT(uploadProcError(QProcess::ProcessError)));
......
......@@ -48,8 +48,7 @@ class GdbRemoteServerEngine : public GdbEngine
Q_OBJECT
public:
GdbRemoteServerEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbRemoteServerEngine(const DebuggerStartParameters &startParameters);
private:
DumperHandling dumperHandling() const;
......
......@@ -39,9 +39,8 @@
namespace Debugger {
namespace Internal {
GdbRemotePlainEngine::GdbRemotePlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbAbstractPlainEngine(startParameters, masterEngine),
GdbRemotePlainEngine::GdbRemotePlainEngine(const DebuggerStartParameters &startParameters)
: GdbAbstractPlainEngine(startParameters),
m_gdbProc(startParameters.connParams, this)
{
connect(&m_gdbProc, SIGNAL(started()), this, SLOT(handleGdbStarted()));
......
......@@ -43,8 +43,7 @@ class GdbRemotePlainEngine : public GdbAbstractPlainEngine
public:
friend class RemoteGdbProcess;
GdbRemotePlainEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbRemotePlainEngine(const DebuggerStartParameters &startParameters);
private slots:
void handleGdbStarted();
......
......@@ -56,9 +56,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbTermEngine::GdbTermEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: GdbEngine(startParameters, masterEngine)
GdbTermEngine::GdbTermEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
{
#ifdef Q_OS_WIN
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
......
......@@ -50,9 +50,7 @@ class GdbTermEngine : public GdbEngine
Q_OBJECT
public:
GdbTermEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit GdbTermEngine(const DebuggerStartParameters &startParameters);
~GdbTermEngine();
private:
......
......@@ -54,9 +54,6 @@ enum { debug = 0 };
const int ConnectionWaitTimeMs = 5000;
QmlEngine *createQmlEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
QString *errorMessage)
{
......@@ -74,32 +71,17 @@ DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
//
////////////////////////////////////////////////////////////////////////
class QmlCppEnginePrivate : public QObject
class QmlCppEnginePrivate
{
Q_OBJECT
public:
QmlCppEnginePrivate(QmlCppEngine *parent,
const DebuggerStartParameters &sp);
~QmlCppEnginePrivate() {}
QmlCppEnginePrivate() {}
private:
friend class QmlCppEngine;
QmlCppEngine *q;
QmlEngine *m_qmlEngine;
DebuggerEngine *m_cppEngine;
DebuggerEngine *m_activeEngine;
};
QmlCppEnginePrivate::QmlCppEnginePrivate(QmlCppEngine *parent,
const DebuggerStartParameters &sp)
: q(parent), m_qmlEngine(createQmlEngine(sp, q)),
m_cppEngine(0), m_activeEngine(0)
{
setObjectName(QLatin1String("QmlCppEnginePrivate"));
}
////////////////////////////////////////////////////////////////////////
//
// QmlCppEngine
......@@ -107,10 +89,14 @@ QmlCppEnginePrivate::QmlCppEnginePrivate(QmlCppEngine *parent,
////////////////////////////////////////////////////////////////////////
QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp, QString *errorMessage)
: DebuggerEngine(sp), d(new QmlCppEnginePrivate(this, sp))
: DebuggerEngine(sp)
{
setObjectName(QLatin1String("QmlCppEngine"));
d->m_cppEngine = DebuggerRunControlFactory::createEngine(sp.firstSlaveEngineType, sp, this, errorMessage);
d = new QmlCppEnginePrivate;
d->m_qmlEngine = new QmlEngine(sp);
d->m_qmlEngine->setMasterEngine(this);
d->m_cppEngine = DebuggerRunControlFactory::createEngine(sp.firstSlaveEngineType, sp, errorMessage);
d->m_cppEngine->setMasterEngine(this);
if (!d->m_cppEngine) {
*errorMessage = tr("The slave debugging engine required for combined QML/C++-Debugging could not be created: %1").arg(*errorMessage);
return;
......@@ -831,5 +817,3 @@ void QmlCppEngine::setActiveEngine(DebuggerEngine *engine)
} // namespace Internal
} // namespace Debugger
#include "qmlcppengine.moc"
......@@ -266,9 +266,8 @@ public:
//
///////////////////////////////////////////////////////////////////////
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: DebuggerEngine(startParameters, masterEngine)
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters)
, m_adapter(this)
, m_inspectorAdapter(&m_adapter, this)
, m_retryOnConnectFail(false)
......@@ -1343,10 +1342,9 @@ bool QmlEngine::adjustBreakpointLineAndColumn(
return success;
}
QmlEngine *createQmlEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine)
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
{
return new QmlEngine(sp, masterEngine);
return new QmlEngine(sp);
}
} // namespace Internal
......
......@@ -60,8 +60,7 @@ class QmlEngine : public DebuggerEngine
Q_OBJECT
public:
QmlEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
explicit QmlEngine(const DebuggerStartParameters &startParameters);
~QmlEngine();
void notifyEngineRemoteSetupDone(int gdbServerPort, int qmlPort);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment