diff options
author | hjk <hjk@theqtcompany.com> | 2015-10-13 16:58:04 +0200 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2015-10-14 13:38:07 +0000 |
commit | 23f3fcbabc4959c5d05d821b25776f6344d9b42b (patch) | |
tree | 30f749073da023dfac58e3216c83275ac5509e56 /src/qml/jsruntime | |
parent | 4f3379352a265bab00a7265f85ffc38a9ca4ffe4 (diff) |
QmlDebug: Split QV4::Debugging::Debugger
... into a pure interface and a QV4::Debugging::V4Debugger implementation.
This is in preparation of a second implementation of this interface
to be used with 'native mixed' debugging.
Change-Id: I3078dcfe4bdee392a2d13ef43a55ca993e7b88d8
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4debugging.cpp | 48 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4debugging_p.h | 21 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 |
4 files changed, 44 insertions, 31 deletions
diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 79fd58f700..7706a40da6 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; using namespace QV4::Debugging; -Debugger::JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, +V4Debugger::JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, const QString &script) : engine(engine) , frameNr(frameNr) @@ -62,7 +62,7 @@ Debugger::JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr , resultIsException(false) {} -void Debugger::JavaScriptJob::run() +void V4Debugger::JavaScriptJob::run() { Scope scope(engine); @@ -92,18 +92,18 @@ void Debugger::JavaScriptJob::run() handleResult(result); } -bool Debugger::JavaScriptJob::hasExeption() const +bool V4Debugger::JavaScriptJob::hasExeption() const { return resultIsException; } -class EvalJob: public Debugger::JavaScriptJob +class EvalJob: public V4Debugger::JavaScriptJob { bool result; public: EvalJob(QV4::ExecutionEngine *engine, const QString &script) - : Debugger::JavaScriptJob(engine, /*frameNr*/-1, script) + : V4Debugger::JavaScriptJob(engine, /*frameNr*/-1, script) , result(false) {} @@ -118,7 +118,7 @@ public: } }; -Debugger::Debugger(QV4::ExecutionEngine *engine) +V4Debugger::V4Debugger(QV4::ExecutionEngine *engine) : m_engine(engine) , m_state(Running) , m_stepping(NotStepping) @@ -129,11 +129,11 @@ Debugger::Debugger(QV4::ExecutionEngine *engine) , m_gatherSources(0) , m_runningJob(0) { - qMetaTypeId<Debugger*>(); + qMetaTypeId<V4Debugger*>(); qMetaTypeId<PauseReason>(); } -void Debugger::pause() +void V4Debugger::pause() { QMutexLocker locker(&m_lock); if (m_state == Paused) @@ -141,7 +141,7 @@ void Debugger::pause() m_pauseRequested = true; } -void Debugger::resume(Speed speed) +void V4Debugger::resume(Speed speed) { QMutexLocker locker(&m_lock); if (m_state != Paused) @@ -155,28 +155,28 @@ void Debugger::resume(Speed speed) m_runningCondition.wakeAll(); } -void Debugger::addBreakPoint(const QString &fileName, int lineNumber, const QString &condition) +void V4Debugger::addBreakPoint(const QString &fileName, int lineNumber, const QString &condition) { QMutexLocker locker(&m_lock); m_breakPoints.insert(DebuggerBreakPoint(fileName.mid(fileName.lastIndexOf('/') + 1), lineNumber), condition); m_haveBreakPoints = true; } -void Debugger::removeBreakPoint(const QString &fileName, int lineNumber) +void V4Debugger::removeBreakPoint(const QString &fileName, int lineNumber) { QMutexLocker locker(&m_lock); m_breakPoints.remove(DebuggerBreakPoint(fileName.mid(fileName.lastIndexOf('/') + 1), lineNumber)); m_haveBreakPoints = !m_breakPoints.isEmpty(); } -void Debugger::setBreakOnThrow(bool onoff) +void V4Debugger::setBreakOnThrow(bool onoff) { QMutexLocker locker(&m_lock); m_breakOnThrow = onoff; } -Debugger::ExecutionState Debugger::currentExecutionState() const +V4Debugger::ExecutionState V4Debugger::currentExecutionState() const { ExecutionState state; state.fileName = getFunction()->sourceFile(); @@ -185,12 +185,12 @@ Debugger::ExecutionState Debugger::currentExecutionState() const return state; } -QVector<StackFrame> Debugger::stackTrace(int frameLimit) const +QVector<StackFrame> V4Debugger::stackTrace(int frameLimit) const { return m_engine->stackTrace(frameLimit); } -void Debugger::maybeBreakAtInstruction() +void V4Debugger::maybeBreakAtInstruction() { if (m_runningJob) // do not re-enter when we're doing a job for the debugger. return; @@ -228,7 +228,7 @@ void Debugger::maybeBreakAtInstruction() } } -void Debugger::enteringFunction() +void V4Debugger::enteringFunction() { if (m_runningJob) return; @@ -239,7 +239,7 @@ void Debugger::enteringFunction() } } -void Debugger::leavingFunction(const ReturnedValue &retVal) +void V4Debugger::leavingFunction(const ReturnedValue &retVal) { if (m_runningJob) return; @@ -254,7 +254,7 @@ void Debugger::leavingFunction(const ReturnedValue &retVal) } } -void Debugger::aboutToThrow() +void V4Debugger::aboutToThrow() { if (!m_breakOnThrow) return; @@ -266,7 +266,7 @@ void Debugger::aboutToThrow() pauseAndWait(Throwing); } -Function *Debugger::getFunction() const +Function *V4Debugger::getFunction() const { Scope scope(m_engine); ExecutionContext *context = m_engine->currentContext; @@ -277,7 +277,7 @@ Function *Debugger::getFunction() const return context->d()->engine->globalCode; } -void Debugger::pauseAndWait(PauseReason reason) +void V4Debugger::pauseAndWait(PauseReason reason) { if (m_runningJob) return; @@ -298,7 +298,7 @@ void Debugger::pauseAndWait(PauseReason reason) m_state = Running; } -bool Debugger::reallyHitTheBreakPoint(const QString &filename, int linenr) +bool V4Debugger::reallyHitTheBreakPoint(const QString &filename, int linenr) { BreakPoints::iterator it = m_breakPoints.find(DebuggerBreakPoint(filename.mid(filename.lastIndexOf('/') + 1), linenr)); if (it == m_breakPoints.end()) @@ -316,13 +316,13 @@ bool Debugger::reallyHitTheBreakPoint(const QString &filename, int linenr) return evilJob.resultAsBoolean(); } -void Debugger::runInEngine(Debugger::Job *job) +void V4Debugger::runInEngine(V4Debugger::Job *job) { QMutexLocker locker(&m_lock); runInEngine_havingLock(job); } -void Debugger::runInEngine_havingLock(Debugger::Job *job) +void V4Debugger::runInEngine_havingLock(V4Debugger::Job *job) { Q_ASSERT(job); Q_ASSERT(m_runningJob == 0); @@ -333,7 +333,7 @@ void Debugger::runInEngine_havingLock(Debugger::Job *job) m_runningJob = 0; } -Debugger::Job::~Job() +V4Debugger::Job::~Job() { } diff --git a/src/qml/jsruntime/qv4debugging_p.h b/src/qml/jsruntime/qv4debugging_p.h index 9b07a31f26..fdc9cac24f 100644 --- a/src/qml/jsruntime/qv4debugging_p.h +++ b/src/qml/jsruntime/qv4debugging_p.h @@ -93,6 +93,19 @@ typedef QHash<DebuggerBreakPoint, QString> BreakPoints; class Q_QML_EXPORT Debugger : public QObject { Q_OBJECT + +public: + virtual ~Debugger() {} + virtual bool pauseAtNextOpportunity() const = 0; + virtual void maybeBreakAtInstruction() = 0; + virtual void enteringFunction() = 0; + virtual void leavingFunction(const ReturnedValue &retVal) = 0; + virtual void aboutToThrow() = 0; +}; + +class Q_QML_EXPORT V4Debugger : public Debugger +{ + Q_OBJECT public: class Q_QML_EXPORT Job { @@ -131,7 +144,7 @@ public: NotStepping = FullThrottle }; - Debugger(ExecutionEngine *engine); + V4Debugger(ExecutionEngine *engine); ExecutionEngine *engine() const { return m_engine; } @@ -173,14 +186,14 @@ public: // execution hooks void aboutToThrow(); signals: - void sourcesCollected(QV4::Debugging::Debugger *self, const QStringList &sources, int seq); - void debuggerPaused(QV4::Debugging::Debugger *self, QV4::Debugging::PauseReason reason); + void sourcesCollected(QV4::Debugging::V4Debugger *self, const QStringList &sources, int seq); + void debuggerPaused(QV4::Debugging::V4Debugger *self, QV4::Debugging::PauseReason reason); private: // requires lock to be held void pauseAndWait(PauseReason reason); bool reallyHitTheBreakPoint(const QString &filename, int linenr); - void runInEngine_havingLock(Debugger::Job *job); + void runInEngine_havingLock(V4Debugger::Job *job); private: QV4::ExecutionEngine *m_engine; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 6fe14da850..2732f360b3 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -518,10 +518,10 @@ ExecutionEngine::~ExecutionEngine() delete [] argumentsAccessors; } -void ExecutionEngine::enableDebugger() +void ExecutionEngine::setDebugger(Debugging::Debugger *debugger_) { Q_ASSERT(!debugger); - debugger = new Debugging::Debugger(this); + debugger = debugger_; iselFactory.reset(new Moth::ISelFactory); } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index e94b417908..4640f3f4cc 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -366,7 +366,7 @@ public: ExecutionEngine(EvalISelFactory *iselFactory = 0); ~ExecutionEngine(); - void enableDebugger(); + void setDebugger(Debugging::Debugger *debugger); void enableProfiler(); ExecutionContext *pushGlobalContext(); |