From e4a6c5b3e41d655efcbd34e4e2dc0fd28f3da196 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 6 Mar 2014 09:09:05 +0100 Subject: [PATCH] Fix test failure in qqmldebugjs autotest The debugger should only have one breakpoint that can be set per line. Nevertheless, we should have proper line number information available in case we stop at other places. We also need a debug instruction before the return statement, so that step out will always find a last stopping point in the parent frame. Change-Id: I86145fc244148f106a4a97ce69ab60b568c8dac6 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4isel_moth.cpp | 13 ++++++++++--- src/qml/jit/qv4isel_masm.cpp | 2 +- src/qml/jsruntime/qv4engine.cpp | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index 921af76..d97fa58 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -385,7 +385,7 @@ void InstructionSelection::run(int functionIndex) push.value = quint32(locals); addInstruction(push); - currentLine = -1; + currentLine = 0; for (int i = 0, ei = _function->basicBlocks.size(); i != ei; ++i) { blockNeedsDebugInstruction = irModule->debugMode; _block = _function->basicBlocks[i]; @@ -1038,7 +1038,7 @@ void InstructionSelection::visitJump(IR::Jump *s) if (blockNeedsDebugInstruction) { Instruction::Debug debug; - debug.lineNumber = currentLine; + debug.lineNumber = -currentLine; addInstruction(debug); } @@ -1053,7 +1053,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) { if (blockNeedsDebugInstruction) { Instruction::Debug debug; - debug.lineNumber = currentLine; + debug.lineNumber = -currentLine; addInstruction(debug); } @@ -1090,6 +1090,13 @@ void InstructionSelection::visitCJump(IR::CJump *s) void InstructionSelection::visitRet(IR::Ret *s) { + if (blockNeedsDebugInstruction) { + // this is required so stepOut will always be guaranteed to stop in every stack frame + Instruction::Debug debug; + debug.lineNumber = -currentLine; + addInstruction(debug); + } + Instruction::Ret ret; ret.result = getParam(s->expr); addInstruction(ret); diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index d09ac4d..dc3f455 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -336,7 +336,7 @@ void InstructionSelection::run(int functionIndex) _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister); _as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop))); - int lastLine = -1; + int lastLine = 0; for (int i = 0, ei = _function->basicBlocks.size(); i != ei; ++i) { IR::BasicBlock *nextBlock = (i < ei - 1) ? _function->basicBlocks[i + 1] : 0; _block = _function->basicBlocks[i]; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 65165d4..6aedc5f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -684,7 +684,8 @@ QVector ExecutionEngine::stackTrace(int frameLimit) const frame.column = -1; if (callCtx->function->function) - frame.line = callCtx->lineNumber; + // line numbers can be negative for places where you can't set a real breakpoint + frame.line = qAbs(callCtx->lineNumber); stack.append(frame); --frameLimit; -- 2.7.4