diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2019-04-29 10:46:02 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2019-05-05 21:23:36 +0000 |
commit | d2c089eb11d3ad6a9917efde8f13b36931b35baf (patch) | |
tree | da5df88a71f3e7c3479d6cb6682a528d8cc640aa | |
parent | 006f8b666f90b356976c9948a8a79b722b38c9b1 (diff) |
Add Q_TRACE calls to QtQml for QML profiler trace points
This adds tracepoints for LTTng/ETW at the positions that are also
used by the QML profiler within QtQml. I.e. with the tracepoints
here, you'll see which QML function is being executed which is
already quite helpful.
This will allow us to bridge the gap between C++ and QML when
tracing with LTTng/ETW. Additionally, you'll also be able to see
kernel tracepoints which bridges another gap.
Combined, this approach can give much deeper insights into what the
(embedded) system is doing compared to just looking at the QML
profiler alone.
Change-Id: Ia8f71bf6d44b7f51c3c5aaa38f032675604aeca6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Rafael Roquetto <rafael@roquetto.com>
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml.pro | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 20 | ||||
-rw-r--r-- | src/qml/qtqml.tracepoints | 14 |
4 files changed, 36 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index ea2217499f..c69bb67061 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -63,6 +63,8 @@ #include <private/qv4baselinejit_p.h> +#include <qtqml_tracepoints_p.h> + #undef COUNT_INSTRUCTIONS extern "C" { @@ -418,6 +420,10 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine) CHECK_STACK_LIMITS(engine); Function *function = frame->v4Function; + Q_TRACE_SCOPE(QQmlV4_function_call, engine, function->name()->toQString(), + function->compilationUnit->fileName(), + function->compiledFunction->location.line, + function->compiledFunction->location.column); Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling QV4::Debugging::Debugger *debugger = engine->debugger(); diff --git a/src/qml/qml.pro b/src/qml/qml.pro index db59140f06..d2170ac40b 100644 --- a/src/qml/qml.pro +++ b/src/qml/qml.pro @@ -4,6 +4,9 @@ QT = core-private qtConfig(qml-network): \ QT += network +TRACEPOINT_PROVIDER = $$PWD/qtqml.tracepoints +CONFIG += qt_tracepoints + DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x66000000 diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index b62b07e39c..d5b15a7a5a 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -57,6 +57,8 @@ #include <private/qqmldebugserviceinterfaces_p.h> #include <private/qjsvalue_p.h> +#include <qtqml_tracepoints_p.h> + QT_USE_NAMESPACE namespace { @@ -1130,6 +1132,9 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo { const QV4::CompiledData::Object *obj = compilationUnit->objectAt(index); QQmlObjectCreationProfiler profiler(sharedState->profiler.profiler, obj); + Q_TRACE(QQmlObjectCreator_createInstance_entry, compilationUnit.data(), obj, context->url()); + QString typeName; + Q_TRACE_EXIT(QQmlObjectCreator_createInstance_exit, typeName); ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine)); @@ -1143,8 +1148,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo if (obj->flags & QV4::CompiledData::Object::IsComponent) { isComponent = true; QQmlComponent *component = new QQmlComponent(engine, compilationUnit.data(), index, parent); - Q_QML_OC_PROFILE(sharedState->profiler, profiler.update( - compilationUnit.data(), obj, QStringLiteral("<component>"), context->url())); + typeName = QStringLiteral("<component>"); QQmlComponentPrivate::get(component)->creationContext = context; instance = component; ddata = QQmlData::get(instance, /*create*/true); @@ -1155,8 +1159,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo installPropertyCache = !typeRef->isFullyDynamicType; QQmlType type = typeRef->type; if (type.isValid()) { - Q_QML_OC_PROFILE(sharedState->profiler, profiler.update( - compilationUnit.data(), obj, type.qmlTypeName(), context->url())); + typeName = type.qmlTypeName(); void *ddataMemory = nullptr; type.create(&instance, &ddataMemory, sizeof(QQmlData)); @@ -1188,9 +1191,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo sharedState->allCreatedObjects.push(instance); } else { Q_ASSERT(typeRef->compilationUnit); - Q_QML_OC_PROFILE(sharedState->profiler, profiler.update( - compilationUnit.data(), obj, typeRef->compilationUnit->fileName(), - context->url())); + typeName = typeRef->compilationUnit->fileName(); if (typeRef->compilationUnit->unitData()->isSingleton()) { recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex))); @@ -1217,6 +1218,11 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo ddata = QQmlData::get(instance, /*create*/true); } + + Q_QML_OC_PROFILE(sharedState->profiler, profiler.update( + compilationUnit.data(), obj, typeName, context->url())); + Q_UNUSED(typeName); // only relevant for tracing + ddata->lineNumber = obj->location.line; ddata->columnNumber = obj->location.column; diff --git a/src/qml/qtqml.tracepoints b/src/qml/qtqml.tracepoints new file mode 100644 index 0000000000..841748f201 --- /dev/null +++ b/src/qml/qtqml.tracepoints @@ -0,0 +1,14 @@ +{ +namespace QV4 { +class ExecutionEngine; +namespace CompiledData { +class CompilationUnit; +class Object; +} // CompiledData +} // QV4 +} + +QQmlObjectCreator_createInstance_entry(const QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Object *object, const QUrl &url) +QQmlObjectCreator_createInstance_exit(const QString &typeName) +QQmlV4_function_call_entry(const QV4::ExecutionEngine *engine, const QString &function, const QString &fileName, int line, int column) +QQmlV4_function_call_exit() |