Commit aff13fdf authored by hjk's avatar hjk

Debugger: Make DebuggerEngine internal

Expose less of debugger internals to the device plugins.

Change-Id: Ie78756b033fae3fe02bff92eadf26b7319990605
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 8f7bd196
......@@ -35,7 +35,6 @@
#include "androidmanager.h"
#include "androidqtsupport.h"
#include <debugger/debuggerengine.h>
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <debugger/debuggerruncontrol.h>
......@@ -128,7 +127,6 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
DebuggerRunControl *runControl)
: QObject(runControl),
m_engine(0),
m_runControl(runControl),
m_runner(new AndroidRunner(this, runConfig, runControl->runMode()))
{
......@@ -142,21 +140,17 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Q_ASSERT(aspect->useCppDebugger() || aspect->useQmlDebugger());
Q_UNUSED(aspect)
m_engine = runControl->engine();
connect(m_runControl, &DebuggerRunControl::requestRemoteSetup,
m_runner, &AndroidRunner::start);
if (m_engine) {
connect(m_engine, &DebuggerEngine::requestRemoteSetup,
m_runner, &AndroidRunner::start);
// FIXME: Move signal to base class and generalize handling.
connect(m_engine, SIGNAL(aboutToNotifyInferiorSetupOk()),
m_runner, SLOT(handleRemoteDebuggerRunning()));
}
// FIXME: Move signal to base class and generalize handling.
connect(m_runControl, &DebuggerRunControl::aboutToNotifyInferiorSetupOk,
m_runner, &AndroidRunner::handleRemoteDebuggerRunning);
connect(m_runner, &AndroidRunner::remoteServerRunning,
[this](const QByteArray &serverChannel, int pid) {
QTC_ASSERT(m_engine, return);
m_engine->notifyEngineRemoteServerRunning(serverChannel, pid);
QTC_ASSERT(m_runControl, return);
m_runControl->notifyEngineRemoteServerRunning(serverChannel, pid);
});
connect(m_runner, &AndroidRunner::remoteProcessStarted,
......@@ -166,19 +160,19 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
[this](const QString &errorMsg) {
QTC_ASSERT(m_runControl, return);
m_runControl->appendMessage(errorMsg, Utils::DebugFormat);
QMetaObject::invokeMethod(m_engine, "notifyInferiorExited", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_runControl, "notifyInferiorExited", Qt::QueuedConnection);
});
connect(m_runner, &AndroidRunner::remoteErrorOutput,
[this](const QByteArray &output) {
QTC_ASSERT(m_engine, return);
m_engine->showMessage(QString::fromUtf8(output), AppError);
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(QString::fromUtf8(output), AppError);
});
connect(m_runner, &AndroidRunner::remoteOutput,
[this](const QByteArray &output) {
QTC_ASSERT(m_engine, return);
m_engine->showMessage(QString::fromUtf8(output), AppOutput);
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(QString::fromUtf8(output), AppOutput);
});
}
......@@ -186,12 +180,12 @@ void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlP
{
disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
QTC_ASSERT(m_engine, return);
QTC_ASSERT(m_runControl, return);
RemoteSetupResult result;
result.success = true;
result.gdbServerPort = gdbServerPort;
result.qmlServerPort = qmlPort;
m_engine->notifyEngineRemoteSetupFinished(result);
m_runControl->notifyEngineRemoteSetupFinished(result);
}
} // namespace Internal
......
......@@ -33,10 +33,7 @@
#include "androidrunconfiguration.h"
namespace Debugger {
class DebuggerEngine;
class DebuggerRunControl;
}
namespace Debugger { class DebuggerRunControl; }
namespace ProjectExplorer { class RunControl; }
......@@ -60,7 +57,6 @@ public:
private:
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
Debugger::DebuggerEngine *m_engine;
Debugger::DebuggerRunControl *m_runControl;
AndroidRunner * const m_runner;
};
......
......@@ -42,12 +42,10 @@
//////////////////////////////////////////////////////////////////
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class BreakpointMarker;
class DebuggerEngine;
class BreakHandler : public QAbstractItemModel
{
......
......@@ -52,7 +52,7 @@ struct MemoryViewCookie;
class ByteArrayInputStream;
class GdbMi;
class CdbEngine : public Debugger::DebuggerEngine
class CdbEngine : public DebuggerEngine
{
Q_OBJECT
......
......@@ -50,12 +50,10 @@ namespace CPlusPlus { class Snapshot; }
namespace Utils { class SavedAction; }
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class BreakHandler;
class DebuggerEngine;
class Symbol;
class Section;
class GlobalDebuggerOptions;
......
......@@ -99,18 +99,6 @@ const char PrefixDebugExecutable[] = "DebuggedExecutable";
namespace Debugger {
Internal::Location::Location(const StackFrame &frame, bool marker)
{
init();
m_fileName = frame.file;
m_lineNumber = frame.line;
m_needsMarker = marker;
m_functionName = frame.function;
m_hasDebugInfo = frame.isUsable();
m_address = frame.address;
m_from = frame.from;
}
QDebug operator<<(QDebug d, DebuggerState state)
{
//return d << DebuggerEngine::stateName(state) << '(' << int(state) << ')';
......@@ -133,6 +121,20 @@ QDebug operator<<(QDebug str, const DebuggerStartParameters &sp)
return str;
}
namespace Internal {
Location::Location(const StackFrame &frame, bool marker)
{
init();
m_fileName = frame.file;
m_lineNumber = frame.line;
m_needsMarker = marker;
m_functionName = frame.function;
m_hasDebugInfo = frame.isUsable();
m_address = frame.address;
m_from = frame.from;
}
//////////////////////////////////////////////////////////////////////
//
......@@ -781,6 +783,7 @@ void DebuggerEngine::notifyInferiorSetupOk()
#ifdef WITH_BENCHMARK
CALLGRIND_START_INSTRUMENTATION;
#endif
aboutToNotifyInferiorSetupOk();
showMessage(_("NOTE: INFERIOR SETUP OK"));
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << this << state());
setState(InferiorSetupOk);
......@@ -1903,6 +1906,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
}
}
} // namespace Internal
} // namespace Debugger
#include "debuggerengine.moc"
......@@ -50,7 +50,6 @@ namespace Core { class IOptionsPage; }
namespace Debugger {
class DebuggerEnginePrivate;
class DebuggerRunControl;
class DebuggerStartParameters;
......@@ -59,6 +58,7 @@ DEBUGGER_EXPORT QDebug operator<<(QDebug str, DebuggerState state);
namespace Internal {
class DebuggerEnginePrivate;
class DebuggerPluginPrivate;
class DisassemblerAgent;
class MemoryAgent;
......@@ -129,11 +129,7 @@ public:
quint64 address;
};
} // namespace Internal
// FIXME: DEBUGGER_EXPORT?
class DEBUGGER_EXPORT DebuggerEngine : public QObject
class DebuggerEngine : public QObject
{
Q_OBJECT
......@@ -282,6 +278,7 @@ signals:
* a server start script should be used, but none is given.
*/
void requestRemoteSetup();
void aboutToNotifyInferiorSetupOk();
protected:
// The base notify*() function implementation should be sufficient
......@@ -315,7 +312,9 @@ protected:
virtual void notifyInferiorStopOk();
virtual void notifyInferiorSpontaneousStop();
virtual void notifyInferiorStopFailed();
Q_SLOT virtual void notifyInferiorExited();
public:
virtual void notifyInferiorExited();
protected:
virtual void notifyInferiorShutdownOk();
......@@ -392,9 +391,9 @@ protected:
private:
// Wrapper engine needs access to state of its subengines.
friend class Internal::QmlCppEngine;
friend class Internal::DebuggerPluginPrivate;
friend class Internal::QmlAdapter;
friend class QmlCppEngine;
friend class DebuggerPluginPrivate;
friend class QmlAdapter;
virtual void setState(DebuggerState state, bool forced = false);
......@@ -402,6 +401,7 @@ private:
DebuggerEnginePrivate *d;
};
} // namespace Internal
} // namespace Debugger
Q_DECLARE_METATYPE(Debugger::Internal::ContextData)
......
......@@ -36,16 +36,11 @@
#include <utils/fancymainwindow.h>
namespace Core {
class Context;
class IMode;
}
namespace Core { class IMode; }
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerMainWindowPrivate;
// DebuggerMainWindow dock widget names
......
......@@ -108,6 +108,13 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, Debug
{
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL));
connect(this, &RunControl::finished, this, &DebuggerRunControl::handleFinished);
connect(engine, &DebuggerEngine::requestRemoteSetup,
this, &DebuggerRunControl::requestRemoteSetup);
connect(engine, &DebuggerEngine::stateChanged,
this, &DebuggerRunControl::stateChanged);
connect(engine, &DebuggerEngine::aboutToNotifyInferiorSetupOk,
this, &DebuggerRunControl::aboutToNotifyInferiorSetupOk);
}
DebuggerRunControl::~DebuggerRunControl()
......@@ -186,6 +193,16 @@ void DebuggerRunControl::startFailed()
m_engine->handleStartFailed();
}
void DebuggerRunControl::notifyEngineRemoteServerRunning(const QByteArray &msg, int pid)
{
m_engine->notifyEngineRemoteServerRunning(msg, pid);
}
void DebuggerRunControl::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
{
m_engine->notifyEngineRemoteSetupFinished(result);
}
void DebuggerRunControl::handleFinished()
{
appendMessage(tr("Debugging has finished") + QLatin1Char('\n'), NormalMessageFormat);
......@@ -222,15 +239,39 @@ void DebuggerRunControl::debuggingFinished()
emit finished();
}
void DebuggerRunControl::showMessage(const QString &msg, int channel)
{
m_engine->showMessage(msg, channel);
}
bool DebuggerRunControl::isRunning() const
{
return m_running;
}
DebuggerEngine *DebuggerRunControl::engine()
DebuggerStartParameters &DebuggerRunControl::startParameters()
{
return m_engine->startParameters();
}
void DebuggerRunControl::notifyInferiorIll()
{
m_engine->notifyInferiorIll();
}
void DebuggerRunControl::notifyInferiorExited()
{
m_engine->notifyInferiorExited();
}
void DebuggerRunControl::quitDebugger()
{
m_engine->quitDebugger();
}
void DebuggerRunControl::abortDebugger()
{
QTC_CHECK(m_engine);
return m_engine;
m_engine->abortDebugger();
}
////////////////////////////////////////////////////////////////////////
......
......@@ -40,7 +40,10 @@ namespace ProjectExplorer { class Kit; }
namespace Debugger {
class DebuggerEngine;
class RemoteSetupResult;
namespace Internal { class DebuggerEngine; }
class DebuggerStartParameters;
class DEBUGGER_EXPORT DebuggerRunControl
......@@ -59,20 +62,32 @@ public:
QString displayName() const;
void startFailed();
void notifyEngineRemoteServerRunning(const QByteArray &msg, int pid);
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result);
void notifyInferiorIll();
Q_SLOT void notifyInferiorExited();
void quitDebugger();
void abortDebugger();
void debuggingFinished();
DebuggerEngine *engine();
void showMessage(const QString &msg, int channel = LogDebug);
DebuggerStartParameters &startParameters();
signals:
void engineRequestSetup();
void requestRemoteSetup();
void aboutToNotifyInferiorSetupOk();
void stateChanged(Debugger::DebuggerState state);
private slots:
void handleFinished();
private:
friend class DebuggerRunControlFactory;
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerEngine *engine);
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
Internal::DebuggerEngine *engine);
DebuggerEngine *m_engine;
Internal::DebuggerEngine *m_engine;
bool m_running;
};
......@@ -91,7 +106,7 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
static DebuggerEngine *createEngine(DebuggerEngineType et,
static Internal::DebuggerEngine *createEngine(DebuggerEngineType et,
const DebuggerStartParameters &sp,
QString *errorMessage);
......
......@@ -42,11 +42,9 @@ class QAbstractItemModel;
QT_END_NAMESPACE
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerEngine;
class StackFrame;
class DebuggerToolTipContext
......
......@@ -34,13 +34,12 @@
#include <QObject>
namespace Debugger {
namespace Internal {
class DebuggerEngine;
namespace Internal {
class DisassemblerAgentPrivate;
class DisassemblerLines;
class Location;
class DisassemblerAgentPrivate;
class DisassemblerAgent : public QObject
{
......
......@@ -60,7 +60,7 @@ class WatchData;
class DisassemblerAgentCookie;
class DisassemblerLines;
class GdbEngine : public Debugger::DebuggerEngine
class GdbEngine : public DebuggerEngine
{
Q_OBJECT
......
......@@ -333,12 +333,6 @@ void GdbRemoteServerEngine::handleTargetExtendedAttach(const GdbResponse &respon
}
}
void GdbRemoteServerEngine::notifyInferiorSetupOk()
{
emit aboutToNotifyInferiorSetupOk();
GdbEngine::notifyInferiorSetupOk();
}
void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response)
{
QTC_ASSERT(m_isQnxGdb, qDebug() << m_isQnxGdb);
......
......@@ -66,7 +66,6 @@ signals:
* a server start script should be used, but none is given.
*/
void requestSetup();
void aboutToNotifyInferiorSetupOk();
private:
Q_SLOT void readUploadStandardOutput();
......@@ -77,7 +76,6 @@ private:
void notifyEngineRemoteServerRunning(const QByteArray &serverChannel, int inferiorPid);
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result);
void notifyInferiorSetupOk();
void handleSetTargetAsync(const GdbResponse &response);
void handleFileExecAndSymbols(const GdbResponse &response);
......
......@@ -44,11 +44,11 @@ namespace Core { class IEditor; }
namespace ProjectExplorer { class Abi; }
namespace Debugger {
namespace Internal {
class DebuggerEngine;
namespace Internal {
class MemoryView;
class MemoryMarkup
{
public:
......
......@@ -39,11 +39,9 @@ class QSortFilterProxyModel;
QT_END_NAMESPACE
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerEngine;
class ModulesModel;
//////////////////////////////////////////////////////////////////
......
......@@ -43,11 +43,10 @@ class QDebugMessageClient;
}
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class BaseQmlDebuggerClient;
class DebuggerEngine;
class QmlAdapterPrivate;
class QmlAdapter : public QObject
......
......@@ -408,7 +408,6 @@ void QmlCppEngine::notifyInferiorShutdownOk()
void QmlCppEngine::notifyInferiorSetupOk()
{
EDEBUG("\nMASTER INFERIOR SETUP OK");
emit aboutToNotifyInferiorSetupOk();
DebuggerEngine::notifyInferiorSetupOk();
}
......
......@@ -130,9 +130,6 @@ protected:
void notifyInferiorSetupOk();
void notifyEngineRemoteServerRunning(const QByteArray &, int pid);
signals:
void aboutToNotifyInferiorSetupOk();
private:
void engineStateChanged(DebuggerState newState);
void setState(DebuggerState newState, bool forced = false);
......
......@@ -351,12 +351,6 @@ QmlEngine::~QmlEngine()
Core::EditorManager::closeDocuments(documentsToClose.toList());
}
void QmlEngine::notifyInferiorSetupOk()
{
emit aboutToNotifyInferiorSetupOk();
DebuggerEngine::notifyInferiorSetupOk();
}
void QmlEngine::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
......
......@@ -60,7 +60,6 @@ public:
DebuggerEngine *masterEngine = 0);
~QmlEngine();
void notifyInferiorSetupOk();
void notifyEngineRemoteServerRunning(const QByteArray &, int pid);
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result);
......@@ -90,7 +89,6 @@ public:
signals:
void tooltipRequested(const QPoint &mousePos,
TextEditor::TextEditorWidget *editorWidget, int cursorPos);
void aboutToNotifyInferiorSetupOk();
private slots:
void disconnected();
......
......@@ -47,11 +47,9 @@ class FileReference;
}
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerEngine;
class WatchTreeView;
class QmlAdapter;
class QmlInspectorAgent;
......
......@@ -37,11 +37,9 @@
#include <qmldebug/baseenginedebugclient.h>
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class DebuggerEngine;