From 58d2a88e9c3b9f5d21310b6e282a30fe63a24cae Mon Sep 17 00:00:00 2001 From: Burak Hancerli Date: Mon, 31 Mar 2025 15:30:36 +0200 Subject: [PATCH] QmlDesigner: Merge tracing categories Meta info tracing is merged to model tracing category. Change-Id: Ib6f0f5338b18b4d14e6fd63786e81f7a0b89ce79 Reviewed-by: Marco Bubke --- src/plugins/qmldesigner/CMakeLists.txt | 4 -- .../libs/designercore/CMakeLists.txt | 4 +- .../libs/designercore/include/nodemetainfo.h | 35 +----------- .../designercore/metainfo/nodemetainfo.cpp | 16 +++--- .../tracing/qmldesignertracing.cpp | 10 ---- .../designercore/tracing/qmldesignertracing.h | 16 ------ .../qmldesignertracingsourcelocation.h | 56 +++++++++++++++++++ 7 files changed, 67 insertions(+), 74 deletions(-) create mode 100644 src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracingsourcelocation.h diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index ecad2d73d81..fcea12a3096 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -28,10 +28,6 @@ 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} "") -env_with_default("QTC_ENABLE_METAINFO_TRACING" ENV_QTC_ENABLE_METAINFO_TRACING OFF) -option(ENABLE_METAINFO_TRACING "Enable meta info tracing" ${ENV_QTC_ENABLE_METAINFO_TRACING}) -add_feature_info("Meta info tracing" ${ENABLE_METAINFO_TRACING} "") - env_with_default("QDS_DESIGNVIEWER_USE_STAGING" ENV_QDS_DESIGNVIEWER_USE_STAGING OFF) option(QDS_DESIGNVIEWER_USE_STAGING "Use staging API URL for Design Viewer" ${ENV_QDS_DESIGNVIEWER_USE_STAGING}) add_feature_info("Use staging API URL for Design Viewer" ${QDS_DESIGNVIEWER_USE_STAGING} "") diff --git a/src/plugins/qmldesigner/libs/designercore/CMakeLists.txt b/src/plugins/qmldesigner/libs/designercore/CMakeLists.txt index ee1293830f6..e3bb78e8dd1 100644 --- a/src/plugins/qmldesigner/libs/designercore/CMakeLists.txt +++ b/src/plugins/qmldesigner/libs/designercore/CMakeLists.txt @@ -49,16 +49,14 @@ extend_qtc_library(QmlDesignerCore ) extend_qtc_library(QmlDesignerCore - CONDITION ENABLE_PROJECT_STORAGE_TRACING OR ENABLE_SOURCE_PATH_STORAGE_TRACING OR ENABLE_IMAGE_CACHE_TRACING OR ENABLE_MODEL_TRACING OR ENABLE_METAINFO_TRACING + CONDITION ENABLE_PROJECT_STORAGE_TRACING OR ENABLE_SOURCE_PATH_STORAGE_TRACING OR ENABLE_IMAGE_CACHE_TRACING OR ENABLE_MODEL_TRACING PUBLIC_DEPENDS Nanotrace PUBLIC_DEFINES ENABLE_QMLDESIGNER_TRACING - DEFINES $<$:ENABLE_PROJECT_STORAGE_TRACING> $<$:ENABLE_SOURCE_PATH_STORAGE_TRACING> $<$:ENABLE_IMAGE_CACHE_TRACING> $<$:ENABLE_MODEL_TRACING> - $<$:ENABLE_METAINFO_TRACING> ) extend_qtc_library(QmlDesignerCore diff --git a/src/plugins/qmldesigner/libs/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/libs/designercore/include/nodemetainfo.h index 0fda91f52ba..641394af487 100644 --- a/src/plugins/qmldesigner/libs/designercore/include/nodemetainfo.h +++ b/src/plugins/qmldesigner/libs/designercore/include/nodemetainfo.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -35,38 +35,7 @@ enum class MetaInfoType { None, Reference, Value, Sequence }; class QMLDESIGNERCORE_EXPORT NodeMetaInfo { -#ifdef ENABLE_PROJECT_STORAGE_TRACING - class SL : public Sqlite::source_location - { - public: - consteval SL(const char *fileName = __builtin_FILE(), - const char *functionName = __builtin_FUNCTION(), - const uint_least32_t line = __builtin_LINE()) - : Sqlite::source_location(Sqlite::source_location::current(fileName, functionName, line)) - {} - - template - friend void convertToString(String &string, SL sourceLocation) - { - using NanotraceHR::dictonary; - using NanotraceHR::keyValue; - auto dict = dictonary(keyValue("file", sourceLocation.file_name()), - keyValue("function", sourceLocation.function_name()), - keyValue("line", sourceLocation.line())); - convertToString(string, dict); - } - }; - -#else - class SL - { - public: - template - friend void convertToString(String &, SL) - {} - }; -#endif - + using SL = ModelTracing::SourceLocation; using NodeMetaInfos = std::vector; public: diff --git a/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp index 12ab712f7c7..bf8f0917ca3 100644 --- a/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp @@ -38,7 +38,7 @@ namespace { using Storage::ModuleKind; -auto category = MetaInfoTracing::category; +auto category = ModelTracing::category; struct TypeDescription { @@ -2537,7 +2537,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo, [[maybe_unused]] SL s return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 1 node meta info", category(), keyValue("type id", m_typeId), keyValue("meta info type id", metaInfo.m_typeId), @@ -2562,7 +2562,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 2 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; @@ -2589,7 +2589,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 3 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; @@ -2622,7 +2622,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 4 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; @@ -2655,7 +2655,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 5 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; @@ -2691,7 +2691,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 6 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; @@ -2730,7 +2730,7 @@ bool NodeMetaInfo::isBasedOn(const NodeMetaInfo &metaInfo1, return false; using NanotraceHR::keyValue; - NanotraceHR::Tracer tracer{"is based on", + NanotraceHR::Tracer tracer{"is based on 7 node meta infos", category(), keyValue("type id", m_typeId), keyValue("caller location", sl)}; diff --git a/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.cpp b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.cpp index bd6592d1f02..fd50623b023 100644 --- a/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.cpp +++ b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.cpp @@ -98,14 +98,4 @@ Category &category() return category_; } } // namespace SourcePathStorageTracing - -namespace MetaInfoTracing { -Category &category() -{ - thread_local Category category_{"meta info", Tracing::eventQueueWithStringArguments(), category}; - - return category_; -} -} // namespace MetaInfoTracing - } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.h b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.h index 7edc50c10f8..93c351cf385 100644 --- a/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.h +++ b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracing.h @@ -78,20 +78,4 @@ using Category = NanotraceHR::StringViewWithStringArgumentsCategory; - -[[gnu::pure]] Category &category(); - -} // namespace MetaInfoTracing } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracingsourcelocation.h b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracingsourcelocation.h new file mode 100644 index 00000000000..67d3fc53105 --- /dev/null +++ b/src/plugins/qmldesigner/libs/designercore/tracing/qmldesignertracingsourcelocation.h @@ -0,0 +1,56 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include +#include + +namespace QmlDesigner { + +namespace ModelTracing { + +#ifdef ENABLE_MODEL_TRACING +class SourceLocation : public Sqlite::source_location +{ +public: + consteval SourceLocation(const char *fileName = __builtin_FILE(), + const char *functionName = __builtin_FUNCTION(), + const uint_least32_t line = __builtin_LINE()) + : Sqlite::source_location(Sqlite::source_location::current(fileName, functionName, line)) + {} + + template + friend void convertToString(String &string, SourceLocation sourceLocation) + { + using NanotraceHR::dictonary; + using NanotraceHR::keyValue; + auto dict = dictonary(keyValue("file", sourceLocation.file_name()), + keyValue("function", sourceLocation.function_name()), + keyValue("line", sourceLocation.line())); + convertToString(string, dict); + + string.append(','); + convertToString(string, "id"); + string.append(':'); + string.append('\"'); + string.append(sourceLocation.file_name()); + string.append(':'); + string.append(sourceLocation.line()); + string.append('\"'); + } +}; + +#else +class SourceLocation +{ +public: + template + friend void convertToString(String &, SourceLocation) + {} +}; +#endif + +} // namespace ModelTracing + +} // namespace QmlDesigner