Commit 6dd55aa4 authored by hjk's avatar hjk

debugger: introduce generic master/slaves engine

parent eb701fc7
......@@ -262,7 +262,8 @@ static inline QString msgCdbDisabled(ToolChainType tc)
}
// Accessed by RunControlFactory
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *errorMessage)
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine, QString *errorMessage)
{
#ifdef Q_OS_WIN
CdbOptionsPage *op = CdbOptionsPage::instance();
......@@ -274,11 +275,12 @@ DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *erro
*errorMessage = CdbEngine::tr("The CDB debug engine does not support start mode %1.").arg(sp.startMode);
return 0;
}
return new CdbEngine(sp, op->options());
return new CdbEngine(sp, masterEngine, op->options());
#else
Q_UNUSED(masterEngine)
Q_UNUSED(sp)
#endif
*errorMessage = QString::fromLatin1("Unsuppported debug mode");
*errorMessage = QString::fromLatin1("Unsupported debug mode");
return 0;
}
......@@ -315,9 +317,13 @@ ConfigurationCheck checkCdbConfiguration(ToolChainType toolChain)
return check;
}
void addCdb2OptionPages(QList<Core::IOptionsPage *> *opts)
void addCdbOptionPages(QList<Core::IOptionsPage *> *opts)
{
#ifdef Q_OS_WIN
opts->push_back(new CdbOptionsPage);
#else
Q_UNUSED(opts);
#endif
}
#define QT_CREATOR_CDB_EXT "qtcreatorcdbext"
......@@ -327,8 +333,9 @@ static inline Utils::SavedAction *theAssemblerAction()
return debuggerCore()->action(OperateByInstruction);
}
CdbEngine::CdbEngine(const DebuggerStartParameters &sp, const OptionsPtr &options) :
DebuggerEngine(sp),
CdbEngine::CdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine, const OptionsPtr &options) :
DebuggerEngine(sp, masterEngine),
m_creatorExtPrefix("<qtcreatorcdbext>|"),
m_tokenPrefix("<token>"),
m_options(options),
......
......@@ -72,7 +72,10 @@ public:
typedef void (CdbEngine::*BuiltinCommandHandler)(const CdbBuiltinCommandPtr &);
typedef void (CdbEngine::*ExtensionCommandHandler)(const CdbExtensionCommandPtr &);
explicit CdbEngine(const DebuggerStartParameters &sp, const OptionsPtr &options);
explicit CdbEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine,
const OptionsPtr &options);
virtual ~CdbEngine();
// Factory function that returns 0 if the debug engine library cannot be found.
......
......@@ -165,8 +165,11 @@ class DebuggerEnginePrivate : public QObject
Q_OBJECT
public:
DebuggerEnginePrivate(DebuggerEngine *engine, const DebuggerStartParameters &sp)
DebuggerEnginePrivate(DebuggerEngine *engine,
DebuggerEngine *masterEngine,
const DebuggerStartParameters &sp)
: m_engine(engine),
m_masterEngine(masterEngine),
m_runControl(0),
m_startParameters(sp),
m_state(DebuggerNotReady),
......@@ -178,7 +181,6 @@ public:
m_stackHandler(),
m_threadsHandler(),
m_watchHandler(engine),
m_isSlaveEngine(false),
m_disassemblerAgent(engine),
m_memoryAgent(engine)
{
......@@ -250,6 +252,7 @@ public:
DebuggerState state() const { return m_state; }
DebuggerEngine *m_engine; // Not owned.
DebuggerEngine *m_masterEngine; // Not owned
DebuggerRunControl *m_runControl; // Not owned.
DebuggerStartParameters m_startParameters;
......@@ -273,7 +276,6 @@ public:
WatchHandler m_watchHandler;
QFutureInterface<void> m_progress;
bool m_isSlaveEngine;
DisassemblerAgent m_disassemblerAgent;
MemoryAgent m_memoryAgent;
QScopedPointer<TextEditor::BaseTextMark> m_locationMark;
......@@ -287,8 +289,9 @@ public:
//
//////////////////////////////////////////////////////////////////////
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters)
: d(new DebuggerEnginePrivate(this, startParameters))
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *parentEngine)
: d(new DebuggerEnginePrivate(this, parentEngine, startParameters))
{
}
......@@ -354,37 +357,49 @@ void DebuggerEngine::frameDown()
ModulesHandler *DebuggerEngine::modulesHandler() const
{
return &d->m_modulesHandler;
return d->m_masterEngine
? d->m_masterEngine->modulesHandler()
: &d->m_modulesHandler;
}
RegisterHandler *DebuggerEngine::registerHandler() const
{
return &d->m_registerHandler;
return d->m_masterEngine
? d->m_masterEngine->registerHandler()
: &d->m_registerHandler;
}
StackHandler *DebuggerEngine::stackHandler() const
{
return &d->m_stackHandler;
return d->m_masterEngine
? d->m_masterEngine->stackHandler()
: &d->m_stackHandler;
}
ThreadsHandler *DebuggerEngine::threadsHandler() const
{
return &d->m_threadsHandler;
return d->m_masterEngine
? d->m_masterEngine->threadsHandler()
: &d->m_threadsHandler;
}
WatchHandler *DebuggerEngine::watchHandler() const
{
return &d->m_watchHandler;
return d->m_masterEngine
? d->m_masterEngine->watchHandler()
: &d->m_watchHandler;
}
SourceFilesHandler *DebuggerEngine::sourceFilesHandler() const
{
return &d->m_sourceFilesHandler;
return d->m_masterEngine
? d->m_masterEngine->sourceFilesHandler()
: &d->m_sourceFilesHandler;
}
QAbstractItemModel *DebuggerEngine::modulesModel() const
{
QAbstractItemModel *model = d->m_modulesHandler.model();
QAbstractItemModel *model = modulesHandler()->model();
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("ModulesModel"));
return model;
......@@ -392,7 +407,7 @@ QAbstractItemModel *DebuggerEngine::modulesModel() const
QAbstractItemModel *DebuggerEngine::registerModel() const
{
QAbstractItemModel *model = d->m_registerHandler.model();
QAbstractItemModel *model = registerHandler()->model();
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("RegisterModel"));
return model;
......@@ -400,7 +415,7 @@ QAbstractItemModel *DebuggerEngine::registerModel() const
QAbstractItemModel *DebuggerEngine::stackModel() const
{
QAbstractItemModel *model = d->m_stackHandler.model();
QAbstractItemModel *model = stackHandler()->model();
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("StackModel"));
return model;
......@@ -408,7 +423,7 @@ QAbstractItemModel *DebuggerEngine::stackModel() const
QAbstractItemModel *DebuggerEngine::threadsModel() const
{
QAbstractItemModel *model = d->m_threadsHandler.model();
QAbstractItemModel *model = threadsHandler()->model();
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("ThreadsModel"));
return model;
......@@ -416,7 +431,7 @@ QAbstractItemModel *DebuggerEngine::threadsModel() const
QAbstractItemModel *DebuggerEngine::localsModel() const
{
QAbstractItemModel *model = d->m_watchHandler.model(LocalsWatch);
QAbstractItemModel *model = watchHandler()->model(LocalsWatch);
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("LocalsModel"));
return model;
......@@ -424,7 +439,7 @@ QAbstractItemModel *DebuggerEngine::localsModel() const
QAbstractItemModel *DebuggerEngine::watchersModel() const
{
QAbstractItemModel *model = d->m_watchHandler.model(WatchersWatch);
QAbstractItemModel *model = watchHandler()->model(WatchersWatch);
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("WatchersModel"));
return model;
......@@ -432,7 +447,7 @@ QAbstractItemModel *DebuggerEngine::watchersModel() const
QAbstractItemModel *DebuggerEngine::returnModel() const
{
QAbstractItemModel *model = d->m_watchHandler.model(ReturnWatch);
QAbstractItemModel *model = watchHandler()->model(ReturnWatch);
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("ReturnModel"));
return model;
......@@ -440,7 +455,7 @@ QAbstractItemModel *DebuggerEngine::returnModel() const
QAbstractItemModel *DebuggerEngine::sourceFilesModel() const
{
QAbstractItemModel *model = d->m_sourceFilesHandler.model();
QAbstractItemModel *model = sourceFilesHandler()->model();
if (model->objectName().isEmpty()) // Make debugging easier.
model->setObjectName(objectName() + QLatin1String("SourceFilesModel"));
return model;
......@@ -1039,12 +1054,7 @@ void DebuggerEngine::updateViews()
bool DebuggerEngine::isSlaveEngine() const
{
return d->m_isSlaveEngine;
}
void DebuggerEngine::setSlaveEngine(bool value)
{
d->m_isSlaveEngine = value;
return d->m_masterEngine != 0;
}
bool DebuggerEngine::debuggerActionsEnabled() const
......
......@@ -129,7 +129,8 @@ class DEBUGGER_EXPORT DebuggerEngine : public QObject
Q_OBJECT
public:
explicit DebuggerEngine(const DebuggerStartParameters &sp);
explicit DebuggerEngine(const DebuggerStartParameters &sp,
DebuggerEngine *parentEngine = 0);
virtual ~DebuggerEngine();
typedef Internal::BreakpointId BreakpointId;
......@@ -138,7 +139,7 @@ public:
virtual void updateWatchData(const Internal::WatchData &data,
const Internal::WatchUpdateFlags & flags = Internal::WatchUpdateFlags());
void startDebugger(DebuggerRunControl *runControl);
virtual void startDebugger(DebuggerRunControl *runControl);
virtual void watchPoint(const QPoint &);
virtual void openMemoryView(quint64 addr);
......@@ -213,13 +214,13 @@ public:
const DebuggerStartParameters &startParameters() const;
DebuggerStartParameters &startParameters();
Internal::ModulesHandler *modulesHandler() const;
Internal::RegisterHandler *registerHandler() const;
Internal::StackHandler *stackHandler() const;
Internal::ThreadsHandler *threadsHandler() const;
Internal::WatchHandler *watchHandler() const;
Internal::SourceFilesHandler *sourceFilesHandler() const;
Internal::BreakHandler *breakHandler() const;
virtual Internal::ModulesHandler *modulesHandler() const;
virtual Internal::RegisterHandler *registerHandler() const;
virtual Internal::StackHandler *stackHandler() const;
virtual Internal::ThreadsHandler *threadsHandler() const;
virtual Internal::WatchHandler *watchHandler() const;
virtual Internal::SourceFilesHandler *sourceFilesHandler() const;
virtual Internal::BreakHandler *breakHandler() const;
virtual QAbstractItemModel *modulesModel() const;
virtual QAbstractItemModel *registerModel() const;
......@@ -345,7 +346,7 @@ private:
// Wrapper engine needs access to state of its subengines.
friend class Internal::QmlCppEngine;
void setState(DebuggerState state, bool forced = false);
void setSlaveEngine(bool value);
//void setSlaveEngine(bool value);
friend class DebuggerEnginePrivate;
DebuggerEnginePrivate *d;
......
......@@ -405,11 +405,6 @@ const char * const SNAPSHOT_KEY = "Ctrl+D,Ctrl+S";
} // namespace Constants
namespace Internal {
void addCdb2OptionPages(QList<Core::IOptionsPage*> *);
} // namespace Cdb
namespace Internal {
// FIXME: Outdated?
......@@ -418,6 +413,7 @@ namespace Internal {
// of the engine. That's good for not enabling the related ActiveX control
// unnecessarily.
void addCdbOptionPages(QList<IOptionsPage*> *opts);
void addGdbOptionPages(QList<IOptionsPage*> *opts);
void addScriptOptionPages(QList<IOptionsPage*> *opts);
void addTcfOptionPages(QList<IOptionsPage*> *opts);
......@@ -1094,7 +1090,6 @@ public slots:
void handleExecStep()
{
qDebug() << "CURRENT: " << currentEngine();
currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction))
currentEngine()->executeStepI();
......@@ -1965,7 +1960,6 @@ void DebuggerPluginPrivate::startDebugger(RunControl *rc)
void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
{
qDebug() << "CONNECT: " << engine;
if (!engine)
engine = dummyEngine();
......@@ -3020,9 +3014,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
QList<Core::IOptionsPage *> engineOptionPages;
if (m_cmdLineEnabledEngines & GdbEngineType)
addGdbOptionPages(&engineOptionPages);
#ifdef Q_OS_WIN
addCdb2OptionPages(&engineOptionPages);
#endif
addCdbOptionPages(&engineOptionPages);
#ifdef WITH_LLDB
if (m_cmdLineEnabledEngines & LldbEngineType)
addLldbOptionPages(&engineOptionPages);
......
......@@ -70,20 +70,20 @@ using namespace ProjectExplorer;
using namespace Debugger::Internal;
namespace Debugger {
namespace Internal {
bool isCdbEngineEnabled(); // Check the configuration page
ConfigurationCheck checkCdbConfiguration(ToolChainType toolChain);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &, QString *error);
}
namespace Internal {
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine, QString *error);
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine);
DebuggerEngine *createScriptEngine(const DebuggerStartParameters &);
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &);
DebuggerEngine *createTcfEngine(const DebuggerStartParameters &);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &);
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &);
......@@ -315,13 +315,13 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
switch (engineType) {
case GdbEngineType:
d->m_engine = createGdbEngine(sp);
d->m_engine = createGdbEngine(sp, 0);
break;
case ScriptEngineType:
d->m_engine = createScriptEngine(sp);
break;
case CdbEngineType:
d->m_engine = Internal::createCdbEngine(sp, &d->m_errorMessage);
d->m_engine = createCdbEngine(sp, 0, &d->m_errorMessage);
break;
case PdbEngineType:
d->m_engine = createPdbEngine(sp);
......@@ -330,7 +330,7 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
d->m_engine = createTcfEngine(sp);
break;
case QmlEngineType:
d->m_engine = createQmlEngine(sp);
d->m_engine = createQmlEngine(sp, 0);
break;
case QmlCppEngineType:
d->m_engine = createQmlCppEngine(sp);
......@@ -406,7 +406,7 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(ToolChainType toolCha
}
break;
case ToolChain_MSVC:
result = Internal::checkCdbConfiguration(toolChain);
result = checkCdbConfiguration(toolChain);
if (!result) {
result.errorMessage += msgEngineNotAvailable("Cdb");
result.settingsPage = QLatin1String("Cdb");
......
......@@ -176,8 +176,9 @@ static QByteArray parsePlainConsoleStream(const GdbResponse &response)
//
///////////////////////////////////////////////////////////////////////
GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters)
GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: DebuggerEngine(startParameters, masterEngine)
{
setObjectName(QLatin1String("GdbEngine"));
......@@ -4495,9 +4496,10 @@ void GdbEngine::handleRemoteSetupFailed(const QString &message)
// Factory
//
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &startParameters)
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
{
return new GdbEngine(startParameters);
return new GdbEngine(startParameters, masterEngine);
}
void addGdbOptionPages(QList<Core::IOptionsPage *> *opts)
......
......@@ -70,7 +70,6 @@ class CoreGdbAdapter;
class LocalPlainGdbAdapter;
class RemoteGdbServerAdapter;
class TrkGdbAdapter;
class QmlCppEngine;
enum DebuggingHelperState
{
......@@ -86,7 +85,8 @@ class GdbEngine : public Debugger::DebuggerEngine
Q_OBJECT
public:
explicit GdbEngine(const DebuggerStartParameters &startParameters);
GdbEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
~GdbEngine();
AbstractGdbAdapter *gdbAdapter() const { return m_gdbAdapter; }
......@@ -101,7 +101,6 @@ private:
friend class RemotePlainGdbAdapter;
friend class TrkGdbAdapter;
friend class TcfTrkGdbAdapter;
friend class QmlCppEngine;
private: ////////// General Interface //////////
......
......@@ -4,8 +4,6 @@
#include "debuggermainwindow.h"
#include "debuggercore.h"
#include "gdb/gdbengine.h"
#include <qmljseditor/qmljseditorconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
......@@ -14,18 +12,18 @@
namespace Debugger {
namespace Internal {
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &, QString *);
}
namespace Internal {
const int ConnectionWaitTimeMs = 5000;
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine, QString *);
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &,
DebuggerEngine *masterEngine);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp)
{
qDebug() << "CREATING QMLCPPENGINE";
QmlCppEngine *newEngine = new QmlCppEngine(sp);
if (newEngine->cppEngine())
return newEngine;
......@@ -58,22 +56,19 @@ QmlCppEnginePrivate::QmlCppEnginePrivate()
QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp)
: DebuggerEngine(sp), d(new QmlCppEnginePrivate)
{
d->m_qmlEngine = createQmlEngine(sp);
d->m_qmlEngine = createQmlEngine(sp, this);
if (startParameters().cppEngineType == GdbEngineType) {
d->m_cppEngine = createGdbEngine(sp);
d->m_cppEngine = createGdbEngine(sp, this);
} else {
QString errorMessage;
d->m_cppEngine = Debugger::Internal::createCdbEngine(sp, &errorMessage);
d->m_cppEngine = Debugger::Internal::createCdbEngine(sp, this, &errorMessage);
if (!d->m_cppEngine) {
qWarning("%s", qPrintable(errorMessage));
return;
}
}
d->m_cppEngine->setSlaveEngine(true);
d->m_qmlEngine->setSlaveEngine(true);
d->m_activeEngine = d->m_cppEngine;
connect(d->m_cppEngine, SIGNAL(stateChanged(DebuggerState)),
SLOT(masterEngineStateChanged(DebuggerState)));
......@@ -122,7 +117,7 @@ void QmlCppEngine::setActiveEngine(DebuggerLanguage language)
}
if (previousEngine != d->m_activeEngine) {
showStatusMessage(tr("%1 debugger activated").arg(engineName));
//debuggerCore()->displayDebugger(d->m_activeEngine, updateEngine);
debuggerCore()->displayDebugger(d->m_activeEngine, updateEngine);
}
}
......@@ -310,18 +305,7 @@ void QmlCppEngine::detachDebugger()
void QmlCppEngine::executeStep()
{
qDebug() << "CPP ENGINE: " << d->m_cppEngine;
if (d->m_activeEngine == d->m_cppEngine) {
d->m_cppEngine->executeStep();
} else {
QByteArray ba =
"-break-insert -f 'myns::QScript::FunctionWrapper::proxyCall'";
GdbEngine *cppEngine = qobject_cast<GdbEngine *>(d->m_cppEngine);
qDebug() << "CPP ENGINE: " << cppEngine << d->m_cppEngine;
if (cppEngine)
cppEngine->postCommand(ba);
d->m_qmlEngine->executeStep();
}
d->m_activeEngine->executeStep();
}
void QmlCppEngine::executeStepOut()
......@@ -331,14 +315,12 @@ void QmlCppEngine::executeStepOut()
void QmlCppEngine::executeNext()
{
qDebug() << "NEXT";
d->m_activeEngine->executeNext();
}
void QmlCppEngine::executeStepI()
{
qDebug() << "STEP I";
d->m_activeEngine->executeStep();
d->m_activeEngine->executeStepI();
}
void QmlCppEngine::executeNextI()
......
......@@ -172,8 +172,10 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q)
//
///////////////////////////////////////////////////////////////////////
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters), d(new QmlEnginePrivate(this))
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine)
: DebuggerEngine(startParameters, masterEngine),
d(new QmlEnginePrivate(this))
{
setObjectName(QLatin1String("QmlEngine"));
}
......@@ -645,11 +647,6 @@ void QmlEngine::sendPing()
sendMessage(reply);
}
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
{
return new QmlEngine(sp);
}
unsigned QmlEngine::debuggerCapabilities() const
{
return AddWatcherCapability;
......@@ -934,6 +931,12 @@ void QmlEngine::logMessage(LogDirection direction, const QString &message)
showMessage(msg, LogDebug);
}
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp,
DebuggerEngine *masterEngine)
{
return new QmlEngine(sp, masterEngine);
}
} // namespace Internal
} // namespace Debugger
......@@ -51,7 +51,8 @@ class QmlEngine : public DebuggerEngine
Q_OBJECT
public:
explicit QmlEngine(const DebuggerStartParameters &startParameters);
QmlEngine(const DebuggerStartParameters &startParameters,
DebuggerEngine *masterEngine);
~QmlEngine();
void handleRemoteSetupDone(int port);
......
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