aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-04 10:03:03 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-04 08:59:54 +0000
commit7835060518a2280bda4ca28684b78a1481677158 (patch)
treebba6908444148a724c0f7e8f724edc204ccf7322 /src/qml/jsruntime
parentc0f961cd6b82a523e277f6d8778a20508b15697d (diff)
Fix frame handling
Fix some regressions introduced by change 1ae1eaf59e0475a2dc9c5e22e53e9be19d0f2feb. Change-Id: I24c1db78634e3beb1ab090325b60e70f788f92a7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp21
-rw-r--r--src/qml/jsruntime/qv4enginebase_p.h10
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp9
-rw-r--r--src/qml/jsruntime/qv4global_p.h7
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp4
6 files changed, 32 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 167e38f04a..8d0f401f58 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -804,26 +804,29 @@ QQmlContextData *ExecutionEngine::callingQmlContext() const
return ctx->qml()->context->contextData();
}
-QString StackFrame::source() const
+QString EngineBase::StackFrame::source() const
{
return v4Function->sourceFile();
}
-QString StackFrame::function() const
+QString EngineBase::StackFrame::function() const
{
return v4Function->name()->toQString();
}
-QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
+StackTrace ExecutionEngine::stackTrace(int frameLimit) const
{
Scope scope(const_cast<ExecutionEngine *>(this));
ScopedString name(scope);
- QVector<StackFrame> stack;
+ StackTrace stack;
StackFrame *f = currentStackFrame;
while (f && frameLimit) {
- StackFrame frame = *f;
- frame.parent = 0;
+ QV4::StackFrame frame;
+ frame.source = f->source();
+ frame.function = f->function();
+ frame.line = f->line;
+ frame.column = f->column;
stack.append(frame);
--frameLimit;
f = f->parent;
@@ -849,9 +852,9 @@ static inline char *v4StackTrace(const ExecutionContext *context)
for (int i = 0; i < stackTrace.size(); ++i) {
if (i)
str << ',';
- const QUrl url(stackTrace.at(i).source());
+ const QUrl url(stackTrace.at(i).source);
const QString fileName = url.isLocalFile() ? url.toLocalFile() : url.toString();
- str << "frame={level=\"" << i << "\",func=\"" << stackTrace.at(i).function()
+ str << "frame={level=\"" << i << "\",func=\"" << stackTrace.at(i).function
<< "\",file=\"" << fileName << "\",fullname=\"" << fileName
<< "\",line=\"" << stackTrace.at(i).line << "\",language=\"js\"}";
}
@@ -1066,7 +1069,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError()
QQmlError error;
if (!trace.isEmpty()) {
QV4::StackFrame frame = trace.constFirst();
- error.setUrl(QUrl(frame.source()));
+ error.setUrl(QUrl(frame.source));
error.setLine(frame.line);
error.setColumn(frame.column);
}
diff --git a/src/qml/jsruntime/qv4enginebase_p.h b/src/qml/jsruntime/qv4enginebase_p.h
index 55c44f33f1..cc049fb296 100644
--- a/src/qml/jsruntime/qv4enginebase_p.h
+++ b/src/qml/jsruntime/qv4enginebase_p.h
@@ -63,6 +63,16 @@ namespace QV4 {
#pragma pack(push, 1)
#endif
struct EngineBase {
+ struct StackFrame {
+ StackFrame *parent;
+ Function *v4Function;
+ int line = -1;
+ int column = -1;
+
+ QString source() const;
+ QString function() const;
+ };
+
Heap::ExecutionContext *current = 0;
StackFrame *currentStackFrame = 0;
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index 1eb2cd866d..aef4e64964 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -96,7 +96,7 @@ void Heap::ErrorObject::init(const Value &message, ErrorType t)
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
if (!e->d()->stackTrace->isEmpty()) {
- setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source()));
+ setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
}
@@ -117,13 +117,14 @@ void Heap::ErrorObject::init(const Value &message, const QString &fileName, int
setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
- StackFrame frame = *scope.engine->currentStackFrame;
+ StackFrame frame;
+ frame.source = fileName;
frame.line = line;
frame.column = column;
e->d()->stackTrace->prepend(frame);
Q_ASSERT(!e->d()->stackTrace->isEmpty());
- setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source()));
+ setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
if (!message.isUndefined())
@@ -162,7 +163,7 @@ void ErrorObject::method_get_stack(const BuiltinFunction *, Scope &scope, CallDa
if (i > 0)
trace += QLatin1Char('\n');
const StackFrame &frame = This->d()->stackTrace->at(i);
- trace += frame.function() + QLatin1Char('@') + frame.source();
+ trace += frame.function + QLatin1Char('@') + frame.source;
if (frame.line >= 0)
trace += QLatin1Char(':') + QString::number(frame.line);
}
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index d06ab86593..d50669a24e 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -358,13 +358,10 @@ struct PropertyAttributes
};
struct Q_QML_EXPORT StackFrame {
- StackFrame *parent;
- Function *v4Function;
+ QString source;
+ QString function;
int line = -1;
int column = -1;
-
- QString source() const;
- QString function() const;
};
typedef QVector<StackFrame> StackTrace;
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 0abe6ddd98..ec3ff0ea1d 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -66,7 +66,7 @@ static void generateWarning(QV4::ExecutionEngine *v4, const QString& description
QQmlError retn;
retn.setDescription(description);
- QV4::StackFrame *stackFrame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *stackFrame = v4->currentStackFrame;
retn.setLine(stackFrame->line);
retn.setUrl(QUrl(stackFrame->source()));
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index e3a9815f54..954b7d40a1 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -235,7 +235,7 @@ int qt_v4DebuggerHook(const char *json)
return -NoSuchCommand; // Failure.
}
-Q_NEVER_INLINE static void qt_v4CheckForBreak(QV4::StackFrame *frame)
+Q_NEVER_INLINE static void qt_v4CheckForBreak(QV4::EngineBase::StackFrame *frame)
{
if (!qt_v4IsStepping && !qt_v4Breakpoints.size())
return;
@@ -446,7 +446,7 @@ QV4::ReturnedValue VME::exec(Function *function)
ExecutionEngine *engine = function->internalClass->engine;
- StackFrame frame;
+ EngineBase::StackFrame frame;
frame.parent = engine->currentStackFrame;
frame.v4Function = function;
engine->currentStackFrame = &frame;