diff options
5 files changed, 31 insertions, 45 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index a3f59870a2..f85c7f704d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -58,9 +58,9 @@ QT_BEGIN_NAMESPACE const QV4DataCollector::Ref QV4DataCollector::s_invalidRef = std::numeric_limits<QV4DataCollector::Ref>::max(); -QV4::CallContext *QV4DataCollector::findContext(QV4::ExecutionEngine *engine, int frame) +QV4::CallContext *QV4DataCollector::findContext(int frame) { - QV4::ExecutionContext *ctx = engine->currentContext; + QV4::ExecutionContext *ctx = engine()->currentContext; while (ctx) { QV4::CallContext *cCtxt = ctx->asCallContext(); if (cCtxt && cCtxt->d()->function) { @@ -68,7 +68,7 @@ QV4::CallContext *QV4DataCollector::findContext(QV4::ExecutionEngine *engine, in return cCtxt; --frame; } - ctx = engine->parentContext(ctx); + ctx = engine()->parentContext(ctx); } return 0; @@ -87,13 +87,12 @@ QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::ExecutionContext *ctxt, return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0; } -QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes( - QV4::ExecutionEngine *engine, int frame) +QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes(int frame) { QVector<QV4::Heap::ExecutionContext::ContextType> types; - QV4::Scope scope(engine); - QV4::CallContext *sctxt = findContext(engine, frame); + QV4::Scope scope(engine()); + QV4::CallContext *sctxt = findContext(frame); if (!sctxt || sctxt->d()->type < QV4::Heap::ExecutionContext::Type_QmlContext) return types; @@ -254,7 +253,7 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) QStringList names; QV4::Scope scope(engine()); - QV4::Scoped<QV4::CallContext> ctxt(scope, findScope(findContext(engine(), frameNr), scopeNr)); + QV4::Scoped<QV4::CallContext> ctxt(scope, findScope(findContext(frameNr), scopeNr)); if (!ctxt) return false; @@ -314,7 +313,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int QJsonArray scopes; QV4::Scope scope(engine()); - QV4::ScopedContext ctxt(scope, findContext(engine(), frameNr)); + QV4::ScopedContext ctxt(scope, findContext(frameNr)); while (ctxt) { if (QV4::CallContext *cCtxt = ctxt->asCallContext()) { if (cCtxt->d()->activation) @@ -329,7 +328,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int } // Only type and index are used by Qt Creator, so we keep it easy: - QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(engine(), frameNr); + QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(frameNr); for (int i = 0, ei = scopeTypes.count(); i != ei; ++i) { int type = encodeScopeType(scopeTypes[i]); if (type == -1) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 1c3a05960c..aea03d2257 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -56,12 +56,12 @@ public: typedef QVector<uint> Refs; static const Ref s_invalidRef; - static QV4::CallContext *findContext(QV4::ExecutionEngine *engine, int frame); static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope); - static QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes( - QV4::ExecutionEngine *engine, int frame); static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); + QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes(int frame); + QV4::CallContext *findContext(int frame); + QV4DataCollector(QV4::ExecutionEngine *engine); Ref collect(const QV4::ScopedValue &value); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index d60db6cf82..a2d2fff72b 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -173,7 +173,7 @@ void ScopeJob::run() if (success) { QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = - QV4DataCollector::getScopeTypes(collector->engine(), frameNr); + collector->getScopeTypes(frameNr); result[QLatin1String("type")] = QV4DataCollector::encodeScopeType(scopeTypes[scopeNr]); } else { result[QLatin1String("type")] = -1; @@ -270,24 +270,6 @@ const QStringList &GatherSourcesJob::result() const return sources; } -ExceptionCollectJob::ExceptionCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector) - : engine(engine) - , collector(collector) - , exception(QV4DataCollector::s_invalidRef) -{} - -void ExceptionCollectJob::run() -{ - QV4::Scope scope(engine); - QV4::ScopedValue v(scope, *engine->exceptionValue); - exception = collector->collect(v); -} - -QV4DataCollector::Ref ExceptionCollectJob::exceptionValue() const -{ - return exception; -} - EvalJob::EvalJob(QV4::ExecutionEngine *engine, const QString &script) : JavaScriptJob(engine, /*frameNr*/-1, script), result(false) {} diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h index a1adbeff40..721f42b7c2 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h @@ -154,18 +154,6 @@ public: const QStringList &result() const; }; -class ExceptionCollectJob: public QV4DebugJob -{ - QV4::ExecutionEngine *engine; - QV4DataCollector *collector; - QV4DataCollector::Ref exception; - -public: - ExceptionCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector); - void run(); - QV4DataCollector::Ref exceptionValue() const; -}; - class EvalJob: public JavaScriptJob { bool result; diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 7398e97326..1b2df62b76 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -93,6 +93,23 @@ signals: void evaluateFinished(); }; +class ExceptionCollectJob: public CollectJob +{ + QV4DataCollector::Ref exception; + +public: + ExceptionCollectJob(QV4DataCollector *collector) : + CollectJob(collector), exception(-1) {} + + void run() { + QV4::Scope scope(collector->engine()); + QV4::ScopedValue v(scope, *collector->engine()->exceptionValue); + exception = collector->collect(v); + } + + QV4DataCollector::Ref exceptionValue() const { return exception; } +}; + class TestAgent : public QObject { Q_OBJECT @@ -170,7 +187,7 @@ public slots: m_statesWhenPaused << debugger->currentExecutionState(); if (debugger->state() == QV4Debugger::Paused && debugger->engine()->hasException) { - ExceptionCollectJob job(debugger->engine(), &collector); + ExceptionCollectJob job(&collector); debugger->runInEngine(&job); m_thrownValue = job.exceptionValue(); } |