aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qv4codegen.cpp10
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp23
2 files changed, 24 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 819f4615f2..2c1b5c57cc 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2256,7 +2256,7 @@ bool Codegen::visit(DoWhileStatement *ast)
_block = loopbody;
statement(ast->statement);
- _block->JUMP(loopcond);
+ setLocation(_block->JUMP(loopcond), ast->statement->lastSourceLocation());
_block = loopcond;
condition(ast->expression, loopbody, loopend);
@@ -2321,7 +2321,7 @@ bool Codegen::visit(ForEachStatement *ast)
return false;
move(*init, _block->TEMP(temp));
statement(ast->statement);
- _block->JUMP(foreachin);
+ setLocation(_block->JUMP(foreachin), ast->lastSourceLocation());
_block = foreachin;
@@ -2360,7 +2360,7 @@ bool Codegen::visit(ForStatement *ast)
_block = forbody;
statement(ast->statement);
- _block->JUMP(forstep);
+ setLocation(_block->JUMP(forstep), ast->lastSourceLocation());
_block = forstep;
statement(ast->expression);
@@ -2460,7 +2460,7 @@ bool Codegen::visit(LocalForEachStatement *ast)
int temp = _block->newTemp();
move(identifier(ast->declaration->name.toString()), _block->TEMP(temp));
statement(ast->statement);
- _block->JUMP(foreachin);
+ setLocation(_block->JUMP(foreachin), ast->lastSourceLocation());
_block = foreachin;
@@ -2800,7 +2800,7 @@ bool Codegen::visit(WhileStatement *ast)
_block = whilebody;
statement(ast->statement);
- _block->JUMP(whilecond);
+ setLocation(_block->JUMP(whilecond), ast->lastSourceLocation());
_block = whileend;
leaveLoop();
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index 8362cb9ed6..56320b8365 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -327,8 +327,9 @@ private slots:
void evaluateExpression();
void stepToEndOfScript();
- void lastLineOfLoop();
+ void lastLineOfLoop_data();
+ void lastLineOfLoop();
private:
QV4Debugger *debugger() const
{
@@ -787,16 +788,30 @@ void tst_qv4debugger::stepToEndOfScript()
QCOMPARE(state.lineNumber, -4); // A return instruction without proper line number.
}
+void tst_qv4debugger::lastLineOfLoop_data()
+{
+ QTest::addColumn<QString>("loopHead");
+ QTest::addColumn<QString>("loopTail");
+
+ QTest::newRow("for") << "for (var i = 0; i < 10; ++i) {\n" << "}\n";
+ QTest::newRow("for..in") << "for (var i in [0, 1, 2, 3, 4]) {\n" << "}\n";
+ QTest::newRow("while") << "while (ret < 10) {\n" << "}\n";
+ QTest::newRow("do..while") << "do {\n" << "} while (ret < 10);\n";
+}
+
void tst_qv4debugger::lastLineOfLoop()
{
+ QFETCH(QString, loopHead);
+ QFETCH(QString, loopTail);
+
QString script =
"var ret = 0;\n"
- "for (var i = 0; i < 10; ++i) {\n"
- " if (i == 2)\n"
+ + loopHead +
+ " if (ret == 2)\n"
" ret += 4;\n" // breakpoint, then step over
" else \n"
" ret += 1;\n"
- "}\n"; // after step over
+ + loopTail;
debugger()->addBreakPoint("trueBranch", 4);
m_debuggerAgent->m_resumeSpeed = QV4Debugger::StepOver;