aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2023-10-14 15:56:03 +0200
committerTim Jenssen <tim.jenssen@qt.io>2023-10-17 11:55:03 +0000
commitad12bbb6698a6c00ed127f79a0078f52b1e7ce7d (patch)
tree10bc3ca87b822387a0763defa7f25824f75d043a /src/plugins/qmldesigner
parent11bf705e26bec1db1f33304d2cdbd00559b91b9c (diff)
QmlDesigner: Add object trace
'N' and 'D' phases are not supported by Perfetto. So I mapped it to async events. This patch is improving the interface for arguments too. Now you can select the type for you arguments. So the name can be a string_view but the arguments can be a string. The variadic template arguments are used to prevent any conversion code which could not be optimized out for an empty function. Change-Id: I1ad1927b5e3b63607a21df1351b1f5cfba50159c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/qmldesigner')
-rw-r--r--src/plugins/qmldesigner/CMakeLists.txt13
-rw-r--r--src/plugins/qmldesigner/designercore/imagecache/asynchronousimagecache.cpp11
-rw-r--r--src/plugins/qmldesigner/designercore/imagecache/imagecachegenerator.h2
-rw-r--r--src/plugins/qmldesigner/designercore/include/asynchronousimagecache.h2
-rw-r--r--src/plugins/qmldesigner/designercore/include/imagecacheauxiliarydata.h2
-rw-r--r--src/plugins/qmldesigner/designercore/model/internalnode_p.h4
-rw-r--r--src/plugins/qmldesigner/designercore/model/internalproperty.h6
-rw-r--r--src/plugins/qmldesigner/designercore/model/model.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/projectstorage.cpp13
-rw-r--r--src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.cpp45
-rw-r--r--src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.h47
11 files changed, 130 insertions, 20 deletions
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt
index e92dc29942f..275e75a8cff 100644
--- a/src/plugins/qmldesigner/CMakeLists.txt
+++ b/src/plugins/qmldesigner/CMakeLists.txt
@@ -23,6 +23,11 @@ env_with_default("QTC_ENABLE_IMAGE_CACHE_TRACING" ENV_QTC_ENABLE_IMAGE_CACHE_TRA
option(ENABLE_IMAGE_CACHE_TRACING "Enable image cache tracing" ${ENV_QTC_ENABLE_IMAGE_CACHE_TRACING})
add_feature_info("Image cache tracing" ${ENABLE_IMAGE_CACHE_TRACING} "")
+env_with_default("QTC_ENABLE_MODEL_TRACING" ENV_QTC_ENABLE_MODEL_TRACING OFF)
+option(ENABLE_MODEL_TRACING "Enable model tracing" ${ENV_QTC_ENABLE_MODEL_TRACING})
+add_feature_info("Model tracing" ${ENABLE_MODEL_TRACING} "")
+
+
add_qtc_library(QmlDesignerUtils STATIC
DEPENDS
@@ -96,8 +101,10 @@ extend_qtc_library(QmlDesignerCore
CONDITION TARGET Nanotrace
DEPENDS Nanotrace
DEFINES
+ ENABLE_QMLDESIGNER_TRACING
$<$<BOOL:${ENABLE_PROJECT_STORAGE_TRACING}>:ENABLE_PROJECT_STORAGE_TRACING>
$<$<BOOL:${ENABLE_IMAGE_CACHE_TRACING}>:ENABLE_IMAGE_CACHE_TRACING>
+ $<$<BOOL:${ENABLE_MODEL_TRACING}>:ENABLE_MODEL_TRACING>
)
extend_qtc_library(QmlDesignerCore
@@ -202,6 +209,12 @@ extend_qtc_library(QmlDesignerCore
)
extend_qtc_library(QmlDesignerCore
+ SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/tracing
+ SOURCES
+ qmldesignertracing.cpp qmldesignertracing.h
+)
+
+extend_qtc_library(QmlDesignerCore
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/include
SOURCES
abstractview.h
diff --git a/src/plugins/qmldesigner/designercore/imagecache/asynchronousimagecache.cpp b/src/plugins/qmldesigner/designercore/imagecache/asynchronousimagecache.cpp
index 19fba2e15c5..37e3e05ac0f 100644
--- a/src/plugins/qmldesigner/designercore/imagecache/asynchronousimagecache.cpp
+++ b/src/plugins/qmldesigner/designercore/imagecache/asynchronousimagecache.cpp
@@ -7,6 +7,8 @@
#include "imagecachestorage.h"
#include "timestampprovider.h"
+#include <tracing/qmldesignertracing.h>
+
#include <QScopeGuard>
#include <thread>
@@ -17,15 +19,8 @@ using namespace NanotraceHR::Literals;
namespace ImageCache {
namespace {
-using TraceFile = NanotraceHR::TraceFile<ImageCache::tracingIsEnabled()>;
-
-TraceFile traceFile{"qml_designer.json"};
-
-thread_local auto eventQueueData = NanotraceHR::makeEventQueueData<NanotraceHR::StringViewTraceEvent, 10000>(
- traceFile);
-thread_local NanotraceHR::EventQueue eventQueue = eventQueueData.createEventQueue();
-thread_local Category category_{"image cache"_t, eventQueue};
+thread_local Category category_{"image cache"_t, QmlDesigner::Tracing::eventQueue()};
} // namespace
Category &category()
diff --git a/src/plugins/qmldesigner/designercore/imagecache/imagecachegenerator.h b/src/plugins/qmldesigner/designercore/imagecache/imagecachegenerator.h
index e89e25bcb29..3b28c117fdb 100644
--- a/src/plugins/qmldesigner/designercore/imagecache/imagecachegenerator.h
+++ b/src/plugins/qmldesigner/designercore/imagecache/imagecachegenerator.h
@@ -68,7 +68,7 @@ private:
std::vector<ImageCache::CaptureImageWithScaledImagesCallback> captureCallbacks;
std::vector<ImageCache::InternalAbortCallback> abortCallbacks;
Sqlite::TimeStamp timeStamp;
- ImageCache::TraceToken traceToken;
+ NO_UNIQUE_ADDRESS ImageCache::TraceToken traceToken;
};
void startGeneration();
diff --git a/src/plugins/qmldesigner/designercore/include/asynchronousimagecache.h b/src/plugins/qmldesigner/designercore/include/asynchronousimagecache.h
index b1948f566bd..c3fc7bcd153 100644
--- a/src/plugins/qmldesigner/designercore/include/asynchronousimagecache.h
+++ b/src/plugins/qmldesigner/designercore/include/asynchronousimagecache.h
@@ -78,7 +78,7 @@ private:
ImageCache::AbortCallback abortCallback;
ImageCache::AuxiliaryData auxiliaryData;
RequestType requestType = RequestType::Image;
- ImageCache::TraceToken traceToken;
+ NO_UNIQUE_ADDRESS ImageCache::TraceToken traceToken;
};
static void request(Utils::SmallStringView name,
diff --git a/src/plugins/qmldesigner/designercore/include/imagecacheauxiliarydata.h b/src/plugins/qmldesigner/designercore/include/imagecacheauxiliarydata.h
index b27816f0548..96667624ad6 100644
--- a/src/plugins/qmldesigner/designercore/include/imagecacheauxiliarydata.h
+++ b/src/plugins/qmldesigner/designercore/include/imagecacheauxiliarydata.h
@@ -27,7 +27,7 @@ constexpr bool tracingIsEnabled()
}
using Category = NanotraceHR::StringViewCategory<tracingIsEnabled()>;
-using TraceToken = Category::TokenType;
+using TraceToken = Category::AsynchronousTokenType;
Category &category();
class FontCollectorSizeAuxiliaryData
diff --git a/src/plugins/qmldesigner/designercore/model/internalnode_p.h b/src/plugins/qmldesigner/designercore/model/internalnode_p.h
index af5b43eec28..7d32b498a09 100644
--- a/src/plugins/qmldesigner/designercore/model/internalnode_p.h
+++ b/src/plugins/qmldesigner/designercore/model/internalnode_p.h
@@ -13,6 +13,7 @@
#include <auxiliarydata.h>
#include <projectstorageids.h>
+#include <tracing/qmldesignertracing.h>
#include <utils/smallstring.h>
#include <QHash>
@@ -30,6 +31,7 @@
namespace QmlDesigner {
namespace Internal {
+using namespace NanotraceHR::Literals;
class InternalProperty;
class InternalNode;
@@ -221,6 +223,8 @@ public:
ModuleId moduleId;
ImportedTypeNameId importedTypeNameId;
TypeId typeId;
+ NO_UNIQUE_ADDRESS ModelTracing::ObjectTraceToken traceToken = ModelTracing::category().beginObject(
+ "InternalNode"_t);
private:
AuxiliaryDatas m_auxiliaryDatas;
diff --git a/src/plugins/qmldesigner/designercore/model/internalproperty.h b/src/plugins/qmldesigner/designercore/model/internalproperty.h
index 66d0bcaa881..2dfcdd616bb 100644
--- a/src/plugins/qmldesigner/designercore/model/internalproperty.h
+++ b/src/plugins/qmldesigner/designercore/model/internalproperty.h
@@ -5,6 +5,8 @@
#include "qmldesignercorelib_global.h"
+#include <tracing/qmldesignertracing.h>
+
#include <QVariant>
#include <memory>
@@ -14,6 +16,8 @@ namespace QmlDesigner {
namespace Internal {
+using namespace NanotraceHR::Literals;
+
class InternalBindingProperty;
class InternalSignalHandlerProperty;
class InternalSignalDeclarationProperty;
@@ -185,6 +189,8 @@ private:
TypeName m_dynamicType;
std::weak_ptr<InternalNode> m_propertyOwner;
PropertyType m_propertyType = PropertyType::None;
+ NO_UNIQUE_ADDRESS ModelTracing::ObjectTraceToken traceToken = ModelTracing::category().beginObject(
+ "InternalProperty"_t, std::forward_as_tuple("name", m_name));
};
} // namespace Internal
diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp
index b85a0d8b403..67001855757 100644
--- a/src/plugins/qmldesigner/designercore/model/model.cpp
+++ b/src/plugins/qmldesigner/designercore/model/model.cpp
@@ -46,6 +46,8 @@
#include <QRegularExpression>
#include <qcompilerdetection.h>
+#include <string>
+
/*!
\defgroup CoreModel
*/
@@ -473,9 +475,12 @@ void ModelPrivate::setMetaInfo(const MetaInfo &metaInfo)
void ModelPrivate::changeNodeId(const InternalNodePointer &node, const QString &id)
{
+ using namespace NanotraceHR::Literals;
+
const QString oldId = node->id;
node->id = id;
+ node->traceToken.change("id"_t, std::forward_as_tuple("id", id));
if (!oldId.isEmpty())
m_idNodeHash.remove(oldId);
if (!id.isEmpty())
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.cpp b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.cpp
index 29f732dea60..c3b659f6453 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.cpp
+++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.cpp
@@ -3,20 +3,15 @@
#include "projectstorage.h"
+#include <tracing/qmldesignertracing.h>
+
#include <sqlitedatabase.h>
namespace QmlDesigner {
-namespace {
-NanotraceHR::TraceFile<projectStorageTracingIsEnabled()> traceFile{"projectstorage.json"};
-
-thread_local auto eventQueueData = NanotraceHR::makeEventQueueData<NanotraceHR::StringViewTraceEvent, 1000>(
- traceFile);
-thread_local NanotraceHR::EventQueue eventQueue = eventQueueData.createEventQueue();
-} // namespace
-
thread_local NanotraceHR::StringViewCategory<projectStorageTracingIsEnabled()> projectStorageCategory{
- "project storage"_t, eventQueue};
+ "project storage"_t, Tracing::eventQueue()};
+
} // namespace QmlDesigner
template class QmlDesigner::ProjectStorage<Sqlite::Database>;
diff --git a/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.cpp b/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.cpp
new file mode 100644
index 00000000000..5912914f6e9
--- /dev/null
+++ b/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.cpp
@@ -0,0 +1,45 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "qmldesignertracing.h"
+
+namespace QmlDesigner {
+namespace Tracing {
+
+namespace {
+using TraceFile = NanotraceHR::TraceFile<tracingIsEnabled()>;
+
+TraceFile traceFile{"qml_designer.json"};
+
+thread_local auto strinViewEventQueueData = NanotraceHR::makeEventQueueData<NanotraceHR::StringViewTraceEvent,
+ 10000>(traceFile);
+thread_local NanotraceHR::EventQueue stringViewEventQueue_ = strinViewEventQueueData.createEventQueue();
+
+thread_local auto stringViewWithStringArgumentsEventQueueData = NanotraceHR::
+ makeEventQueueData<NanotraceHR::StringViewWithStringArgumentsTraceEvent, 1000>(traceFile);
+thread_local NanotraceHR::EventQueue stringViewEventWithStringArgumentsQueue_ = stringViewWithStringArgumentsEventQueueData
+ .createEventQueue();
+} // namespace
+
+EventQueue &eventQueue()
+{
+ return stringViewEventQueue_;
+}
+
+} // namespace Tracing
+
+namespace ModelTracing {
+namespace {
+using namespace NanotraceHR::Literals;
+
+thread_local Category category_{"model"_t, Tracing::stringViewEventWithStringArgumentsQueue_};
+
+} // namespace
+
+Category &category()
+{
+ return category_;
+}
+
+} // namespace ModelTracing
+} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.h b/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.h
new file mode 100644
index 00000000000..4a9c741cc4c
--- /dev/null
+++ b/src/plugins/qmldesigner/designercore/tracing/qmldesignertracing.h
@@ -0,0 +1,47 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <qmldesignercorelib_exports.h>
+
+#include <nanotrace/nanotracehr.h>
+
+#pragma once
+
+namespace QmlDesigner {
+namespace Tracing {
+#ifdef ENABLE_QMLDESIGNER_TRACING
+using Enabled = std::true_type;
+#else
+using Enabled = std::false_type;
+#endif
+
+constexpr bool tracingIsEnabled()
+{
+#ifdef ENABLE_QMLDESIGNER_TRACING
+ return NanotraceHR::isTracerActive();
+#else
+ return false;
+#endif
+}
+
+using EventQueue = NanotraceHR::EventQueue<NanotraceHR::StringViewTraceEvent, Enabled>;
+QMLDESIGNERCORE_EXPORT EventQueue &eventQueue();
+
+} // namespace Tracing
+
+namespace ModelTracing {
+constexpr bool tracingIsEnabled()
+{
+#ifdef ENABLE_MODEL_TRACING
+ return NanotraceHR::isTracerActive();
+#else
+ return false;
+#endif
+}
+
+using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingIsEnabled()>;
+using ObjectTraceToken = Category::ObjectTokenType;
+QMLDESIGNERCORE_EXPORT Category &category();
+
+} // namespace ModelTracing
+} // namespace QmlDesigner