From: Erik Verbruggen Date: Fri, 5 Dec 2014 12:58:22 +0000 (+0100) Subject: QML Debugging: Fix breakpoints/stepping in a with-statement. X-Git-Tag: v5.4.1~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5586af99c15af8fef27bedfbf84a05d107b4320c;p=platform%2Fupstream%2Fqtdeclarative.git QML Debugging: Fix breakpoints/stepping in a with-statement. Also fix the stack-trace generation, otherwise the debugger engine would report a breakpoint hit on the wrong line. Change-Id: I6eb4b508fbdca64d03badd8f9312a05c78781ded Reviewed-by: Simon Hausmann --- diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index c0ca4ae..99a982a 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -149,6 +149,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed inline CallContext *asCallContext(); inline const CallContext *asCallContext() const; inline const CatchContext *asCatchContext() const; + inline const WithContext *asWithContext() const; inline FunctionObject *getFunctionObject() const; @@ -232,12 +233,17 @@ inline const CatchContext *ExecutionContext::asCatchContext() const return d()->type == Type_CatchContext ? static_cast(this) : 0; } +inline const WithContext *ExecutionContext::asWithContext() const +{ + return d()->type == Type_WithContext ? static_cast(this) : 0; +} + inline FunctionObject *ExecutionContext::getFunctionObject() const { for (const ExecutionContext *it = this; it; it = it->d()->parent) { if (const CallContext *callCtx = it->asCallContext()) return callCtx->d()->function; - else if (it->asCatchContext()) + else if (it->asCatchContext() || it->asWithContext()) continue; // look in the parent context for a FunctionObject else break; diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index fcbdcbc..4d155cf 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -287,6 +287,7 @@ private slots: // exceptions: void pauseOnThrow(); void breakInCatch(); + void breakInWith(); void evaluateExpression(); @@ -632,6 +633,23 @@ void tst_qv4debugger::breakInCatch() QCOMPARE(state.lineNumber, 4); } +void tst_qv4debugger::breakInWith() +{ + QString script = + "with (42) {\n" + " console.log('give the answer');\n" + "}\n"; + + m_debuggerAgent->addBreakPoint("breakInWith", 2); + evaluateJavaScript(script, "breakInWith"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_pauseReason, BreakPoint); + QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); + QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + QCOMPARE(state.fileName, QString("breakInWith")); + QCOMPARE(state.lineNumber, 2); +} + void tst_qv4debugger::evaluateExpression() { QString script =