Commit 83df6206 authored by hjk's avatar hjk
Browse files

Debugger: Remove QmlCppEnginePrivate



No need for a pimpl containing three pointers in an
internal class.

Change-Id: Iabafa5da4a684099cbfd3e945a642929a2cecf50
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent dcedc454
......@@ -58,23 +58,6 @@ DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
}
////////////////////////////////////////////////////////////////////////
//
// QmlCppEnginePrivate
//
////////////////////////////////////////////////////////////////////////
class QmlCppEnginePrivate
{
public:
QmlCppEnginePrivate() {}
QmlEngine *m_qmlEngine;
DebuggerEngine *m_cppEngine;
DebuggerEngine *m_activeEngine;
};
////////////////////////////////////////////////////////////////////////
//
// QmlCppEngine
......@@ -85,27 +68,25 @@ QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp, QString *errorMess
: DebuggerEngine(sp)
{
setObjectName(QLatin1String("QmlCppEngine"));
d = new QmlCppEnginePrivate;
d->m_qmlEngine = new QmlEngine(sp, this);
d->m_cppEngine = DebuggerRunControlFactory::createEngine(sp.firstSlaveEngineType, sp, errorMessage);
if (!d->m_cppEngine) {
m_qmlEngine = new QmlEngine(sp, this);
m_cppEngine = DebuggerRunControlFactory::createEngine(sp.firstSlaveEngineType, sp, errorMessage);
if (!m_cppEngine) {
*errorMessage = tr("The slave debugging engine required for combined QML/C++-Debugging could not be created: %1").arg(*errorMessage);
return;
}
d->m_cppEngine->setMasterEngine(this);
setActiveEngine(d->m_cppEngine);
m_cppEngine->setMasterEngine(this);
setActiveEngine(m_cppEngine);
}
QmlCppEngine::~QmlCppEngine()
{
delete d->m_qmlEngine;
delete d->m_cppEngine;
delete d;
delete m_qmlEngine;
delete m_cppEngine;
}
bool QmlCppEngine::canDisplayTooltip() const
{
return d->m_cppEngine->canDisplayTooltip() || d->m_qmlEngine->canDisplayTooltip();
return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip();
}
bool QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
......@@ -114,9 +95,9 @@ bool QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
QTC_ASSERT(editor, return false);
bool success = false;
if (editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID)
success = d->m_cppEngine->setToolTipExpression(mousePos, editor, ctx);
success = m_cppEngine->setToolTipExpression(mousePos, editor, ctx);
else if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
success = d->m_qmlEngine->setToolTipExpression(mousePos, editor, ctx);
success = m_qmlEngine->setToolTipExpression(mousePos, editor, ctx);
return success;
}
......@@ -124,32 +105,32 @@ void QmlCppEngine::updateWatchData(const WatchData &data,
const WatchUpdateFlags &flags)
{
if (data.isInspect())
d->m_qmlEngine->updateWatchData(data, flags);
m_qmlEngine->updateWatchData(data, flags);
else
d->m_activeEngine->updateWatchData(data, flags);
m_activeEngine->updateWatchData(data, flags);
}
void QmlCppEngine::watchDataSelected(const QByteArray &iname)
{
const WatchData *wd = watchHandler()->findData(iname);
if (wd && wd->isInspect())
d->m_qmlEngine->watchDataSelected(iname);
m_qmlEngine->watchDataSelected(iname);
}
void QmlCppEngine::watchPoint(const QPoint &point)
{
d->m_cppEngine->watchPoint(point);
m_cppEngine->watchPoint(point);
}
void QmlCppEngine::fetchMemory(MemoryAgent *ma, QObject *obj,
quint64 addr, quint64 length)
{
d->m_cppEngine->fetchMemory(ma, obj, addr, length);
m_cppEngine->fetchMemory(ma, obj, addr, length);
}
void QmlCppEngine::fetchDisassembler(DisassemblerAgent *da)
{
d->m_cppEngine->fetchDisassembler(da);
m_cppEngine->fetchDisassembler(da);
}
void QmlCppEngine::activateFrame(int index)
......@@ -157,105 +138,105 @@ void QmlCppEngine::activateFrame(int index)
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
return;
d->m_activeEngine->activateFrame(index);
m_activeEngine->activateFrame(index);
stackHandler()->setCurrentIndex(index);
}
void QmlCppEngine::reloadModules()
{
d->m_cppEngine->reloadModules();
m_cppEngine->reloadModules();
}
void QmlCppEngine::examineModules()
{
d->m_cppEngine->examineModules();
m_cppEngine->examineModules();
}
void QmlCppEngine::loadSymbols(const QString &moduleName)
{
d->m_cppEngine->loadSymbols(moduleName);
m_cppEngine->loadSymbols(moduleName);
}
void QmlCppEngine::loadAllSymbols()
{
d->m_cppEngine->loadAllSymbols();
m_cppEngine->loadAllSymbols();
}
void QmlCppEngine::requestModuleSymbols(const QString &moduleName)
{
d->m_cppEngine->requestModuleSymbols(moduleName);
m_cppEngine->requestModuleSymbols(moduleName);
}
void QmlCppEngine::reloadRegisters()
{
d->m_cppEngine->reloadRegisters();
m_cppEngine->reloadRegisters();
}
void QmlCppEngine::reloadSourceFiles()
{
d->m_cppEngine->reloadSourceFiles();
m_cppEngine->reloadSourceFiles();
}
void QmlCppEngine::reloadFullStack()
{
d->m_cppEngine->reloadFullStack();
m_cppEngine->reloadFullStack();
}
void QmlCppEngine::setRegisterValue(int regnr, const QString &value)
{
d->m_cppEngine->setRegisterValue(regnr, value);
m_cppEngine->setRegisterValue(regnr, value);
}
bool QmlCppEngine::hasCapability(unsigned cap) const
{
// ### this could also be an OR of both engines' capabilities
bool hasCap = d->m_cppEngine->hasCapability(cap);
if (d->m_activeEngine != d->m_cppEngine) {
bool hasCap = m_cppEngine->hasCapability(cap);
if (m_activeEngine != m_cppEngine) {
//Some capabilities cannot be handled by QML Engine
//Expand this list as and when required
if (cap == AddWatcherWhileRunningCapability)
hasCap = hasCap || d->m_qmlEngine->hasCapability(cap);
hasCap = hasCap || m_qmlEngine->hasCapability(cap);
if (cap == WatchWidgetsCapability ||
cap == DisassemblerCapability ||
cap == OperateByInstructionCapability ||
cap == ReverseSteppingCapability)
hasCap = hasCap && d->m_qmlEngine->hasCapability(cap);
hasCap = hasCap && m_qmlEngine->hasCapability(cap);
}
return hasCap;
}
bool QmlCppEngine::isSynchronous() const
{
return d->m_activeEngine->isSynchronous();
return m_activeEngine->isSynchronous();
}
QByteArray QmlCppEngine::qtNamespace() const
{
return d->m_cppEngine->qtNamespace();
return m_cppEngine->qtNamespace();
}
void QmlCppEngine::createSnapshot()
{
d->m_cppEngine->createSnapshot();
m_cppEngine->createSnapshot();
}
void QmlCppEngine::updateAll()
{
d->m_activeEngine->updateAll();
m_activeEngine->updateAll();
}
void QmlCppEngine::attemptBreakpointSynchronization()
{
d->m_cppEngine->attemptBreakpointSynchronization();
m_cppEngine->attemptBreakpointSynchronization();
switch (d->m_qmlEngine->state()) {
switch (m_qmlEngine->state()) {
case InferiorRunOk:
case InferiorRunRequested:
case InferiorStopOk: // fall through
case InferiorStopRequested:
d->m_qmlEngine->attemptBreakpointSynchronization();
m_qmlEngine->attemptBreakpointSynchronization();
break;
default:
break;
......@@ -264,22 +245,22 @@ void QmlCppEngine::attemptBreakpointSynchronization()
bool QmlCppEngine::acceptsBreakpoint(BreakpointModelId id) const
{
return d->m_cppEngine->acceptsBreakpoint(id)
|| d->m_qmlEngine->acceptsBreakpoint(id);
return m_cppEngine->acceptsBreakpoint(id)
|| m_qmlEngine->acceptsBreakpoint(id);
}
void QmlCppEngine::selectThread(ThreadId threadId)
{
d->m_activeEngine->selectThread(threadId);
m_activeEngine->selectThread(threadId);
}
void QmlCppEngine::assignValueInDebugger(const WatchData *data,
const QString &expr, const QVariant &value)
{
if (data->isInspect())
d->m_qmlEngine->assignValueInDebugger(data, expr, value);
m_qmlEngine->assignValueInDebugger(data, expr, value);
else
d->m_activeEngine->assignValueInDebugger(data, expr, value);
m_activeEngine->assignValueInDebugger(data, expr, value);
}
void QmlCppEngine::notifyInferiorIll()
......@@ -292,79 +273,79 @@ void QmlCppEngine::notifyInferiorIll()
//Call notifyInferiorIll of cpp engine
//as qml engine will follow state transitions
//of cpp engine
d->m_cppEngine->notifyInferiorIll();
m_cppEngine->notifyInferiorIll();
}
void QmlCppEngine::detachDebugger()
{
d->m_qmlEngine->detachDebugger();
d->m_cppEngine->detachDebugger();
m_qmlEngine->detachDebugger();
m_cppEngine->detachDebugger();
}
void QmlCppEngine::executeStep()
{
// TODO: stepping from qml -> cpp requires more thought
// if (d->m_activeEngine == d->m_qmlEngine) {
// QTC_CHECK(d->m_cppEngine->state() == InferiorRunOk);
// if (d->m_cppEngine->setupQmlStep(true))
// if (m_activeEngine == m_qmlEngine) {
// QTC_CHECK(m_cppEngine->state() == InferiorRunOk);
// if (m_cppEngine->setupQmlStep(true))
// return; // Wait for callback to readyToExecuteQmlStep()
// } else {
// notifyInferiorRunRequested();
// d->m_cppEngine->executeStep();
// m_cppEngine->executeStep();
// }
notifyInferiorRunRequested();
d->m_activeEngine->executeStep();
m_activeEngine->executeStep();
}
void QmlCppEngine::readyToExecuteQmlStep()
{
notifyInferiorRunRequested();
d->m_qmlEngine->executeStep();
m_qmlEngine->executeStep();
}
void QmlCppEngine::executeStepOut()
{
notifyInferiorRunRequested();
d->m_activeEngine->executeStepOut();
m_activeEngine->executeStepOut();
}
void QmlCppEngine::executeNext()
{
notifyInferiorRunRequested();
d->m_activeEngine->executeNext();
m_activeEngine->executeNext();
}
void QmlCppEngine::executeStepI()
{
notifyInferiorRunRequested();
d->m_activeEngine->executeStepI();
m_activeEngine->executeStepI();
}
void QmlCppEngine::executeNextI()
{
notifyInferiorRunRequested();
d->m_activeEngine->executeNextI();
m_activeEngine->executeNextI();
}
void QmlCppEngine::executeReturn()
{
notifyInferiorRunRequested();
d->m_activeEngine->executeReturn();
m_activeEngine->executeReturn();
}
void QmlCppEngine::continueInferior()
{
EDEBUG("\nMASTER CONTINUE INFERIOR"
<< d->m_cppEngine->state() << d->m_qmlEngine->state());
<< state() << m_qmlEngine->state());
notifyInferiorRunRequested();
if (d->m_cppEngine->state() == InferiorStopOk) {
d->m_cppEngine->continueInferior();
} else if (d->m_qmlEngine->state() == InferiorStopOk) {
d->m_qmlEngine->continueInferior();
if (m_cppEngine->state() == InferiorStopOk) {
m_cppEngine->continueInferior();
} else if (m_qmlEngine->state() == InferiorStopOk) {
m_qmlEngine->continueInferior();
} else {
QTC_ASSERT(false, qDebug() << "MASTER CANNOT CONTINUE INFERIOR"
<< d->m_cppEngine->state() << d->m_qmlEngine->state());
<< m_cppEngine->state() << m_qmlEngine->state());
notifyEngineIll();
}
}
......@@ -372,7 +353,7 @@ void QmlCppEngine::continueInferior()
void QmlCppEngine::interruptInferior()
{
EDEBUG("\nMASTER INTERRUPT INFERIOR");
d->m_cppEngine->requestInterruptInferior();
m_cppEngine->requestInterruptInferior();
}
void QmlCppEngine::requestInterruptInferior()
......@@ -383,23 +364,23 @@ void QmlCppEngine::requestInterruptInferior()
void QmlCppEngine::executeRunToLine(const ContextData &data)
{
d->m_activeEngine->executeRunToLine(data);
m_activeEngine->executeRunToLine(data);
}
void QmlCppEngine::executeRunToFunction(const QString &functionName)
{
d->m_activeEngine->executeRunToFunction(functionName);
m_activeEngine->executeRunToFunction(functionName);
}
void QmlCppEngine::executeJumpToLine(const ContextData &data)
{
d->m_activeEngine->executeJumpToLine(data);
m_activeEngine->executeJumpToLine(data);
}
void QmlCppEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
{
d->m_qmlEngine->executeDebuggerCommand(command, languages);
d->m_cppEngine->executeDebuggerCommand(command, languages);
m_qmlEngine->executeDebuggerCommand(command, languages);
m_cppEngine->executeDebuggerCommand(command, languages);
}
/////////////////////////////////////////////////////////
......@@ -407,9 +388,9 @@ void QmlCppEngine::executeDebuggerCommand(const QString &command, DebuggerLangua
void QmlCppEngine::setupEngine()
{
EDEBUG("\nMASTER SETUP ENGINE");
setActiveEngine(d->m_cppEngine);
d->m_qmlEngine->setupSlaveEngine();
d->m_cppEngine->setupSlaveEngine();
setActiveEngine(m_cppEngine);
m_qmlEngine->setupSlaveEngine();
m_cppEngine->setupSlaveEngine();
if (startParameters().remoteSetupNeeded)
notifyEngineRequestRemoteSetup();
......@@ -448,33 +429,33 @@ void QmlCppEngine::notifyInferiorSetupOk()
void QmlCppEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel, int pid)
{
d->m_cppEngine->notifyEngineRemoteServerRunning(serverChannel, pid);
m_cppEngine->notifyEngineRemoteServerRunning(serverChannel, pid);
}
void QmlCppEngine::setupInferior()
{
EDEBUG("\nMASTER SETUP INFERIOR");
d->m_qmlEngine->setupSlaveInferior();
d->m_cppEngine->setupSlaveInferior();
m_qmlEngine->setupSlaveInferior();
m_cppEngine->setupSlaveInferior();
}
void QmlCppEngine::runEngine()
{
EDEBUG("\nMASTER RUN ENGINE");
d->m_qmlEngine->runSlaveEngine();
d->m_cppEngine->runSlaveEngine();
m_qmlEngine->runSlaveEngine();
m_cppEngine->runSlaveEngine();
}
void QmlCppEngine::shutdownInferior()
{
EDEBUG("\nMASTER SHUTDOWN INFERIOR");
d->m_cppEngine->shutdownInferior();
m_cppEngine->shutdownInferior();
}
void QmlCppEngine::shutdownEngine()
{
EDEBUG("\nMASTER SHUTDOWN ENGINE");
d->m_cppEngine->shutdownSlaveEngine();
m_cppEngine->shutdownSlaveEngine();
QmlJS::ConsoleManagerInterface *consoleManager = QmlJS::ConsoleManagerInterface::instance();
if (consoleManager)
consoleManager->setScriptEvaluator(0);
......@@ -483,28 +464,28 @@ void QmlCppEngine::shutdownEngine()
void QmlCppEngine::quitDebugger()
{
EDEBUG("\nMASTER QUIT DEBUGGER");
d->m_cppEngine->quitDebugger();
m_cppEngine->quitDebugger();
}
void QmlCppEngine::abortDebugger()
{
EDEBUG("\nMASTER ABORT DEBUGGER");
d->m_cppEngine->abortDebugger();
m_cppEngine->abortDebugger();
}
void QmlCppEngine::setState(DebuggerState newState, bool forced)
{
EDEBUG("SET MASTER STATE: " << newState);
EDEBUG(" CPP STATE: " << d->m_cppEngine->state());
EDEBUG(" QML STATE: " << d->m_qmlEngine->state());
EDEBUG(" CPP STATE: " << m_cppEngine->state());
EDEBUG(" QML STATE: " << m_qmlEngine->state());
DebuggerEngine::setState(newState, forced);
}
void QmlCppEngine::slaveEngineStateChanged
(DebuggerEngine *slaveEngine, const DebuggerState newState)
{
DebuggerEngine *otherEngine = (slaveEngine == d->m_cppEngine)
? d->m_qmlEngine : d->m_cppEngine;
DebuggerEngine *otherEngine = (slaveEngine == m_cppEngine)
? m_qmlEngine : m_cppEngine;
QTC_CHECK(otherEngine != slaveEngine);
......@@ -521,7 +502,7 @@ void QmlCppEngine::slaveEngineStateChanged
// InferiorStopOk state. The cpp engine becomes the active one again as soon as it itself enters
// the InferiorStopOk state.
if (slaveEngine == d->m_cppEngine) {
if (slaveEngine == m_cppEngine) {
switch (newState) {
case DebuggerNotReady: {
// Can this ever happen?
......@@ -589,7 +570,7 @@ void QmlCppEngine::slaveEngineStateChanged
// track qml engine again
setState(InferiorStopRequested);
notifyInferiorStopOk();
setActiveEngine(d->m_qmlEngine);
setActiveEngine(m_qmlEngine);
}
break;
}
......@@ -599,7 +580,7 @@ void QmlCppEngine::slaveEngineStateChanged
break;
}
case InferiorStopRequested: {
if (d->m_activeEngine == cppEngine()) {
if (m_activeEngine == cppEngine()) {
// might be set by doInterruptInferior()
QTC_ASSERT(state() == InferiorStopRequested
|| state() == InferiorRunOk, qDebug() << state());
......@@ -622,7 +603,7 @@ void QmlCppEngine::slaveEngineStateChanged
setState(InferiorStopRequested);
}
// now track cpp engine
setActiveEngine(d->m_cppEngine);
setActiveEngine(m_cppEngine);
}
break;
}
......@@ -634,15 +615,15 @@ void QmlCppEngine::slaveEngineStateChanged
|| state() == InferiorStopOk, qDebug() << state());
// Just to make sure, we're shutting down anyway ...
setActiveEngine(d->m_cppEngine);
setActiveEngine(m_cppEngine);
if (state() == InferiorStopRequested)
setState(InferiorStopOk);
// otherwise we're probably inside notifyInferiorStopOk already
} else {
if (d->m_activeEngine != cppEngine()) {
if (m_activeEngine != cppEngine()) {
showStatusMessage(tr("C++ debugger activated"));
setActiveEngine(d->m_cppEngine);
setActiveEngine(m_cppEngine);
}
QTC_ASSERT(state() == InferiorStopRequested
......@@ -734,15 +715,15 @@ void QmlCppEngine::slaveEngineStateChanged
EDEBUG("... QML ENGINE STOPPED DURING SHUTDOWN ");
// Just to make sure, we're shutting down anyway ...
setActiveEngine(d->m_cppEngine);
setActiveEngine(m_cppEngine);
if (state() == InferiorStopRequested)
notifyInferiorStopOk();
// otherwise we're probably inside notifyInferiorStopOk already
} else {
if (d->m_activeEngine != qmlEngine()) {
if (m_activeEngine != qmlEngine()) {
showStatusMessage(tr("QML debugger activated"));
setActiveEngine(d->m_qmlEngine);
setActiveEngine(m_qmlEngine);
}
QTC_ASSERT(state() == InferiorRunOk
......@@ -756,7 +737,7 @@ void QmlCppEngine::slaveEngineStateChanged
}
} else if (newState == InferiorRunOk) {
if (d->m_activeEngine == qmlEngine()) {
if (m_activeEngine == qmlEngine()) {
QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state());
notifyInferiorRunOk();
}
......@@ -786,34 +767,34 @@ void QmlCppEngine::showMessage(const QString &msg, int channel, int timeout) con
{
if (channel == AppOutput || channel == AppError || channel == AppStuff) {
// message is from CppEngine, allow qml engine to process
d->m_qmlEngine->filterApplicationMessage(msg, channel);
m_qmlEngine->filterApplicationMessage(msg, channel);
}
DebuggerEngine::showMessage(msg, channel, timeout);
}
void QmlCppEngine::resetLocation()
{
if (d->m_qmlEngine)
d->m_qmlEngine->resetLocation();
if (d->m_cppEngine)
d->m_cppEngine->resetLocation();
if (m_qmlEngine)
m_qmlEngine->resetLocation();
if (m_cppEngine)
m_cppEngine->resetLocation();
DebuggerEngine::resetLocation();
}
DebuggerEngine *QmlCppEngine::cppEngine() const
{
return d->m_cppEngine;
return m_cppEngine;
}
DebuggerEngine *QmlCppEngine::qmlEngine() const
{
return d->m_qmlEngine;
return m_qmlEngine;
}
void QmlCppEngine::setActiveEngine(DebuggerEngine *engine)
{
d->m_activeEngine = engine;
m_activeEngine = engine;
updateViews();
}
......