diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-18 10:56:12 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-18 13:36:57 +0000 |
commit | 98f848ef834d1be33929b39ca1a85ef42b8c9a78 (patch) | |
tree | a97c79331a1af77d25e1f8a039bc4a1bec0617ba | |
parent | d241dfdde503daa306914cf0410ff312e2473b3d (diff) |
V4 debugger: Drop redundantRefs option
No client is using this anymore and we can eliminate a lot of code this
way.
Change-Id: I454581928fe88e59cd28738c4f7fddd060999181
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
8 files changed, 57 insertions, 217 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index a437b7ccc7..2d1dcee0aa 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -111,18 +111,14 @@ int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType s } QV4DataCollector::QV4DataCollector(QV4::ExecutionEngine *engine) - : m_engine(engine), m_namesAsObjects(true), m_redundantRefs(true) + : m_engine(engine), m_namesAsObjects(true) { m_values.set(engine, engine->newArrayObject()); } -// TODO: Directly call addRef() once we don't need to support redundantRefs anymore -QV4DataCollector::Ref QV4DataCollector::collect(const QV4::ScopedValue &value) +QV4DataCollector::Ref QV4DataCollector::addValueRef(const QV4::ScopedValue &value) { - Ref ref = addRef(value); - if (m_redundantRefs) - m_collectedRefs.append(ref); - return ref; + return addRef(value); } const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::ExecutionEngine *engine, @@ -192,7 +188,7 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution } } -QJsonObject QV4DataCollector::lookupRef(Ref ref, bool deep) +QJsonObject QV4DataCollector::lookupRef(Ref ref) { QJsonObject dict; @@ -201,15 +197,12 @@ QJsonObject QV4DataCollector::lookupRef(Ref ref, bool deep) return dict; } - if (m_redundantRefs) - deep = true; - dict.insert(QStringLiteral("handle"), qint64(ref)); QV4::Scope scope(engine()); QV4::ScopedValue value(scope, getValue(ref)); const QV4::Object *object = collectProperty(value, engine(), dict); - if (deep && object) + if (object) dict.insert(QStringLiteral("properties"), collectProperties(object)); return dict; @@ -226,7 +219,6 @@ QV4DataCollector::Ref QV4DataCollector::addFunctionRef(const QString &functionNa dict.insert(QStringLiteral("type"), QStringLiteral("function")); dict.insert(QStringLiteral("name"), functionName); m_specialRefs.insert(ref, dict); - m_collectedRefs.append(ref); return ref; } @@ -242,7 +234,6 @@ QV4DataCollector::Ref QV4DataCollector::addScriptRef(const QString &scriptName) dict.insert(QStringLiteral("type"), QStringLiteral("script")); dict.insert(QStringLiteral("name"), scriptName); m_specialRefs.insert(ref, dict); - m_collectedRefs.append(ref); return ref; } @@ -273,7 +264,7 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) QString name = ic->nameMap[i].toQString(); names.append(name); v = static_cast<QV4::Heap::CallContext *>(ctxt->d())->locals[i]; - collectedRefs.append(collect(v)); + collectedRefs.append(addValueRef(v)); } Q_ASSERT(names.size() == collectedRefs.size()); @@ -284,13 +275,7 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) } } - Ref scopeObjectRef = addRef(scopeObject); - if (m_redundantRefs) { - dict->insert(QStringLiteral("ref"), qint64(scopeObjectRef)); - m_collectedRefs.append(scopeObjectRef); - } else { - *dict = lookupRef(scopeObjectRef, true); - } + *dict = lookupRef(addRef(scopeObject)); return true; } @@ -330,7 +315,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int if (ctxt) { QV4::ScopedValue o(scope, ctxt->d()->activation); - frame[QLatin1String("receiver")] = toRef(collect(o)); + frame[QLatin1String("receiver")] = toRef(addValueRef(o)); } // Only type and index are used by Qt Creator, so we keep it easy: @@ -351,30 +336,11 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int return frame; } -// TODO: Drop this method once we don't need to support redundantRefs anymore -QJsonArray QV4DataCollector::flushCollectedRefs() -{ - Q_ASSERT(m_redundantRefs); - QJsonArray refs; - std::sort(m_collectedRefs.begin(), m_collectedRefs.end()); - for (int i = 0, ei = m_collectedRefs.size(); i != ei; ++i) { - QV4DataCollector::Ref ref = m_collectedRefs.at(i); - if (i > 0 && ref == m_collectedRefs.at(i - 1)) - continue; - refs.append(lookupRef(ref, true)); - } - - m_collectedRefs.clear(); - return refs; -} - void QV4DataCollector::clear() { m_values.set(engine(), engine()->newArrayObject()); - m_collectedRefs.clear(); m_specialRefs.clear(); m_namesAsObjects = true; - m_redundantRefs = true; } QV4DataCollector::Ref QV4DataCollector::addRef(QV4::Value value, bool deduplicate) @@ -459,8 +425,6 @@ QJsonObject QV4DataCollector::collectAsJson(const QString &name, const QV4::Scop if (value->isManaged() && !value->isString()) { Ref ref = addRef(value); dict.insert(QStringLiteral("ref"), qint64(ref)); - if (m_redundantRefs) - m_collectedRefs.append(ref); } collectProperty(value, engine(), dict); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 5494e10e9a..4851e2fa29 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -67,24 +67,20 @@ public: QV4DataCollector(QV4::ExecutionEngine *engine); - Ref collect(const QV4::ScopedValue &value); // only for redundantRefs + Ref addValueRef(const QV4::ScopedValue &value); Ref addFunctionRef(const QString &functionName); // only for namesAsObjects Ref addScriptRef(const QString &scriptName); // only for namesAsObjects void setNamesAsObjects(bool namesAsObjects) { m_namesAsObjects = namesAsObjects; } bool namesAsObjects() const { return m_namesAsObjects; } - void setRedundantRefs(bool redundantRefs) { m_redundantRefs = redundantRefs; } - bool redundantRefs() const { return m_redundantRefs; } - bool isValidRef(Ref ref) const; - QJsonObject lookupRef(Ref ref, bool deep); + QJsonObject lookupRef(Ref ref); bool collectScope(QJsonObject *dict, int frameNr, int scopeNr); QJsonObject buildFrame(const QV4::StackFrame &stackFrame, int frameNr); QV4::ExecutionEngine *engine() const { return m_engine; } - QJsonArray flushCollectedRefs(); // only for redundantRefs void clear(); private: @@ -97,12 +93,10 @@ private: void collectArgumentsInContext(); QV4::ExecutionEngine *m_engine; - Refs m_collectedRefs; // only for redundantRefs QV4::PersistentValue m_values; typedef QHash<Ref, QJsonObject> SpecialRefs; // only for namesAsObjects SpecialRefs m_specialRefs; // only for namesAsObjects bool m_namesAsObjects; - bool m_redundantRefs; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 70f71de6ca..b424ef9f6c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -150,7 +150,6 @@ void BacktraceJob::run() result.insert(QStringLiteral("toFrame"), fromFrame + frameArray.size()); result.insert(QStringLiteral("frames"), frameArray); } - flushRedundantRefs(); } FrameJob::FrameJob(QV4DataCollector *collector, int frameNr) : @@ -165,7 +164,6 @@ void FrameJob::run() success = false; } else { result = collector->buildFrame(frames[frameNr], frameNr); - flushRedundantRefs(); success = true; } } @@ -195,7 +193,6 @@ void ScopeJob::run() result[QLatin1String("index")] = scopeNr; result[QLatin1String("frameIndex")] = frameNr; result[QLatin1String("object")] = object; - flushRedundantRefs(); } bool ScopeJob::wasSuccessful() const @@ -228,9 +225,8 @@ void ValueLookupJob::run() exception = QString::fromLatin1("Invalid Ref: %1").arg(ref); break; } - result[QString::number(ref)] = collector->lookupRef(ref, true); + result[QString::number(ref)] = collector->lookupRef(ref); } - flushRedundantRefs(); } const QString &ValueLookupJob::exceptionMessage() const @@ -249,9 +245,7 @@ void ExpressionEvalJob::handleResult(QV4::ScopedValue &value) { if (hasExeption()) exception = value->toQStringNoThrow(); - result = collector->lookupRef(collector->collect(value), true); - if (collector->redundantRefs()) - collectedRefs = collector->flushCollectedRefs(); + result = collector->lookupRef(collector->addValueRef(value)); } const QString &ExpressionEvalJob::exceptionMessage() const @@ -264,13 +258,6 @@ const QJsonObject &ExpressionEvalJob::returnValue() const return result; } -// TODO: Drop this method once we don't need to support redundantRefs anymore -const QJsonArray &ExpressionEvalJob::refs() const -{ - Q_ASSERT(collector->redundantRefs()); - return collectedRefs; -} - GatherSourcesJob::GatherSourcesJob(QV4::ExecutionEngine *engine) : engine(engine) {} diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h index eca8710e15..d1c7495863 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h @@ -78,24 +78,10 @@ class CollectJob : public QV4DebugJob protected: QV4DataCollector *collector; QJsonObject result; - QJsonArray collectedRefs; // only for redundantRefs - - void flushRedundantRefs() - { - if (collector->redundantRefs()) - collectedRefs = collector->flushCollectedRefs(); - } public: CollectJob(QV4DataCollector *collector) : collector(collector) {} const QJsonObject &returnValue() const { return result; } - - // TODO: Drop this method once we don't need to support redundantRefs anymore - const QJsonArray &refs() const - { - Q_ASSERT(collector->redundantRefs()); - return collectedRefs; - } }; class BacktraceJob: public CollectJob @@ -146,7 +132,6 @@ class ExpressionEvalJob: public JavaScriptJob QV4DataCollector *collector; QString exception; QJsonObject result; - QJsonArray collectedRefs; // only for redundantRefs public: ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context, @@ -154,7 +139,6 @@ public: void handleResult(QV4::ScopedValue &value) override; const QString &exceptionMessage() const; const QJsonObject &returnValue() const; - const QJsonArray &refs() const; // only for redundantRefs }; class GatherSourcesJob: public QV4DebugJob diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index 6822d1db9c..42e4566a4f 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -126,17 +126,9 @@ protected: { QV4DataCollector *collector = debugger->collector(); collector->setNamesAsObjects(debugService->clientRequiresNamesAsObjects()); - collector->setRedundantRefs(debugService->clientRequiresRedundantRefs()); return collector; } - // TODO: drop this method once we don't need to support redundantRefs anymore. - void addRefs(const QJsonArray &refs) - { - Q_ASSERT(debugService->clientRequiresRedundantRefs()); - response.insert(QStringLiteral("refs"), refs); - } - void createErrorResponse(const QString &msg) { QJsonValue command = req.value(QLatin1String("command")); @@ -306,8 +298,6 @@ public: addSuccess(true); addRunning(); addBody(job.returnValue()); - if (debugService->clientRequiresRedundantRefs()) - addRefs(job.refs()); } }; @@ -349,8 +339,6 @@ public: addSuccess(true); addRunning(); addBody(job.returnValue()); - if (debugService->clientRequiresRedundantRefs()) - addRefs(job.refs()); } }; @@ -395,8 +383,6 @@ public: addSuccess(true); addRunning(); addBody(job.returnValue()); - if (debugService->clientRequiresRedundantRefs()) - addRefs(job.refs()); } }; @@ -435,8 +421,6 @@ public: addSuccess(true); addRunning(); addBody(job.returnValue()); - if (debugService->clientRequiresRedundantRefs()) - addRefs(job.refs()); } } }; @@ -655,8 +639,6 @@ public: addSuccess(true); addRunning(); addBody(job.returnValue()); - if (debugService->clientRequiresRedundantRefs()) - addRefs(job.refs()); } } }; @@ -678,7 +660,7 @@ V4CommandHandler *QV4DebugServiceImpl::v4CommandHandler(const QString &command) QV4DebugServiceImpl::QV4DebugServiceImpl(QObject *parent) : QQmlConfigurableDebugService<QV4DebugService>(1, parent), - debuggerAgent(this), theSelectedFrame(0), redundantRefs(true), namesAsObjects(true), + debuggerAgent(this), theSelectedFrame(0), namesAsObjects(true), unknownV4CommandHandler(new UnknownV4CommandHandler) { addHandler(new V4VersionRequest); @@ -783,11 +765,8 @@ void QV4DebugServiceImpl::messageReceived(const QByteArray &message) if (type == V4_CONNECT) { QJsonObject parameters = QJsonDocument::fromJson(payload).object(); namesAsObjects = true; - redundantRefs = true; if (parameters.contains("namesAsObjects")) namesAsObjects = parameters.value("namesAsObjects").toBool(); - if (parameters.contains("redundantRefs")) - redundantRefs = parameters.value("redundantRefs").toBool(); emit messageToClient(name(), packMessage(type)); stopWaiting(); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h index f1ff66d3c5..30ea5cd0bf 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h @@ -86,7 +86,6 @@ public: int selectedFrame() const; void selectFrame(int frameNr); - bool clientRequiresRedundantRefs() const { return redundantRefs; } bool clientRequiresNamesAsObjects() const { return namesAsObjects; } QV4DebuggerAgent debuggerAgent; @@ -108,7 +107,6 @@ private: static int sequence; int theSelectedFrame; - bool redundantRefs; bool namesAsObjects; void addHandler(V4CommandHandler* handler); diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index e3996e0c18..afd1afaabc 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -260,7 +260,7 @@ public: this, &QJSDebugClient::onStateChanged); } - void connect(bool redundantRefs = false, bool namesAsObjects = false); + void connect(bool namesAsObjects = false); void interrupt(); void continueDebugging(StepAction stepAction); @@ -306,10 +306,9 @@ public: }; -void QJSDebugClient::connect(bool redundantRefs, bool namesAsObjects) +void QJSDebugClient::connect(bool namesAsObjects) { QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}")); - jsonVal.setProperty("redundantRefs", QJSValue(redundantRefs)); jsonVal.setProperty("namesAsObjects", QJSValue(namesAsObjects)); sendMessage(packMessage(CONNECT, stringify.call(QJSValueList() << jsonVal).toString().toUtf8())); @@ -798,6 +797,7 @@ void tst_QQmlDebugJS::connect() QFETCH(bool, blockMode); QFETCH(bool, restrictMode); QFETCH(bool, qmlscene); + QCOMPARE(init(qmlscene, QString(TEST_QMLFILE), blockMode, restrictMode), ConnectSuccess); m_client->connect(); QVERIFY(waitForClientSignal(SIGNAL(connected()))); @@ -806,12 +806,11 @@ void tst_QQmlDebugJS::connect() void tst_QQmlDebugJS::interrupt() { //void connect() - QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); m_client->interrupt(); QVERIFY(waitForClientSignal(SIGNAL(interruptRequested()))); @@ -820,12 +819,11 @@ void tst_QQmlDebugJS::interrupt() void tst_QQmlDebugJS::getVersion() { //void version() - QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(connected()))); m_client->version(); @@ -836,11 +834,10 @@ void tst_QQmlDebugJS::getVersionWhenAttaching() { //void version() QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); QCOMPARE(init(qmlscene, QLatin1String(TIMER_QMLFILE), false), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); m_client->version(); QVERIFY(waitForClientSignal(SIGNAL(result()))); @@ -849,12 +846,11 @@ void tst_QQmlDebugJS::getVersionWhenAttaching() void tst_QQmlDebugJS::disconnect() { //void disconnect() - QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); m_client->disconnect(); QVERIFY(waitForClientSignal(SIGNAL(result()))); @@ -864,14 +860,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QString jsonString(m_client->response); @@ -887,14 +882,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; QCOMPARE(init(qmlscene, CREATECOMPONENT_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QString jsonString(m_client->response); @@ -909,12 +903,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback() { QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + int sourceLine = 35; QCOMPARE(init(qmlscene, TIMER_QMLFILE), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); //We can set the breakpoint after connect() here because the timer is repeating and if we miss //its first iteration we can still catch the second one. m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true); @@ -933,14 +927,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 31; QCOMPARE(init(qmlscene, LOADJSFILE_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(TEST_JSFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QString jsonString(m_client->response); @@ -956,7 +949,6 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; @@ -964,7 +956,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment() QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1)); @@ -981,7 +973,6 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 35; @@ -989,7 +980,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine() QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1)); @@ -1006,14 +997,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 39; QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QString jsonString(m_client->response); @@ -1028,13 +1018,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() { QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + int out = 10; int sourceLine = 37; QCOMPARE(init(qmlscene, CONDITION_QMLFILE), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); //The breakpoint is in a timer loop so we can set it after connect(). m_client->setBreakpoint(QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10")); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); @@ -1067,14 +1057,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() void tst_QQmlDebugJS::setBreakpointInScriptThatQuits() { QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + QCOMPARE(init(qmlscene, QUIT_QMLFILE), ConnectSuccess); int sourceLine = 36; m_client->setBreakpoint(QLatin1String(QUIT_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QString jsonString(m_client->response); @@ -1111,14 +1101,13 @@ void tst_QQmlDebugJS::clearBreakpoint() { //void clearBreakpoint(int breakpoint); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine1 = 37; int sourceLine2 = 38; QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); //The breakpoints are in a timer loop so we can set them after connect(). //Furthermore the breakpoints should be hit in the right order because setting of breakpoints //can only occur in the QML event loop. (see QCOMPARE for sourceLine2 below) @@ -1161,12 +1150,11 @@ void tst_QQmlDebugJS::setExceptionBreak() { //void setExceptionBreak(QString type, bool enabled = false); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); QCOMPARE(init(qmlscene, EXCEPTION_QMLFILE), ConnectSuccess); m_client->setExceptionBreak(QJSDebugClient::All,true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); } @@ -1174,14 +1162,13 @@ void tst_QQmlDebugJS::stepNext() { //void continueDebugging(StepAction stepAction, int stepCount = 1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 37; QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->continueDebugging(QJSDebugClient::Next); @@ -1208,7 +1195,6 @@ void tst_QQmlDebugJS::stepIn() { //void continueDebugging(StepAction stepAction, int stepCount = 1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 41; @@ -1216,7 +1202,7 @@ void tst_QQmlDebugJS::stepIn() QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine); @@ -1232,7 +1218,6 @@ void tst_QQmlDebugJS::stepOut() { //void continueDebugging(StepAction stepAction, int stepCount = 1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 37; @@ -1240,7 +1225,7 @@ void tst_QQmlDebugJS::stepOut() QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine); @@ -1256,7 +1241,6 @@ void tst_QQmlDebugJS::continueDebugging() { //void continueDebugging(StepAction stepAction, int stepCount = 1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine1 = 41; @@ -1265,7 +1249,7 @@ void tst_QQmlDebugJS::continueDebugging() m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->continueDebugging(QJSDebugClient::Continue); @@ -1284,14 +1268,13 @@ void tst_QQmlDebugJS::backtrace() { //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->backtrace(); @@ -1302,14 +1285,13 @@ void tst_QQmlDebugJS::getFrameDetails() { //void frame(int number = -1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->frame(); @@ -1320,14 +1302,13 @@ void tst_QQmlDebugJS::getScopeDetails() { //void scope(int number = -1, int frameNumber = -1); QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->scope(); @@ -1355,15 +1336,14 @@ void tst_QQmlDebugJS::evaluateInGlobalScope() void tst_QQmlDebugJS::evaluateInLocalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); - QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + int sourceLine = 34; QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->frame(); @@ -1440,14 +1420,13 @@ void tst_QQmlDebugJS::evaluateInContext() void tst_QQmlDebugJS::getScripts() { //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant()); - QFETCH(bool, qmlscene); - QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); m_client->setBreakpoint(QString(TEST_QMLFILE), 35, -1, true); - m_client->connect(redundantRefs, namesAsObjects); + m_client->connect(namesAsObjects); QVERIFY(waitForClientSignal(SIGNAL(stopped()))); m_client->scripts(); @@ -1535,16 +1514,11 @@ QList<QQmlDebugClient *> tst_QQmlDebugJS::createClients() void tst_QQmlDebugJS::targetData() { QTest::addColumn<bool>("qmlscene"); - QTest::addColumn<bool>("redundantRefs"); QTest::addColumn<bool>("namesAsObjects"); - QTest::newRow("custom / redundant / objects") << false << true << true; - QTest::newRow("qmlscene / redundant / objects") << true << true << true; - QTest::newRow("custom / redundant / strings") << false << true << false; - QTest::newRow("qmlscene / redundant / strings") << true << true << false; - QTest::newRow("custom / sparse / objects") << false << false << true; - QTest::newRow("qmlscene / sparse / objects") << true << false << true; - QTest::newRow("custom / sparse / strings") << false << false << false; - QTest::newRow("qmlscene / sparse / strings") << true << false << false; + QTest::newRow("custom / objects") << false << true; + QTest::newRow("qmlscene / objects") << true << true; + QTest::newRow("custom / strings") << false << false; + QTest::newRow("qmlscene / strings") << true << false; } bool tst_QQmlDebugJS::waitForClientSignal(const char *signal, int timeout) diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index a176f674e6..b75fb6b895 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -105,7 +105,7 @@ public: void run() { QV4::Scope scope(collector->engine()); QV4::ScopedValue v(scope, *collector->engine()->exceptionValue); - exception = collector->collect(v); + exception = collector->addValueRef(v); } QV4DataCollector::Ref exceptionValue() const { return exception; } @@ -238,11 +238,7 @@ public: NamedRefs &refs = m_capturedScope.last(); QJsonObject object = job.returnValue(); object = object.value(QLatin1String("object")).toObject(); - if (object.contains("ref") && !object.contains("properties")) { - QVERIFY(collector.redundantRefs()); - object = collector.lookupRef(object.value("ref").toInt(), true); - QVERIFY(object.contains("properties")); - } + QVERIFY(!object.contains("ref") || object.contains("properties")); foreach (const QJsonValue &value, object.value(QLatin1String("properties")).toArray()) { QJsonObject property = value.toObject(); QString name = property.value(QLatin1String("name")).toString(); @@ -308,14 +304,10 @@ private slots: void conditionalBreakPointInQml(); // context access: - void readArguments_data() { redundancy_data(); } void readArguments(); void readComplicatedArguments(); - void readLocals_data() { redundancy_data(); } void readLocals(); - void readObject_data() { redundancy_data(); } void readObject(); - void readContextInAllFrames_data() { redundancy_data(); } void readContextInAllFrames(); // exceptions: @@ -323,9 +315,7 @@ private slots: void breakInCatch(); void breakInWith(); - void evaluateExpression_data() { redundancy_data(); } void evaluateExpression(); - void stepToEndOfScript_data() { redundancy_data(); } void stepToEndOfScript(); void lastLineOfConditional_data(); @@ -345,8 +335,6 @@ private: waitForSignal(m_engine, SIGNAL(evaluateFinished()), /*timeout*/0); } - void redundancy_data(); - TestEngine *m_engine; QV4::ExecutionEngine *m_v4; TestAgent *m_debuggerAgent; @@ -539,9 +527,6 @@ void tst_qv4debugger::conditionalBreakPointInQml() void tst_qv4debugger::readArguments() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - m_debuggerAgent->m_captureContextInfo = true; QString script = "var f = function(a, b, c, d) {\n" @@ -565,7 +550,6 @@ void tst_qv4debugger::readArguments() void tst_qv4debugger::readComplicatedArguments() { - m_debuggerAgent->collector.setRedundantRefs(false); m_debuggerAgent->m_captureContextInfo = true; QString script = "var f = function(a) {\n" @@ -586,9 +570,6 @@ void tst_qv4debugger::readComplicatedArguments() void tst_qv4debugger::readLocals() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - m_debuggerAgent->m_captureContextInfo = true; QString script = "var f = function(a, b) {\n" @@ -612,9 +593,6 @@ void tst_qv4debugger::readLocals() void tst_qv4debugger::readObject() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - m_debuggerAgent->m_captureContextInfo = true; QString script = "var f = function(a) {\n" @@ -636,7 +614,7 @@ void tst_qv4debugger::readObject() QVERIFY(!b.contains(QStringLiteral("properties"))); QVERIFY(b.value("value").isDouble()); QCOMPARE(b.value("value").toInt(), 2); - b = m_debuggerAgent->collector.lookupRef(b.value("ref").toInt(), true); + b = m_debuggerAgent->collector.lookupRef(b.value("ref").toInt()); QVERIFY(b.contains(QStringLiteral("properties"))); QVERIFY(b.value("properties").isArray()); QJsonArray b_props = b.value("properties").toArray(); @@ -652,8 +630,7 @@ void tst_qv4debugger::readObject() QCOMPARE(b_tail.value("name").toString(), QStringLiteral("tail")); QVERIFY(b_tail.contains("ref")); - QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt(), - true); + QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt()); QCOMPARE(b_tail_value.value("type").toString(), QStringLiteral("object")); QVERIFY(b_tail_value.contains("properties")); QJsonArray b_tail_props = b_tail_value.value("properties").toArray(); @@ -670,9 +647,6 @@ void tst_qv4debugger::readObject() void tst_qv4debugger::readContextInAllFrames() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - m_debuggerAgent->m_captureContextInfo = true; QString script = "var fact = function(n) {\n" @@ -720,8 +694,7 @@ void tst_qv4debugger::pauseOnThrow() QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::Throwing); QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 2); QVERIFY(m_debuggerAgent->m_thrownValue >= qint64(0)); - QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue, - true); + QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue); // DUMP_JSON(exception); QCOMPARE(exception.value("type").toString(), QStringLiteral("string")); QCOMPARE(exception.value("value").toString(), QStringLiteral("hard")); @@ -765,9 +738,6 @@ void tst_qv4debugger::breakInWith() void tst_qv4debugger::evaluateExpression() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - QString script = "function testFunction() {\n" " var x = 10\n" @@ -809,9 +779,6 @@ void tst_qv4debugger::evaluateExpression() void tst_qv4debugger::stepToEndOfScript() { - QFETCH(bool, redundantRefs); - m_debuggerAgent->collector.setRedundantRefs(redundantRefs); - QString script = "var ret = 0;\n" "ret += 4;\n" @@ -932,13 +899,6 @@ void tst_qv4debugger::readThis() QCOMPARE(a.value("value").toInt(), 5); } -void tst_qv4debugger::redundancy_data() -{ - QTest::addColumn<bool>("redundantRefs"); - QTest::addRow("redundant") << true; - QTest::addRow("sparse") << false; -} - QTEST_MAIN(tst_qv4debugger) #include "tst_qv4debugger.moc" |