summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-17 07:19:02 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-18 19:04:47 (GMT)
commit93f017401ce8bb73415f88955e928a90c6759fc0 (patch)
tree6bf64b8b1db2382452890204db2b86ed1f1ae80c
parent91cb5464a35d2f461644677973ffdcc91985e7fd (diff)
downloadQt-93f017401ce8bb73415f88955e928a90c6759fc0.zip
Qt-93f017401ce8bb73415f88955e928a90c6759fc0.tar.gz
Qt-93f017401ce8bb73415f88955e928a90c6759fc0.tar.bz2
Fix the line numbers on the backtrace
The returnPC points to the opcode after the call, but we want the opcode right before to compute the line number. Reviewed-by: Kent Hansen
-rw-r--r--src/script/api/qscriptcontextinfo.cpp2
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp
index a305116..04c26e2 100644
--- a/src/script/api/qscriptcontextinfo.cpp
+++ b/src/script/api/qscriptcontextinfo.cpp
@@ -172,7 +172,7 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte
JSC::CodeBlock *codeBlock = frame->codeBlock();
if (returnPC && codeBlock) {
lineNumber = codeBlock->lineNumberForBytecodeOffset(const_cast<JSC::ExecState *>(frame),
- returnPC - codeBlock->instructions().begin());
+ returnPC - codeBlock->instructions().begin() -1);
}
}
}
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index c09ebdb..e5d26a3 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -574,7 +574,8 @@ void tst_QScriptContext::backtrace_data()
"function foo() {\n"
" return bt(123);\n"
"}\n"
- "foo('hello', { })" );
+ "foo('hello', { })\n"
+ "var r = 0;");
QTest::newRow("simple") << source << expected;
}
@@ -585,12 +586,14 @@ void tst_QScriptContext::backtrace_data()
"function foo(arg1 , arg2) {\n"
" return eval(\"%1\");\n"
"}\n"
- "foo('hello', 456)"
+ "foo('hello', 456)\n"
+ "var a = 0;"
).arg("\\n \\n bt('hey'); \\n");
expected << "<native>('hey') at -1"
<< "<eval>() at 3"
- << "foo(arg1 = 'hello', arg2 = 456) at testfile:-1" //### line number should be 2
+ //### line number should be 2 but the line number information is not kept for eval call
+ << "foo(arg1 = 'hello', arg2 = 456) at testfile:-1"
<< "<global>() at testfile:4";
QTest::newRow("eval") << source << expected;