aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-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
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp22
7 files changed, 43 insertions, 32 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;
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 8fc048b5f3..459d9afe2a 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1326,7 +1326,7 @@ void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction
QQmlSourceLocation QQmlBindingFunction::currentLocation() const
{
- QV4::StackFrame *frame = engine()->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = engine()->currentStackFrame;
return QQmlSourceLocation(frame->source(), frame->line, 0);
}
@@ -1475,13 +1475,13 @@ static QString jsStack(QV4::ExecutionEngine *engine) {
QString stackFrame;
if (frame.column >= 0)
- stackFrame = QStringLiteral("%1 (%2:%3:%4)").arg(frame.function(),
- frame.source(),
+ stackFrame = QStringLiteral("%1 (%2:%3:%4)").arg(frame.function,
+ frame.source,
QString::number(frame.line),
QString::number(frame.column));
else
- stackFrame = QStringLiteral("%1 (%2:%3)").arg(frame.function(),
- frame.source(),
+ stackFrame = QStringLiteral("%1 (%2:%3)").arg(frame.function,
+ frame.source,
QString::number(frame.line));
if (i)
@@ -1530,7 +1530,7 @@ static void writeToConsole(const BuiltinFunction *, Scope &scope, CallData *call
if (!loggingCategory)
loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory;
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
const QByteArray baSource = frame->source().toUtf8();
const QByteArray baFunction = frame->function().toUtf8();
QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData(), loggingCategory->categoryName());
@@ -1583,7 +1583,7 @@ void ConsoleObject::method_profile(const BuiltinFunction *, Scope &scope, CallDa
{
QV4::ExecutionEngine *v4 = scope.engine;
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
const QByteArray baSource = frame->source().toUtf8();
const QByteArray baFunction = frame->function().toUtf8();
QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData());
@@ -1602,7 +1602,7 @@ void ConsoleObject::method_profileEnd(const BuiltinFunction *, Scope &scope, Cal
{
QV4::ExecutionEngine *v4 = scope.engine;
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
const QByteArray baSource = frame->source().toUtf8();
const QByteArray baFunction = frame->function().toUtf8();
QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData());
@@ -1656,7 +1656,7 @@ void ConsoleObject::method_count(const BuiltinFunction *, Scope &scope, CallData
QV4::ExecutionEngine *v4 = scope.engine;
QV8Engine *v8engine = scope.engine->v8Engine;
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
QString scriptName = frame->source();
@@ -1679,7 +1679,7 @@ void ConsoleObject::method_trace(const BuiltinFunction *, Scope &scope, CallData
QString stack = jsStack(v4);
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
QMessageLogger(frame->source().toUtf8().constData(), frame->line,
frame->function().toUtf8().constData())
.debug("%s", qPrintable(stack));
@@ -1710,7 +1710,7 @@ void ConsoleObject::method_assert(const BuiltinFunction *, Scope &scope, CallDat
QString stack = jsStack(v4);
- QV4::StackFrame *frame = v4->currentStackFrame;
+ QV4::EngineBase::StackFrame *frame = v4->currentStackFrame;
QMessageLogger(frame->source().toUtf8().constData(), frame->line,
frame->function().toUtf8().constData())
.critical("%s\n%s",qPrintable(message), qPrintable(stack));