From 4ac85039a2e3cd092ad51ae726e01d1eef46e37a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 22 Jun 2017 10:52:28 +0200 Subject: Various compile fixes Make sure all libs and tests compile again after the latest changes. Change-Id: I749d3d2d0109cc97df2ecec93809ea8a1b3014a9 Reviewed-by: Erik Verbruggen --- src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp | 1 - src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index 168a08865c..14954bf380 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -706,7 +706,6 @@ void QV4DebugServiceImpl::engineAdded(QJSEngine *engine) QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); if (QQmlDebugConnector *server = QQmlDebugConnector::instance()) { if (ee) { - ee->iselFactory.reset(new QV4::Moth::ISelFactory); QV4Debugger *debugger = new QV4Debugger(ee); if (state() == Enabled) ee->setDebugger(debugger); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index d536fd51ed..41ce9ac6dc 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -731,7 +731,6 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeAdded(QJSEngine *engine) TRACE_PROTOCOL("Adding execution engine" << ee); if (ee) { NativeDebugger *debugger = new NativeDebugger(this, ee); - ee->iselFactory.reset(new QV4::Moth::ISelFactory); if (state() == Enabled) ee->setDebugger(debugger); m_debuggers.append(QPointer(debugger)); -- cgit v1.2.3 From 29e41a9ee61a05274f77f89e9ffd8875f90d3308 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 22 Jun 2017 10:01:17 +0200 Subject: Remove now unused files Remove all files from the old compiler pipeline that are now unused. This includes the whole IR, JIT code generation, and the old Moth Isel. Change-Id: I50d06abfbcf0e9755a54ed94638f8bb74f9512b1 Reviewed-by: Erik Verbruggen --- src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp | 1 - src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index 14954bf380..f3617ed6ff 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -43,7 +43,6 @@ #include "qqmldebugpacket.h" #include -#include #include #include #include diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 41ce9ac6dc..5e4a8e3eb1 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From d3a1a9e4fea5f6b623ebd13f43957ebbe5bfabea Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 4 Jul 2017 22:23:17 +0200 Subject: Unify SimpleCallContext and CallContext Plan is to completely remove the need for the simple call context. Change-Id: Ie5e4673a6746dc110adbf526e45188f218fd7bfc Reviewed-by: Erik Verbruggen --- .../qmltooling/qmldbg_debugger/qv4datacollector.cpp | 14 +++++++------- src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h | 4 ++-- .../qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index e89b7a63d4..6686e61a1c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -55,11 +55,11 @@ QT_BEGIN_NAMESPACE -QV4::SimpleCallContext *QV4DataCollector::findContext(int frame) +QV4::CallContext *QV4DataCollector::findContext(int frame) { QV4::ExecutionContext *ctx = engine()->currentContext; while (ctx) { - QV4::SimpleCallContext *cCtxt = ctx->asSimpleCallContext(); + QV4::CallContext *cCtxt = ctx->asCallContext(); if (cCtxt && cCtxt->d()->v4Function) { if (frame < 1) return cCtxt; @@ -71,7 +71,7 @@ QV4::SimpleCallContext *QV4DataCollector::findContext(int frame) return 0; } -QV4::Heap::SimpleCallContext *QV4DataCollector::findScope(QV4::ExecutionContext *ctxt, int scope) +QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::ExecutionContext *ctxt, int scope) { if (!ctxt) return 0; @@ -81,7 +81,7 @@ QV4::Heap::SimpleCallContext *QV4DataCollector::findScope(QV4::ExecutionContext for (; scope > 0 && ctx; --scope) ctx = ctx->d()->outer; - return (ctx && ctx->d()) ? ctx->asSimpleCallContext()->d() : 0; + return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0; } QVector QV4DataCollector::getScopeTypes(int frame) @@ -89,7 +89,7 @@ QVector QV4DataCollector::getScopeType QVector types; QV4::Scope scope(engine()); - QV4::SimpleCallContext *sctxt = findContext(frame); + QV4::CallContext *sctxt = findContext(frame); if (!sctxt || sctxt->d()->type < QV4::Heap::ExecutionContext::Type_QmlContext) return types; @@ -340,7 +340,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int QV4::Scope scope(engine()); QV4::ScopedContext ctxt(scope, findContext(frameNr)); while (ctxt) { - if (QV4::SimpleCallContext *cCtxt = ctxt->asSimpleCallContext()) { + if (QV4::CallContext *cCtxt = ctxt->asCallContext()) { if (cCtxt->d()->activation) break; } @@ -348,7 +348,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int } if (ctxt) { - QV4::ScopedValue o(scope, ctxt->asSimpleCallContext()->d()->activation); + QV4::ScopedValue o(scope, ctxt->d()->activation); frame[QLatin1String("receiver")] = toRef(collect(o)); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index de12e8d527..2c2514a1b3 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -58,11 +58,11 @@ public: typedef uint Ref; typedef QVector Refs; - static QV4::Heap::SimpleCallContext *findScope(QV4::ExecutionContext *ctxt, int scope); + static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope); static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); QVector getScopeTypes(int frame); - QV4::SimpleCallContext *findContext(int frame); + QV4::CallContext *findContext(int frame); QV4DataCollector(QV4::ExecutionEngine *engine); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 5e4a8e3eb1..13425b36c2 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -480,7 +480,7 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a QJsonArray output; QV4::Scope scope(engine); - if (QV4::SimpleCallContext *callContext = executionContext->asSimpleCallContext()) { + if (QV4::CallContext *callContext = executionContext->asCallContext()) { QV4::Value thisObject = callContext->thisObject(); collector.collect(&output, QString(), QStringLiteral("this"), thisObject); QV4::Identifier *const *variables = callContext->variables(); -- cgit v1.2.3 From c0f961cd6b82a523e277f6d8778a20508b15697d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 3 Aug 2017 20:26:28 +0200 Subject: Change function signatures for call/construct back Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen --- .../qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 13425b36c2..59d4687615 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -207,7 +207,7 @@ private: void handleDebuggerDeleted(QObject *debugger); - void evaluateExpression(QV4::Scope &scope, const QString &expression); + QV4::ReturnedValue evaluateExpression(const QString &expression); bool checkCondition(const QString &expression); QStringList breakOnSignals; @@ -239,13 +239,12 @@ private: bool NativeDebugger::checkCondition(const QString &expression) { - QV4::Scope scope(m_engine); - evaluateExpression(scope, expression); - return scope.result.booleanValue(); + return evaluateExpression(expression).booleanValue(); } -void NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expression) +QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) { + QV4::Scope scope(m_engine); m_runningJob = true; QV4::ExecutionContextSaver saver(scope); @@ -260,9 +259,10 @@ void NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expres script.inheritContext = true; script.parse(); if (!m_engine->hasException) - scope.result = script.run(); + return script.run(); m_runningJob = false; + return QV4::Encode::undefined(); } NativeDebugger::NativeDebugger(QQmlNativeDebugServiceImpl *service, QV4::ExecutionEngine *engine) @@ -542,8 +542,7 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject TRACE_PROTOCOL("Evaluate expression: " << expression); m_runningJob = true; - evaluateExpression(scope, expression); - QV4::ScopedValue result(scope, scope.result); + QV4::ScopedValue result(scope, evaluateExpression(expression)); m_runningJob = false; if (result->isUndefined()) { -- cgit v1.2.3 From 7835060518a2280bda4ca28684b78a1481677158 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 4 Aug 2017 10:03:03 +0200 Subject: Fix frame handling Fix some regressions introduced by change 1ae1eaf59e0475a2dc9c5e22e53e9be19d0f2feb. Change-Id: I24c1db78634e3beb1ab090325b60e70f788f92a7 Reviewed-by: Erik Verbruggen --- .../qmltooling/qmldbg_debugger/qv4debugger.cpp | 4 +- .../qmldbg_debugger/qv4debuggeragent.cpp | 17 ++++----- .../qqmlnativedebugservice.cpp | 44 +++++++++++----------- 3 files changed, 32 insertions(+), 33 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index b82df9c6a9..1bd8581fbb 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -158,7 +158,7 @@ QV4Debugger::ExecutionState QV4Debugger::currentExecutionState() const { ExecutionState state; state.fileName = getFunction()->sourceFile(); - state.lineNumber = engine()->current->lineNumber; + state.lineNumber = engine()->currentStackFrame->line; return state; } @@ -203,7 +203,7 @@ void QV4Debugger::maybeBreakAtInstruction() pauseAndWait(PauseRequest); } else if (m_haveBreakPoints) { if (QV4::Function *f = getFunction()) { - const int lineNumber = engine()->current->lineNumber; + const int lineNumber = engine()->currentStackFrame->line; if (reallyHitTheBreakPoint(f->sourceFile(), lineNumber)) pauseAndWait(BreakPointHit); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 9a34d5770a..09ed9ac98c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -79,20 +79,19 @@ void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseR case QV4Debugger::PauseRequest: case QV4Debugger::BreakPointHit: { event.insert(QStringLiteral("event"), QStringLiteral("break")); - QVector frames = debugger->stackTrace(1); - if (frames.isEmpty()) + QV4::EngineBase::StackFrame *frame = debugger->engine()->currentStackFrame; + if (!frame) break; - const QV4::StackFrame &topFrame = frames.first(); - body.insert(QStringLiteral("invocationText"), topFrame.function); - body.insert(QStringLiteral("sourceLine"), topFrame.line - 1); - if (topFrame.column > 0) - body.insert(QStringLiteral("sourceColumn"), topFrame.column); + body.insert(QStringLiteral("invocationText"), frame->function()); + body.insert(QStringLiteral("sourceLine"), frame->line - 1); + if (frame->column > 0) + body.insert(QStringLiteral("sourceColumn"), frame->column); QJsonArray breakPoints; - foreach (int breakPointId, breakPointIds(topFrame.source, topFrame.line)) + foreach (int breakPointId, breakPointIds(frame->source(), frame->line)) breakPoints.push_back(breakPointId); body.insert(QStringLiteral("breakpoints"), breakPoints); - script.insert(QStringLiteral("name"), topFrame.source); + script.insert(QStringLiteral("name"), frame->source()); } break; case QV4Debugger::Throwing: // TODO: complete this! diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 59d4687615..cbf4eb1539 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -239,7 +239,9 @@ private: bool NativeDebugger::checkCondition(const QString &expression) { - return evaluateExpression(expression).booleanValue(); + QV4::Scope scope(m_engine); + QV4::ScopedValue r(scope, evaluateExpression(expression)); + return r->booleanValue(); } QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) @@ -333,25 +335,24 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a int limit = arguments.value(QLatin1String("limit")).toInt(0); QJsonArray frameArray; - QV4::ExecutionContext *executionContext = m_engine->currentContext; - for (int i = 0; i < limit && executionContext; ++i) { - if (QV4::Function *function = executionContext->getFunction()) { + QV4::EngineBase::StackFrame *f= m_engine->currentStackFrame; + for (int i = 0; i < limit && f; ++i) { + QV4::Function *function = f->v4Function; - QJsonObject frame; - frame.insert(QStringLiteral("language"), QStringLiteral("js")); - frame.insert(QStringLiteral("context"), encodeContext(executionContext)); + QJsonObject frame; + frame.insert(QStringLiteral("language"), QStringLiteral("js")); + frame.insert(QStringLiteral("context"), encodeContext(nullptr /*#### context*/)); - if (QV4::Heap::String *functionName = function->name()) - frame.insert(QStringLiteral("function"), functionName->toQString()); - frame.insert(QStringLiteral("file"), function->sourceFile()); + if (QV4::Heap::String *functionName = function->name()) + frame.insert(QStringLiteral("function"), functionName->toQString()); + frame.insert(QStringLiteral("file"), function->sourceFile()); - int line = executionContext->d()->lineNumber; - frame.insert(QStringLiteral("line"), (line < 0 ? -line : line)); + int line = f->line; + frame.insert(QStringLiteral("line"), (line < 0 ? -line : line)); - frameArray.push_back(frame); - } + frameArray.push_back(frame); - executionContext = m_engine->parentContext(executionContext); + f = f->parent; } response->insert(QStringLiteral("frames"), frameArray); @@ -621,7 +622,7 @@ void NativeDebugger::maybeBreakAtInstruction() if (m_service->m_breakHandler->m_haveBreakPoints) { if (QV4::Function *function = getFunction()) { - const int lineNumber = m_engine->current->lineNumber; + const int lineNumber = m_engine->currentStackFrame->line; if (reallyHitTheBreakPoint(function, lineNumber)) pauseAndWait(); } @@ -679,12 +680,11 @@ void NativeDebugger::pauseAndWait() event.insert(QStringLiteral("event"), QStringLiteral("break")); event.insert(QStringLiteral("language"), QStringLiteral("js")); - if (QV4::ExecutionContext *executionContext = m_engine->currentContext) { - if (QV4::Function *function = executionContext->getFunction()) { - event.insert(QStringLiteral("file"), function->sourceFile()); - int line = executionContext->d()->lineNumber; - event.insert(QStringLiteral("line"), (line < 0 ? -line : line)); - } + if (QV4::EngineBase::StackFrame *frame = m_engine->currentStackFrame) { + QV4::Function *function = frame->v4Function; + event.insert(QStringLiteral("file"), function->sourceFile()); + int line = frame->line; + event.insert(QStringLiteral("line"), (line < 0 ? -line : line)); } m_service->emitAsynchronousMessageToClient(event); -- cgit v1.2.3 From f284d73ccece0490b4a227c788b9415a59a38d9c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 5 Aug 2017 00:03:52 +0200 Subject: Avoid creating a separate Scope in the ExecutionContextSaver There's no reason this class should create a scope on it's own. Change-Id: I93bddea8be42a908a1aca1bcb0ec867aae0d29f8 Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 +- src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 107ec60943..ebd28b36e0 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -63,7 +63,7 @@ void JavaScriptJob::run() { QV4::Scope scope(engine); - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(engine); QV4::ExecutionContext *ctx = engine->currentContext; QObject scopeObject; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index cbf4eb1539..c4d5e5f683 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -249,7 +249,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Scope scope(m_engine); m_runningJob = true; - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(m_engine); QV4::ExecutionContext *ctx = m_engine->currentContext; m_engine->pushContext(ctx); -- cgit v1.2.3 From eb2c08f57493aa12850e6cddff2cc3527e7cbfd7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 7 Aug 2017 14:43:03 +0200 Subject: Get rid of ExecutionContext::strictMode This should be done by generating different byte code for the strict/non strict cases. For now the VME has a workaround checking the isStrict() flag of QV4::Function. Change-Id: I2faa9e9184ffc5274491067e67f665d6989b54c2 Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 +- src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index ebd28b36e0..80ead1516a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -113,7 +113,7 @@ void JavaScriptJob::run() } QV4::Script script(ctx, this->script); - script.strictMode = ctx->d()->strictMode; + script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index c4d5e5f683..7f11cea9ab 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -255,7 +255,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) m_engine->pushContext(ctx); QV4::Script script(ctx, expression); - script.strictMode = ctx->d()->strictMode; + script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. script.inheritContext = true; -- cgit v1.2.3 From 5bc4f4d958a3b76f3435d61206ca0109f07aa1a3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 8 Aug 2017 10:56:34 +0200 Subject: Refactor context handling Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qv4datacollector.cpp | 38 ++++++++-------------- .../qmltooling/qmldbg_debugger/qv4datacollector.h | 4 +-- .../qmltooling/qmldbg_debugger/qv4debugger.cpp | 24 +++++--------- .../qmltooling/qmldbg_debugger/qv4debugger.h | 2 +- .../qmltooling/qmldbg_debugger/qv4debugjob.cpp | 38 ++++++++-------------- .../qqmlnativedebugservice.cpp | 19 +++++------ 6 files changed, 47 insertions(+), 78 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 6686e61a1c..76d5315004 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -55,47 +55,37 @@ QT_BEGIN_NAMESPACE -QV4::CallContext *QV4DataCollector::findContext(int frame) +QV4::Heap::CallContext *QV4DataCollector::findContext(int frame) { - QV4::ExecutionContext *ctx = engine()->currentContext; - while (ctx) { - QV4::CallContext *cCtxt = ctx->asCallContext(); - if (cCtxt && cCtxt->d()->v4Function) { - if (frame < 1) - return cCtxt; - --frame; - } - ctx = engine()->parentContext(ctx); + QV4::EngineBase::StackFrame *f = engine()->currentStackFrame; + while (f && frame) { + --frame; + f = f->parent; } - return 0; + return f ? f->callContext() : 0; } -QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::ExecutionContext *ctxt, int scope) +QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) { - if (!ctxt) + if (!ctx) return 0; - QV4::Scope s(ctxt); - QV4::ScopedContext ctx(s, ctxt); for (; scope > 0 && ctx; --scope) - ctx = ctx->d()->outer; + ctx = ctx->outer; - return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0; + return (ctx && ctx->type == QV4::Heap::ExecutionContext::Type_CallContext) ? + static_cast(ctx) : 0; } QVector QV4DataCollector::getScopeTypes(int frame) { QVector types; - QV4::Scope scope(engine()); - QV4::CallContext *sctxt = findContext(frame); - if (!sctxt || sctxt->d()->type < QV4::Heap::ExecutionContext::Type_QmlContext) - return types; + QV4::Heap::ExecutionContext *it = findContext(frame); - QV4::ScopedContext it(scope, sctxt); - for (; it; it = it->d()->outer) - types.append(QV4::Heap::ExecutionContext::ContextType(it->d()->type)); + for (; it; it = it->outer) + types.append(QV4::Heap::ExecutionContext::ContextType(it->type)); return types; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 2c2514a1b3..c924f10d8c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -58,11 +58,11 @@ public: typedef uint Ref; typedef QVector Refs; - static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope); + static QV4::Heap::CallContext *findScope(QV4::Heap::ExecutionContext *ctxt, int scope); static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); QVector getScopeTypes(int frame); - QV4::CallContext *findContext(int frame); + QV4::Heap::CallContext *findContext(int frame); QV4DataCollector(QV4::ExecutionEngine *engine); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 1bd8581fbb..c95d4ea99f 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -115,7 +115,7 @@ void QV4Debugger::resume(Speed speed) if (!m_returnedValue.isUndefined()) m_returnedValue.set(m_engine, QV4::Encode::undefined()); - m_currentContext.set(m_engine, *m_engine->currentContext); + m_currentFrame = m_engine->currentStackFrame; m_stepping = speed; m_runningCondition.wakeAll(); } @@ -187,7 +187,7 @@ void QV4Debugger::maybeBreakAtInstruction() switch (m_stepping) { case StepOver: - if (m_currentContext.asManaged()->d() != m_engine->current) + if (m_currentFrame != m_engine->currentStackFrame) break; // fall through case StepIn: @@ -216,9 +216,8 @@ void QV4Debugger::enteringFunction() return; QMutexLocker locker(&m_lock); - if (m_stepping == StepIn) { - m_currentContext.set(m_engine, *m_engine->currentContext); - } + if (m_stepping == StepIn) + m_currentFrame = m_engine->currentStackFrame; } void QV4Debugger::leavingFunction(const QV4::ReturnedValue &retVal) @@ -229,13 +228,8 @@ void QV4Debugger::leavingFunction(const QV4::ReturnedValue &retVal) QMutexLocker locker(&m_lock); - if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->current) { - if (QV4::ExecutionContext *parentContext - = m_engine->parentContext(m_engine->currentContext)) { - m_currentContext.set(m_engine, *parentContext); - } else { - m_currentContext.clear(); - } + if (m_stepping != NotStepping && m_currentFrame == m_engine->currentStackFrame) { + m_currentFrame = m_currentFrame->parent; m_stepping = StepOver; m_returnedValue.set(m_engine, retVal); } @@ -255,10 +249,8 @@ void QV4Debugger::aboutToThrow() QV4::Function *QV4Debugger::getFunction() const { - QV4::Scope scope(m_engine); - QV4::ExecutionContext *context = m_engine->currentContext; - if (QV4::Function *function = context->getFunction()) - return function; + if (m_engine->currentStackFrame) + return m_engine->currentStackFrame->v4Function; else return m_engine->globalCode; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h index cd412e573d..b2200c47fc 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h @@ -150,7 +150,7 @@ private: void runJobUnpaused(); QV4::ExecutionEngine *m_engine; - QV4::PersistentValue m_currentContext; + QV4::EngineBase::StackFrame *m_currentFrame = 0; QMutex m_lock; QWaitCondition m_runningCondition; State m_state; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 80ead1516a..45af1f44a5 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -63,26 +63,20 @@ void JavaScriptJob::run() { QV4::Scope scope(engine); - QV4::ExecutionContextSaver saver(engine); - - QV4::ExecutionContext *ctx = engine->currentContext; + QV4::ScopedContext ctx(scope, engine->currentContext()); QObject scopeObject; if (frameNr > 0) { - for (int i = 0; i < frameNr; ++i) { - ctx = engine->parentContext(ctx); - } - engine->pushContext(ctx); - ctx = engine->currentContext; + QV4::EngineBase::StackFrame *f = engine->currentStackFrame; + for (int i = 0; i < frameNr; ++i) + f = f->parent; + ctx = static_cast(&f->jsFrame->context); } if (context >= 0) { QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context)); - if (extraContext) { - engine->pushContext(QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), - &scopeObject)); - ctx = engine->currentContext; - } + if (extraContext) + ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), &scopeObject); } else if (frameNr < 0) { // Use QML context if available QQmlEngine *qmlEngine = engine->qmlEngine(); if (qmlEngine) { @@ -102,13 +96,8 @@ void JavaScriptJob::run() } } } - if (!engine->qmlContext()) { - engine->pushContext(QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), - &scopeObject)); - ctx = engine->currentContext; - } - engine->pushContext(ctx->newWithContext(withContext->toObject(engine))); - ctx = engine->currentContext; + if (!engine->qmlContext()) + ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), &scopeObject); } } @@ -214,12 +203,15 @@ void ValueLookupJob::run() // set if the engine is currently executing QML code. QScopedPointer scopeObject; QV4::ExecutionEngine *engine = collector->engine(); + QV4::Scope scope(engine); + QV4::Heap::ExecutionContext *qmlContext = 0; if (engine->qmlEngine() && !engine->qmlContext()) { scopeObject.reset(new QObject); - engine->pushContext(QV4::QmlContext::create(engine->currentContext, + qmlContext = QV4::QmlContext::create(engine->currentContext(), QQmlContextData::get(engine->qmlEngine()->rootContext()), - scopeObject.data())); + scopeObject.data()); } + QV4::ScopedStackFrame frame(scope, qmlContext); for (const QJsonValue &handle : handles) { QV4DataCollector::Ref ref = handle.toInt(); if (!collector->isValidRef(ref)) { @@ -229,8 +221,6 @@ void ValueLookupJob::run() result[QString::number(ref)] = collector->lookupRef(ref, true); } flushRedundantRefs(); - if (scopeObject) - engine->popContext(); } const QString &ValueLookupJob::exceptionMessage() const diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 7f11cea9ab..32c67b3986 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -229,7 +229,7 @@ private: QV4::ExecutionEngine *m_engine; QQmlNativeDebugServiceImpl *m_service; - QV4::PersistentValue m_currentContext; + QV4::EngineBase::StackFrame *m_currentFrame = 0; Speed m_stepping; bool m_pauseRequested; bool m_runningJob; @@ -249,10 +249,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Scope scope(m_engine); m_runningJob = true; - QV4::ExecutionContextSaver saver(m_engine); - - QV4::ExecutionContext *ctx = m_engine->currentContext; - m_engine->pushContext(ctx); + QV4::ExecutionContext *ctx = m_engine->currentContext(); QV4::Script script(ctx, expression); script.strictMode = ctx->d()->v4Function->isStrict(); @@ -594,7 +591,7 @@ void NativeDebugger::handleContinue(QJsonObject *response, Speed speed) if (!m_returnedValue.isUndefined()) m_returnedValue.set(m_engine, QV4::Encode::undefined()); - m_currentContext.set(m_engine, *m_engine->currentContext); + m_currentFrame = m_engine->currentStackFrame; m_stepping = speed; } @@ -604,7 +601,7 @@ void NativeDebugger::maybeBreakAtInstruction() return; if (m_stepping == StepOver) { - if (m_currentContext.asManaged()->d() == m_engine->current) + if (m_currentFrame == m_engine->currentStackFrame) pauseAndWait(); return; } @@ -635,7 +632,7 @@ void NativeDebugger::enteringFunction() return; if (m_stepping == StepIn) { - m_currentContext.set(m_engine, *m_engine->currentContext); + m_currentFrame = m_engine->currentStackFrame; } } @@ -644,8 +641,8 @@ void NativeDebugger::leavingFunction(const QV4::ReturnedValue &retVal) if (m_runningJob) return; - if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->current) { - m_currentContext.set(m_engine, *m_engine->parentContext(m_engine->currentContext)); + if (m_stepping != NotStepping && m_currentFrame == m_engine->currentStackFrame) { + m_currentFrame = m_currentFrame->parent; m_stepping = StepOver; m_returnedValue.set(m_engine, retVal); } @@ -667,7 +664,7 @@ void NativeDebugger::aboutToThrow() QV4::Function *NativeDebugger::getFunction() const { - QV4::ExecutionContext *context = m_engine->currentContext; + QV4::ExecutionContext *context = m_engine->currentContext(); if (QV4::Function *function = context->getFunction()) return function; else -- cgit v1.2.3 From 4acb72bf35e736f222c90e49b3e84e20355d33a7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Aug 2017 17:14:11 +0200 Subject: Cleanup naming of Stack frame structures Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp | 3 +-- src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h | 2 +- src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp | 2 +- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 +- .../qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 6 +++--- 5 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 76d5315004..0097fed0d6 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QV4::Heap::CallContext *QV4DataCollector::findContext(int frame) { - QV4::EngineBase::StackFrame *f = engine()->currentStackFrame; + QV4::CppStackFrame *f = engine()->currentStackFrame; while (f && frame) { --frame; f = f->parent; @@ -99,7 +99,6 @@ int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType s return 4; case QV4::Heap::ExecutionContext::Type_WithContext: return 2; - case QV4::Heap::ExecutionContext::Type_SimpleCallContext: case QV4::Heap::ExecutionContext::Type_CallContext: return 1; case QV4::Heap::ExecutionContext::Type_QmlContext: diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h index b2200c47fc..42f4534015 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h @@ -150,7 +150,7 @@ private: void runJobUnpaused(); QV4::ExecutionEngine *m_engine; - QV4::EngineBase::StackFrame *m_currentFrame = 0; + QV4::CppStackFrame *m_currentFrame = 0; QMutex m_lock; QWaitCondition m_runningCondition; State m_state; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 09ed9ac98c..316fd87dd4 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -79,7 +79,7 @@ void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseR case QV4Debugger::PauseRequest: case QV4Debugger::BreakPointHit: { event.insert(QStringLiteral("event"), QStringLiteral("break")); - QV4::EngineBase::StackFrame *frame = debugger->engine()->currentStackFrame; + QV4::CppStackFrame *frame = debugger->engine()->currentStackFrame; if (!frame) break; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 45af1f44a5..625095b340 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -67,7 +67,7 @@ void JavaScriptJob::run() QObject scopeObject; if (frameNr > 0) { - QV4::EngineBase::StackFrame *f = engine->currentStackFrame; + QV4::CppStackFrame *f = engine->currentStackFrame; for (int i = 0; i < frameNr; ++i) f = f->parent; ctx = static_cast(&f->jsFrame->context); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 32c67b3986..167083155c 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -229,7 +229,7 @@ private: QV4::ExecutionEngine *m_engine; QQmlNativeDebugServiceImpl *m_service; - QV4::EngineBase::StackFrame *m_currentFrame = 0; + QV4::CppStackFrame *m_currentFrame = 0; Speed m_stepping; bool m_pauseRequested; bool m_runningJob; @@ -332,7 +332,7 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a int limit = arguments.value(QLatin1String("limit")).toInt(0); QJsonArray frameArray; - QV4::EngineBase::StackFrame *f= m_engine->currentStackFrame; + QV4::CppStackFrame *f= m_engine->currentStackFrame; for (int i = 0; i < limit && f; ++i) { QV4::Function *function = f->v4Function; @@ -677,7 +677,7 @@ void NativeDebugger::pauseAndWait() event.insert(QStringLiteral("event"), QStringLiteral("break")); event.insert(QStringLiteral("language"), QStringLiteral("js")); - if (QV4::EngineBase::StackFrame *frame = m_engine->currentStackFrame) { + if (QV4::CppStackFrame *frame = m_engine->currentStackFrame) { QV4::Function *function = frame->v4Function; event.insert(QStringLiteral("file"), function->sourceFile()); int line = frame->line; -- cgit v1.2.3 From 456632225f3173d401c68e301fb6d38f6c42e493 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 13 Aug 2017 22:29:41 +0200 Subject: Some prospective fixes to the debugging plugin Adjust to the context/frame changes Change-Id: I06e691654961c8c1f60765a4fd469f03607be4d0 Reviewed-by: Erik Verbruggen --- .../qmldbg_debugger/qv4datacollector.cpp | 41 +++++++------ .../qmltooling/qmldbg_debugger/qv4datacollector.h | 3 +- .../qqmlnativedebugservice.cpp | 70 +++++++++------------- 3 files changed, 54 insertions(+), 60 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 0097fed0d6..0d1dcb8397 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -55,15 +55,21 @@ QT_BEGIN_NAMESPACE -QV4::Heap::CallContext *QV4DataCollector::findContext(int frame) +QV4::CppStackFrame *QV4DataCollector::findFrame(int frame) { QV4::CppStackFrame *f = engine()->currentStackFrame; while (f && frame) { --frame; f = f->parent; } + return f; +} + +QV4::Heap::ExecutionContext *QV4DataCollector::findContext(int frame) +{ + QV4::CppStackFrame *f = findFrame(frame); - return f ? f->callContext() : 0; + return f ? f->context()->d() : 0; } QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) @@ -82,7 +88,7 @@ QVector QV4DataCollector::getScopeType { QVector types; - QV4::Heap::ExecutionContext *it = findContext(frame); + QV4::Heap::ExecutionContext *it = findFrame(frame)->context()->d(); for (; it; it = it->outer) types.append(QV4::Heap::ExecutionContext::ContextType(it->type)); @@ -258,27 +264,26 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) QStringList names; QV4::Scope scope(engine()); + QV4::CppStackFrame *frame = findFrame(frameNr); + if (frame->v4Function->canUseSimpleCall) { + if (!scopeNr) { + // ### collect locals from the stack frame + } else { + // the current call context is actually the parent's context + --scopeNr; + } + } + QV4::Scoped ctxt(scope, findScope(findContext(frameNr), scopeNr)); if (!ctxt) return false; Refs collectedRefs; QV4::ScopedValue v(scope); - int nFormals = ctxt->formalCount(); - for (unsigned i = 0, ei = nFormals; i != ei; ++i) { - QString qName; - if (QV4::Identifier *name = ctxt->formals()[nFormals - i - 1]) - qName = name->string; - names.append(qName); - v = ctxt->argument(i); - collectedRefs.append(collect(v)); - } - - for (unsigned i = 0, ei = ctxt->variableCount(); i != ei; ++i) { - QString qName; - if (QV4::Identifier *name = ctxt->variables()[i]) - qName = name->string; - names.append(qName); + QV4::InternalClass *ic = ctxt->internalClass(); + for (uint i = 0; i < ic->size; ++i) { + QString name = ic->nameMap[i]->string; + names.append(name); v = ctxt->d()->locals[i]; collectedRefs.append(collect(v)); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index c924f10d8c..87be009de5 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -62,7 +62,8 @@ public: static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); QVector getScopeTypes(int frame); - QV4::Heap::CallContext *findContext(int frame); + QV4::Heap::ExecutionContext *findContext(int frame); + QV4::CppStackFrame *findFrame(int frame); QV4DataCollector(QV4::ExecutionEngine *engine); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 167083155c..c879c77fcd 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -312,19 +312,19 @@ void NativeDebugger::handleCommand(QJsonObject *response, const QString &cmd, handleContinue(response, NotStepping); } -static QString encodeContext(QV4::ExecutionContext *executionContext) +static QString encodeFrame(QV4::CppStackFrame *f) { QQmlDebugPacket ds; - ds << quintptr(executionContext); + ds << quintptr(f); return QString::fromLatin1(ds.data().toHex()); } -static void decodeContext(const QString &context, QV4::ExecutionContext **executionContext) +static void decodeFrame(const QString &f, QV4::CppStackFrame **frame) { - quintptr rawContext; - QQmlDebugPacket ds(QByteArray::fromHex(context.toLatin1())); - ds >> rawContext; - *executionContext = reinterpret_cast(rawContext); + quintptr rawFrame; + QQmlDebugPacket ds(QByteArray::fromHex(f.toLatin1())); + ds >> rawFrame; + *frame = reinterpret_cast(rawFrame); } void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &arguments) @@ -338,7 +338,7 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a QJsonObject frame; frame.insert(QStringLiteral("language"), QStringLiteral("js")); - frame.insert(QStringLiteral("context"), encodeContext(nullptr /*#### context*/)); + frame.insert(QStringLiteral("context"), encodeFrame(f)); if (QV4::Heap::String *functionName = function->name()) frame.insert(QStringLiteral("function"), functionName->toQString()); @@ -454,15 +454,15 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &arguments) { TRACE_PROTOCOL("Build variables"); - QV4::ExecutionContext *executionContext = 0; - decodeContext(arguments.value(QLatin1String("context")).toString(), &executionContext); - if (!executionContext) { - setError(response, QStringLiteral("No execution context passed")); + QV4::CppStackFrame *frame = 0; + decodeFrame(arguments.value(QLatin1String("context")).toString(), &frame); + if (!frame) { + setError(response, QStringLiteral("No stack frame passed")); return; } - TRACE_PROTOCOL("Context: " << executionContext); + TRACE_PROTOCOL("Context: " << frame); - QV4::ExecutionEngine *engine = executionContext->engine(); + QV4::ExecutionEngine *engine = frame->v4Function->internalClass->engine; if (!engine) { setError(response, QStringLiteral("No execution engine passed")); return; @@ -478,28 +478,16 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a QJsonArray output; QV4::Scope scope(engine); - if (QV4::CallContext *callContext = executionContext->asCallContext()) { - QV4::Value thisObject = callContext->thisObject(); - collector.collect(&output, QString(), QStringLiteral("this"), thisObject); - QV4::Identifier *const *variables = callContext->variables(); - QV4::Identifier *const *formals = callContext->formals(); - if (callContext->d()->type == QV4::Heap::ExecutionContext::Type_CallContext) { - QV4::CallContext *ctx = static_cast(callContext); - for (unsigned i = 0, ei = ctx->variableCount(); i != ei; ++i) { - QString qName; - if (QV4::Identifier *name = variables[i]) - qName = name->string; - QV4::Value val = ctx->d()->locals[i]; - collector.collect(&output, QString(), qName, val); - } - } - for (unsigned i = 0, ei = callContext->formalCount(); i != ei; ++i) { - QString qName; - if (QV4::Identifier *name = formals[i]) - qName = name->string; - QV4::ReturnedValue rval = callContext->argument(i); - QV4::ScopedValue sval(scope, rval); - collector.collect(&output, QString(), qName, *sval); + QV4::ScopedValue thisObject(scope, frame->thisObject()); + collector.collect(&output, QString(), QStringLiteral("this"), thisObject); + QV4::Scoped callContext(scope, frame->callContext()); + if (callContext) { + QV4::InternalClass *ic = callContext->internalClass(); + QV4::ScopedValue v(scope); + for (uint i = 0; i < ic->size; ++i) { + QString name = ic->nameMap[i]->string; + v = callContext->d()->locals[i]; + collector.collect(&output, QString(), name, v); } } @@ -509,15 +497,15 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject &arguments) { TRACE_PROTOCOL("Evaluate expressions"); - QV4::ExecutionContext *executionContext = 0; - decodeContext(arguments.value(QLatin1String("context")).toString(), &executionContext); - if (!executionContext) { - setError(response, QStringLiteral("No execution context passed")); + QV4::CppStackFrame *frame = 0; + decodeFrame(arguments.value(QLatin1String("context")).toString(), &frame); + if (!frame) { + setError(response, QStringLiteral("No stack frame passed")); return; } TRACE_PROTOCOL("Context: " << executionContext); - QV4::ExecutionEngine *engine = executionContext->engine(); + QV4::ExecutionEngine *engine = frame->v4Function->internalClass->engine; if (!engine) { setError(response, QStringLiteral("No execution engine passed")); return; -- cgit v1.2.3 From 4e0174a88e66b9d9471c98eeb7d8be6209ba5c98 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 21 Aug 2017 10:59:53 +0200 Subject: Move line number information into a side table Don't emit any Line instructions anymore, and instead store the info in a side table in the compiled data, where it can be looked up on demand. Change-Id: Idcaf3bf4ee4129fd62f9e717bf1277dc6a34fe19 Reviewed-by: Erik Verbruggen --- src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp | 4 ++-- src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp | 8 ++++---- .../qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index c95d4ea99f..4ef377922b 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -158,7 +158,7 @@ QV4Debugger::ExecutionState QV4Debugger::currentExecutionState() const { ExecutionState state; state.fileName = getFunction()->sourceFile(); - state.lineNumber = engine()->currentStackFrame->line; + state.lineNumber = engine()->currentStackFrame->lineNumber(); return state; } @@ -203,7 +203,7 @@ void QV4Debugger::maybeBreakAtInstruction() pauseAndWait(PauseRequest); } else if (m_haveBreakPoints) { if (QV4::Function *f = getFunction()) { - const int lineNumber = engine()->currentStackFrame->line; + const int lineNumber = engine()->currentStackFrame->lineNumber(); if (reallyHitTheBreakPoint(f->sourceFile(), lineNumber)) pauseAndWait(BreakPointHit); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 316fd87dd4..2a46dc60a6 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -84,11 +84,11 @@ void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseR break; body.insert(QStringLiteral("invocationText"), frame->function()); - body.insert(QStringLiteral("sourceLine"), frame->line - 1); - if (frame->column > 0) - body.insert(QStringLiteral("sourceColumn"), frame->column); + body.insert(QStringLiteral("sourceLine"), frame->lineNumber() - 1); +// if (frame->column > 0) +// body.insert(QStringLiteral("sourceColumn"), frame->column); QJsonArray breakPoints; - foreach (int breakPointId, breakPointIds(frame->source(), frame->line)) + foreach (int breakPointId, breakPointIds(frame->source(), frame->lineNumber())) breakPoints.push_back(breakPointId); body.insert(QStringLiteral("breakpoints"), breakPoints); script.insert(QStringLiteral("name"), frame->source()); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index c879c77fcd..5015c39c8e 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -344,7 +344,7 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a frame.insert(QStringLiteral("function"), functionName->toQString()); frame.insert(QStringLiteral("file"), function->sourceFile()); - int line = f->line; + int line = f->lineNumber(); frame.insert(QStringLiteral("line"), (line < 0 ? -line : line)); frameArray.push_back(frame); @@ -607,7 +607,7 @@ void NativeDebugger::maybeBreakAtInstruction() if (m_service->m_breakHandler->m_haveBreakPoints) { if (QV4::Function *function = getFunction()) { - const int lineNumber = m_engine->currentStackFrame->line; + const int lineNumber = m_engine->currentStackFrame->lineNumber(); if (reallyHitTheBreakPoint(function, lineNumber)) pauseAndWait(); } @@ -668,7 +668,7 @@ void NativeDebugger::pauseAndWait() if (QV4::CppStackFrame *frame = m_engine->currentStackFrame) { QV4::Function *function = frame->v4Function; event.insert(QStringLiteral("file"), function->sourceFile()); - int line = frame->line; + int line = frame->lineNumber(); event.insert(QStringLiteral("line"), (line < 0 ? -line : line)); } -- cgit v1.2.3 From 6df6f642ea382169533a0ad106be270b6d4b7d58 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Aug 2017 21:53:03 +0200 Subject: Move CallContext construction into a interpreter instruction This will allow us to further cut down on function call overhead. To make this work, introduce a proper distinction between EvalCode and GlobalCode and use the correct compilation mode in all places. Change-Id: I070621142159b7416026347c9239200c5ed7a56b Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 +- src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 625095b340..b0607c574a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -101,7 +101,7 @@ void JavaScriptJob::run() } } - QV4::Script script(ctx, this->script); + QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script); script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 5015c39c8e..1eaa2819af 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -251,7 +251,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::ExecutionContext *ctx = m_engine->currentContext(); - QV4::Script script(ctx, expression); + QV4::Script script(ctx, QV4::Compiler::EvalCode, expression); script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. -- cgit v1.2.3 From aa8f956e8d742ec25a01dfeb0d7a7ce54b49ed73 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 1 Sep 2017 10:09:45 +0200 Subject: Move ScopedCallData and ScopedStackFrame into a separate file Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index b0607c574a..e852f574a7 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include -- cgit v1.2.3 From 0855417be493a774c1d1a70fcf7a73ee7fed0529 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 24 Oct 2017 13:56:09 +0200 Subject: Re-enable Debug instructions and locations for QML functions Debug instructions are used to trigger break points and are added for every source line. We also need to insert Debug instructions before Ret, so that we can step out. We also need to assign line numbers to the entry and return points of "abbreviated" QML functions (by simulating lbrace and rbrace) so that we can set break points on them. The line numbers on Ret need to be negative, so that you cannot (accidentally) set break points on them. A typical signal handler or binding in QML consists of only one line and if you set a break point on that line, you want it to hit only once, when entering the function. If the line numbers on Ret were positive, it would be hit again on exit. Some of the tests in tst_qqmldebugjs implicitly check for that. Also the new interpreter does something on the left brace, so a function actually starts there, not on the first statement. Change-Id: Id9dfb20e35696b420d0950deab988f7cc5197bfc Reviewed-by: Lars Knoll --- src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp | 1 + src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp | 2 +- src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 4ef377922b..1581cf637d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -203,6 +203,7 @@ void QV4Debugger::maybeBreakAtInstruction() pauseAndWait(PauseRequest); } else if (m_haveBreakPoints) { if (QV4::Function *f = getFunction()) { + // lineNumber will be negative for Ret instructions, so those won't match const int lineNumber = engine()->currentStackFrame->lineNumber(); if (reallyHitTheBreakPoint(f->sourceFile(), lineNumber)) pauseAndWait(BreakPointHit); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 2a46dc60a6..87e75c49b5 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -84,7 +84,7 @@ void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseR break; body.insert(QStringLiteral("invocationText"), frame->function()); - body.insert(QStringLiteral("sourceLine"), frame->lineNumber() - 1); + body.insert(QStringLiteral("sourceLine"), qAbs(frame->lineNumber()) - 1); // if (frame->column > 0) // body.insert(QStringLiteral("sourceColumn"), frame->column); QJsonArray breakPoints; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index cb5d2d4c1b..7bf419a1d9 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -607,6 +607,7 @@ void NativeDebugger::maybeBreakAtInstruction() if (m_service->m_breakHandler->m_haveBreakPoints) { if (QV4::Function *function = getFunction()) { + // lineNumber will be negative for Ret instructions, so those won't match const int lineNumber = m_engine->currentStackFrame->lineNumber(); if (reallyHitTheBreakPoint(function, lineNumber)) pauseAndWait(); -- cgit v1.2.3 From 07980a034609383e79132c9819b682c88d343a95 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 20 Oct 2017 10:09:01 +0200 Subject: Get rid of the unusued canUseSimpleCall flag Change-Id: I5230342db4647bd95793475f751213f0725d6965 Reviewed-by: Erik Verbruggen --- src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index b4216663ac..a538956e8e 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -262,15 +262,6 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) QStringList names; QV4::Scope scope(engine()); - QV4::CppStackFrame *frame = findFrame(frameNr); - if (frame->v4Function->canUseSimpleCall) { - if (!scopeNr) { - // ### collect locals from the stack frame - } else { - // the current call context is actually the parent's context - --scopeNr; - } - } QV4::Scoped ctxt(scope, findScope(findContext(frameNr), scopeNr)); if (!ctxt) -- cgit v1.2.3 From 425edd90acfbb81b50f63db7f60927dcae197dfd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 26 Oct 2017 10:52:19 +0200 Subject: V4 Debugger: Allow executing jobs on contexts without v4Function Previously this would crash as it tried to determine strict mode by querying the function. Check the functions of out contexts, too, and finally try the global context if none is found. Change-Id: Ib21c2f4f242a67909944b71640a154ff181c33e1 Reviewed-by: Lars Knoll --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 11 +++++++---- .../qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index e852f574a7..8b51574525 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -67,11 +67,11 @@ void JavaScriptJob::run() QV4::ScopedContext ctx(scope, engine->currentContext()); QObject scopeObject; + QV4::CppStackFrame *frame = engine->currentStackFrame; if (frameNr > 0) { - QV4::CppStackFrame *f = engine->currentStackFrame; for (int i = 0; i < frameNr; ++i) - f = f->parent; - ctx = static_cast(&f->jsFrame->context); + frame = frame->parent; + ctx = static_cast(&frame->jsFrame->context); } if (context >= 0) { @@ -103,7 +103,10 @@ void JavaScriptJob::run() } QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script); - script.strictMode = ctx->d()->v4Function->isStrict(); + if (QV4::Function *function = frame->v4Function) + script.strictMode = function->isStrict(); + else if (engine->globalCode) + script.strictMode = engine->globalCode->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 7bf419a1d9..e8570a380f 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -252,7 +252,10 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::ExecutionContext *ctx = m_engine->currentContext(); QV4::Script script(ctx, QV4::Compiler::EvalCode, expression); - script.strictMode = ctx->d()->v4Function->isStrict(); + if (QV4::Function *function = m_engine->currentStackFrame->v4Function) + script.strictMode = function->isStrict(); + else if (m_engine->globalCode) + script.strictMode = m_engine->globalCode->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. script.inheritContext = true; -- cgit v1.2.3 From a5d31af1a58a2c833ed3ee91dd9140ab23fc8e8a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 27 Oct 2017 11:30:43 +0200 Subject: Fix evaluation of V4 debug jobs There may not be a current stack frame and there may not be a function in either the current frame or the global scope. Change-Id: I15daf10586cf8895a9a80ccc3dd4bf4117a947c5 Reviewed-by: Lars Knoll --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 16 ++++++++-------- .../qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 8b51574525..cb40c9e36a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -64,15 +64,16 @@ void JavaScriptJob::run() { QV4::Scope scope(engine); - QV4::ScopedContext ctx(scope, engine->currentContext()); + QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext() + : engine->rootContext()); QObject scopeObject; QV4::CppStackFrame *frame = engine->currentStackFrame; - if (frameNr > 0) { - for (int i = 0; i < frameNr; ++i) - frame = frame->parent; + + for (int i = 0; frame && i < frameNr; ++i) + frame = frame->parent; + if (frameNr > 0 && frame) ctx = static_cast(&frame->jsFrame->context); - } if (context >= 0) { QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context)); @@ -103,10 +104,9 @@ void JavaScriptJob::run() } QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script); - if (QV4::Function *function = frame->v4Function) + if (const QV4::Function *function = frame ? frame->v4Function : engine->globalCode) script.strictMode = function->isStrict(); - else if (engine->globalCode) - script.strictMode = engine->globalCode->isStrict(); + // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index e8570a380f..917d40fd6a 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -249,13 +249,13 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Scope scope(m_engine); m_runningJob = true; - QV4::ExecutionContext *ctx = m_engine->currentContext(); + QV4::ExecutionContext *ctx = m_engine->currentStackFrame ? m_engine->currentContext() + : m_engine->rootContext(); QV4::Script script(ctx, QV4::Compiler::EvalCode, expression); - if (QV4::Function *function = m_engine->currentStackFrame->v4Function) + if (const QV4::Function *function = m_engine->currentStackFrame + ? m_engine->currentStackFrame->v4Function : m_engine->globalCode) script.strictMode = function->isStrict(); - else if (m_engine->globalCode) - script.strictMode = m_engine->globalCode->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. script.inheritContext = true; -- cgit v1.2.3 From a2142203ad6cdb54ec063e259b40171e13c5d4bd Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 23 Oct 2017 10:10:28 +0200 Subject: Finally get rid of the QV4::Function pointer in the context Change-Id: Iad6018f67faa956d385087865fca9d73419e363e Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index b6ae20a02e..eeedb59ce6 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -656,9 +656,8 @@ void NativeDebugger::aboutToThrow() QV4::Function *NativeDebugger::getFunction() const { - QV4::ExecutionContext *context = m_engine->currentContext(); - if (QV4::Function *function = context->getFunction()) - return function; + if (m_engine->currentStackFrame) + return m_engine->currentStackFrame->v4Function; else return m_engine->globalCode; } -- cgit v1.2.3