Debugger: Move DebuggerEngine/QmlEngine/QmlCppEngine into Debugger{}

namespace (from Debugger::Internal) as they are exported classes.
Introduce private classes to avoid exposing private JS debugger
headers.
This commit is contained in:
Friedemann Kleint
2010-09-13 13:30:35 +02:00
parent 6dec1c6ffd
commit f7b19f8114
31 changed files with 618 additions and 450 deletions

View File

@@ -7,12 +7,13 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <QtCore/QTimer>
namespace Debugger {
namespace Internal {
const int ConnectionWaitTimeMs = 5000;
namespace Internal {
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &);
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &);
@@ -21,29 +22,49 @@ DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp)
{
return new QmlCppEngine(sp);
}
} // namespace Internal
QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp)
: DebuggerEngine(sp)
, m_shutdownOk(true)
struct QmlCppEnginePrivate {
QmlCppEnginePrivate();
QmlEngine *m_qmlEngine;
DebuggerEngine *m_cppEngine;
DebuggerEngine *m_activeEngine;
bool m_shutdownOk;
bool m_shutdownDeferred;
bool m_shutdownDone;
bool m_isInitialStartup;
};
QmlCppEnginePrivate::QmlCppEnginePrivate() :
m_qmlEngine(0),
m_cppEngine(0),
m_activeEngine(0),
m_shutdownOk(true)
, m_shutdownDeferred(false)
, m_shutdownDone(false)
, m_isInitialStartup(true)
{
m_qmlEngine = qobject_cast<QmlEngine*>(createQmlEngine(sp));
m_qmlEngine->setAttachToRunningExternalApp(true);
}
QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp)
: DebuggerEngine(sp), d(new QmlCppEnginePrivate)
{
d->m_qmlEngine = qobject_cast<QmlEngine*>(Internal::createQmlEngine(sp));
d->m_qmlEngine->setAttachToRunningExternalApp(true);
if (startParameters().cppEngineType == GdbEngineType) {
m_cppEngine = createGdbEngine(sp);
d->m_cppEngine = Internal::createGdbEngine(sp);
} else {
m_cppEngine = createCdbEngine(sp);
d->m_cppEngine = Internal::createCdbEngine(sp);
}
m_cppEngine->setRunInWrapperEngine(true);
m_qmlEngine->setRunInWrapperEngine(true);
d->m_cppEngine->setRunInWrapperEngine(true);
d->m_qmlEngine->setRunInWrapperEngine(true);
m_activeEngine = m_cppEngine;
connect(m_cppEngine, SIGNAL(stateChanged(DebuggerState)), SLOT(masterEngineStateChanged(DebuggerState)));
connect(m_qmlEngine, SIGNAL(stateChanged(DebuggerState)), SLOT(slaveEngineStateChanged(DebuggerState)));
d->m_activeEngine = d->m_cppEngine;
connect(d->m_cppEngine, SIGNAL(stateChanged(DebuggerState)), SLOT(masterEngineStateChanged(DebuggerState)));
connect(d->m_qmlEngine, SIGNAL(stateChanged(DebuggerState)), SLOT(slaveEngineStateChanged(DebuggerState)));
Core::EditorManager *em = Core::EditorManager::instance();
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(editorChanged(Core::IEditor*)));
@@ -51,10 +72,10 @@ QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp)
QmlCppEngine::~QmlCppEngine()
{
delete m_qmlEngine;
delete m_cppEngine;
m_qmlEngine = 0;
m_cppEngine = 0;
delete d->m_qmlEngine;
delete d->m_cppEngine;
d->m_qmlEngine = 0;
d->m_cppEngine = 0;
}
void QmlCppEngine::editorChanged(Core::IEditor *editor)
@@ -72,274 +93,274 @@ void QmlCppEngine::editorChanged(Core::IEditor *editor)
void QmlCppEngine::setActiveEngine(DebuggerLanguage language)
{
DebuggerEngine *previousEngine = m_activeEngine;
DebuggerEngine *previousEngine = d->m_activeEngine;
bool updateEngine = false;
QString engineName;
if (language == CppLanguage) {
engineName = QLatin1String("C++");
m_activeEngine = m_cppEngine;
d->m_activeEngine = d->m_cppEngine;
// don't update cpp engine - at least gdb will stop temporarily,
// which is not nice when you're just switching files.
} else if (language == QmlLanguage) {
engineName = QLatin1String("QML");
m_activeEngine = m_qmlEngine;
d->m_activeEngine = d->m_qmlEngine;
updateEngine = true;
}
if (previousEngine != m_activeEngine) {
if (previousEngine != d->m_activeEngine) {
showStatusMessage(tr("%1 debugger activated").arg(engineName));
plugin()->displayDebugger(m_activeEngine, updateEngine);
plugin()->displayDebugger(d->m_activeEngine, updateEngine);
}
}
void QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
TextEditor::ITextEditor *editor, int cursorPos)
{
m_activeEngine->setToolTipExpression(mousePos, editor, cursorPos);
d->m_activeEngine->setToolTipExpression(mousePos, editor, cursorPos);
}
void QmlCppEngine::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags)
void QmlCppEngine::updateWatchData(const Internal::WatchData &data, const Internal::WatchUpdateFlags &flags)
{
m_activeEngine->updateWatchData(data, flags);
d->m_activeEngine->updateWatchData(data, flags);
}
void QmlCppEngine::watchPoint(const QPoint &point)
{
m_cppEngine->watchPoint(point);
d->m_cppEngine->watchPoint(point);
}
void QmlCppEngine::fetchMemory(MemoryViewAgent *mva, QObject *obj,
void QmlCppEngine::fetchMemory(Internal::MemoryViewAgent *mva, QObject *obj,
quint64 addr, quint64 length)
{
m_cppEngine->fetchMemory(mva, obj, addr, length);
d->m_cppEngine->fetchMemory(mva, obj, addr, length);
}
void QmlCppEngine::fetchDisassembler(DisassemblerViewAgent *dva)
void QmlCppEngine::fetchDisassembler(Internal::DisassemblerViewAgent *dva)
{
m_cppEngine->fetchDisassembler(dva);
d->m_cppEngine->fetchDisassembler(dva);
}
void QmlCppEngine::activateFrame(int index)
{
m_cppEngine->activateFrame(index);
d->m_cppEngine->activateFrame(index);
}
void QmlCppEngine::reloadModules()
{
m_cppEngine->reloadModules();
d->m_cppEngine->reloadModules();
}
void QmlCppEngine::examineModules()
{
m_cppEngine->examineModules();
d->m_cppEngine->examineModules();
}
void QmlCppEngine::loadSymbols(const QString &moduleName)
{
m_cppEngine->loadSymbols(moduleName);
d->m_cppEngine->loadSymbols(moduleName);
}
void QmlCppEngine::loadAllSymbols()
{
m_cppEngine->loadAllSymbols();
d->m_cppEngine->loadAllSymbols();
}
void QmlCppEngine::requestModuleSymbols(const QString &moduleName)
{
m_cppEngine->requestModuleSymbols(moduleName);
d->m_cppEngine->requestModuleSymbols(moduleName);
}
void QmlCppEngine::reloadRegisters()
{
m_cppEngine->reloadRegisters();
d->m_cppEngine->reloadRegisters();
}
void QmlCppEngine::reloadSourceFiles()
{
m_cppEngine->reloadSourceFiles();
d->m_cppEngine->reloadSourceFiles();
}
void QmlCppEngine::reloadFullStack()
{
m_cppEngine->reloadFullStack();
d->m_cppEngine->reloadFullStack();
}
void QmlCppEngine::setRegisterValue(int regnr, const QString &value)
{
m_cppEngine->setRegisterValue(regnr, value);
d->m_cppEngine->setRegisterValue(regnr, value);
}
unsigned QmlCppEngine::debuggerCapabilities() const
{
// ### this could also be an OR of both engines' capabilities
return m_cppEngine->debuggerCapabilities();
return d->m_cppEngine->debuggerCapabilities();
}
bool QmlCppEngine::isSynchronous() const
{
return m_activeEngine->isSynchronous();
return d->m_activeEngine->isSynchronous();
}
QByteArray QmlCppEngine::qtNamespace() const
{
return m_cppEngine->qtNamespace();
return d->m_cppEngine->qtNamespace();
}
void QmlCppEngine::createSnapshot()
{
m_cppEngine->createSnapshot();
d->m_cppEngine->createSnapshot();
}
void QmlCppEngine::updateAll()
{
m_activeEngine->updateAll();
d->m_activeEngine->updateAll();
}
void QmlCppEngine::attemptBreakpointSynchronization()
{
m_cppEngine->attemptBreakpointSynchronization();
static_cast<DebuggerEngine*>(m_qmlEngine)->attemptBreakpointSynchronization();
d->m_cppEngine->attemptBreakpointSynchronization();
static_cast<DebuggerEngine*>(d->m_qmlEngine)->attemptBreakpointSynchronization();
}
void QmlCppEngine::selectThread(int index)
{
m_cppEngine->selectThread(index);
d->m_cppEngine->selectThread(index);
}
void QmlCppEngine::assignValueInDebugger(const QString &expr, const QString &value)
{
m_activeEngine->assignValueInDebugger(expr, value);
d->m_activeEngine->assignValueInDebugger(expr, value);
}
QAbstractItemModel *QmlCppEngine::commandModel() const
{
return m_activeEngine->commandModel();
return d->m_activeEngine->commandModel();
}
QAbstractItemModel *QmlCppEngine::modulesModel() const
{
return m_cppEngine->modulesModel();
return d->m_cppEngine->modulesModel();
}
QAbstractItemModel *QmlCppEngine::breakModel() const
{
return m_activeEngine->breakModel();
return d->m_activeEngine->breakModel();
}
QAbstractItemModel *QmlCppEngine::registerModel() const
{
return m_cppEngine->registerModel();
return d->m_cppEngine->registerModel();
}
QAbstractItemModel *QmlCppEngine::stackModel() const
{
return m_activeEngine->stackModel();
return d->m_activeEngine->stackModel();
}
QAbstractItemModel *QmlCppEngine::threadsModel() const
{
return m_cppEngine->threadsModel();
return d->m_cppEngine->threadsModel();
}
QAbstractItemModel *QmlCppEngine::localsModel() const
{
return m_activeEngine->localsModel();
return d->m_activeEngine->localsModel();
}
QAbstractItemModel *QmlCppEngine::watchersModel() const
{
return m_activeEngine->watchersModel();
return d->m_activeEngine->watchersModel();
}
QAbstractItemModel *QmlCppEngine::returnModel() const
{
return m_cppEngine->returnModel();
return d->m_cppEngine->returnModel();
}
QAbstractItemModel *QmlCppEngine::sourceFilesModel() const
{
return m_cppEngine->sourceFilesModel();
return d->m_cppEngine->sourceFilesModel();
}
void QmlCppEngine::detachDebugger()
{
m_qmlEngine->detachDebugger();
m_cppEngine->detachDebugger();
d->m_qmlEngine->detachDebugger();
d->m_cppEngine->detachDebugger();
}
void QmlCppEngine::executeStep()
{
m_activeEngine->executeStep();
d->m_activeEngine->executeStep();
}
void QmlCppEngine::executeStepOut()
{
m_activeEngine->executeStepOut();
d->m_activeEngine->executeStepOut();
}
void QmlCppEngine::executeNext()
{
m_activeEngine->executeNext();
d->m_activeEngine->executeNext();
}
void QmlCppEngine::executeStepI()
{
m_activeEngine->executeStepI();
d->m_activeEngine->executeStepI();
}
void QmlCppEngine::executeNextI()
{
m_activeEngine->executeNextI();
d->m_activeEngine->executeNextI();
}
void QmlCppEngine::executeReturn()
{
m_activeEngine->executeReturn();
d->m_activeEngine->executeReturn();
}
void QmlCppEngine::continueInferior()
{
m_activeEngine->continueInferior();
d->m_activeEngine->continueInferior();
}
void QmlCppEngine::interruptInferior()
{
m_activeEngine->interruptInferior();
d->m_activeEngine->interruptInferior();
}
void QmlCppEngine::requestInterruptInferior()
{
m_activeEngine->requestInterruptInferior();
d->m_activeEngine->requestInterruptInferior();
}
void QmlCppEngine::executeRunToLine(const QString &fileName, int lineNumber)
{
m_activeEngine->executeRunToLine(fileName, lineNumber);
d->m_activeEngine->executeRunToLine(fileName, lineNumber);
}
void QmlCppEngine::executeRunToFunction(const QString &functionName)
{
m_activeEngine->executeRunToFunction(functionName);
d->m_activeEngine->executeRunToFunction(functionName);
}
void QmlCppEngine::executeJumpToLine(const QString &fileName, int lineNumber)
{
m_activeEngine->executeJumpToLine(fileName, lineNumber);
d->m_activeEngine->executeJumpToLine(fileName, lineNumber);
}
void QmlCppEngine::executeDebuggerCommand(const QString &command)
{
m_activeEngine->executeDebuggerCommand(command);
d->m_activeEngine->executeDebuggerCommand(command);
}
void QmlCppEngine::frameUp()
{
m_activeEngine->frameUp();
d->m_activeEngine->frameUp();
}
void QmlCppEngine::frameDown()
{
m_activeEngine->frameDown();
d->m_activeEngine->frameDown();
}
void QmlCppEngine::notifyInferiorRunOk()
@@ -352,7 +373,7 @@ void QmlCppEngine::notifyInferiorRunOk()
void QmlCppEngine::setupEngine()
{
m_cppEngine->startDebugger(runControl());
d->m_cppEngine->startDebugger(runControl());
}
void QmlCppEngine::setupInferior()
@@ -369,40 +390,40 @@ void QmlCppEngine::runEngine()
void QmlCppEngine::shutdownInferior()
{
// user wants to stop inferior: always use cpp engine for this.
if (m_activeEngine == m_qmlEngine) {
m_activeEngine = m_cppEngine;
if (d->m_activeEngine == d->m_qmlEngine) {
d->m_activeEngine = d->m_cppEngine;
// we end up in this state after trying to shut down while debugging qml.
// b/c qml does not shutdown by itself, restore previous state and continue.
if (m_qmlEngine->state() == InferiorShutdownRequested) {
m_qmlEngine->setState(InferiorStopOk, true);
if (d->m_qmlEngine->state() == InferiorShutdownRequested) {
d->m_qmlEngine->setState(InferiorStopOk, true);
}
if (m_qmlEngine->state() == InferiorStopOk) {
m_qmlEngine->continueInferior();
if (d->m_qmlEngine->state() == InferiorStopOk) {
d->m_qmlEngine->continueInferior();
}
}
if (m_cppEngine->state() == InferiorRunOk) {
if (d->m_cppEngine->state() == InferiorRunOk) {
// first interrupt c++ engine; when done, we can shutdown.
m_shutdownDeferred = true;
m_cppEngine->requestInterruptInferior();
d->m_shutdownDeferred = true;
d->m_cppEngine->requestInterruptInferior();
}
if (!m_shutdownDeferred)
m_cppEngine->shutdownInferior();
if (!d->m_shutdownDeferred)
d->m_cppEngine->shutdownInferior();
}
void QmlCppEngine::shutdownEngine()
{
m_cppEngine->shutdownEngine();
m_qmlEngine->shutdownEngineAsSlave();
d->m_cppEngine->shutdownEngine();
d->m_qmlEngine->shutdownEngineAsSlave();
notifyEngineShutdownOk();
}
void QmlCppEngine::finishDebugger()
{
if (!m_shutdownDone) {
m_shutdownDone = true;
if (m_shutdownOk) {
if (!d->m_shutdownDone) {
d->m_shutdownDone = true;
if (d->m_shutdownOk) {
notifyEngineShutdownOk();
} else {
notifyEngineShutdownFailed();
@@ -418,7 +439,7 @@ void QmlCppEngine::setupSlaveEngineOnTimer()
void QmlCppEngine::setupSlaveEngine()
{
if (state() == InferiorRunRequested)
m_qmlEngine->startDebugger(runControl());
d->m_qmlEngine->startDebugger(runControl());
}
void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
@@ -463,9 +484,9 @@ void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
break;
case InferiorRunOk:
if (m_qmlEngine->state() == DebuggerNotReady) {
if (m_isInitialStartup) {
m_isInitialStartup = false;
if (d->m_qmlEngine->state() == DebuggerNotReady) {
if (d->m_isInitialStartup) {
d->m_isInitialStartup = false;
setupSlaveEngineOnTimer();
} else {
setupSlaveEngine();
@@ -483,7 +504,7 @@ void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
if (state() == InferiorRunRequested) {
// if stopping on startup, move on to normal state
// and go forward. Also, stop connection and continue later if needed.
m_qmlEngine->pauseConnection();
d->m_qmlEngine->pauseConnection();
setState(EngineRunRequested, true);
notifyEngineRunAndInferiorRunOk();
setState(newState);
@@ -501,25 +522,25 @@ void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
setState(newState);
} else if (state() == InferiorRunOk) {
// if we break on CPP side while running & engine is QML, switch.
if (m_activeEngine == m_qmlEngine) {
if (d->m_activeEngine == d->m_qmlEngine) {
setActiveEngine(CppLanguage);
}
setState(newState);
} else if (state() == InferiorRunRequested) {
setState(newState, true);
}
if (m_shutdownDeferred) {
m_activeEngine = m_cppEngine;
m_shutdownDeferred = false;
if (d->m_shutdownDeferred) {
d->m_activeEngine = d->m_cppEngine;
d->m_shutdownDeferred = false;
shutdownInferior();
}
break;
case InferiorStopFailed:
setState(newState);
if (m_shutdownDeferred) {
m_activeEngine = m_cppEngine;
m_shutdownDeferred = false;
if (d->m_shutdownDeferred) {
d->m_activeEngine = d->m_cppEngine;
d->m_shutdownDeferred = false;
shutdownInferior();
}
break;
@@ -528,22 +549,22 @@ void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
// but due to everything being asyncronous, we cannot guarantee
// that it is shut down completely before gdb engine is shut down.
case InferiorShutdownRequested:
if (m_activeEngine == m_qmlEngine) {
m_activeEngine = m_cppEngine;
if (d->m_activeEngine == d->m_qmlEngine) {
d->m_activeEngine = d->m_cppEngine;
}
m_qmlEngine->shutdownInferiorAsSlave();
d->m_qmlEngine->shutdownInferiorAsSlave();
setState(newState);
break;
case InferiorShutdownOk:
setState(newState);
m_qmlEngine->shutdownEngineAsSlave();
d->m_qmlEngine->shutdownEngineAsSlave();
break;
case InferiorShutdownFailed:
setState(newState);
m_qmlEngine->shutdownEngineAsSlave();
d->m_qmlEngine->shutdownEngineAsSlave();
break;
case EngineShutdownRequested:
@@ -555,7 +576,7 @@ void QmlCppEngine::masterEngineStateChanged(const DebuggerState &newState)
break;
case EngineShutdownFailed:
m_shutdownOk = false;
d->m_shutdownOk = false;
finishDebugger();
break;
@@ -568,7 +589,7 @@ void QmlCppEngine::slaveEngineStateChanged(const DebuggerState &newState)
{
//qDebug() << " qml engine changed to" << newState;
if (m_activeEngine == m_qmlEngine) {
if (d->m_activeEngine == d->m_qmlEngine) {
handleSlaveEngineStateChangeAsActive(newState);
} else {
handleSlaveEngineStateChange(newState);
@@ -604,7 +625,7 @@ void QmlCppEngine::handleSlaveEngineStateChange(const DebuggerState &newState)
break;
case EngineShutdownFailed:
m_shutdownOk = false;
d->m_shutdownOk = false;
break;
default:
@@ -634,7 +655,7 @@ void QmlCppEngine::handleSlaveEngineStateChangeAsActive(const DebuggerState &new
break;
case InferiorShutdownRequested:
if (m_cppEngine->state() == InferiorRunOk) {
if (d->m_cppEngine->state() == InferiorRunOk) {
// occurs when user presses stop button from debugger UI.
shutdownInferior();
}
@@ -645,5 +666,9 @@ void QmlCppEngine::handleSlaveEngineStateChangeAsActive(const DebuggerState &new
}
}
} // namespace Internal
DebuggerEngine *QmlCppEngine::cppEngine() const
{
return d->m_cppEngine;
}
} // namespace Debugger