QmlDesigner: Merge tracing categories

Meta info tracing is merged to model tracing category.

Change-Id: Ib6f0f5338b18b4d14e6fd63786e81f7a0b89ce79
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Burak Hancerli
2025-03-31 15:30:36 +02:00
parent 6b8964071a
commit 58d2a88e9c
7 changed files with 67 additions and 74 deletions

View File

@@ -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} "")

View File

@@ -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
$<$<BOOL:${ENABLE_PROJECT_STORAGE_TRACING}>:ENABLE_PROJECT_STORAGE_TRACING>
$<$<BOOL:${ENABLE_SOURCE_PATH_STORAGE_TRACING}>:ENABLE_SOURCE_PATH_STORAGE_TRACING>
$<$<BOOL:${ENABLE_IMAGE_CACHE_TRACING}>:ENABLE_IMAGE_CACHE_TRACING>
$<$<BOOL:${ENABLE_MODEL_TRACING}>:ENABLE_MODEL_TRACING>
$<$<BOOL:${ENABLE_METAINFO_TRACING}>:ENABLE_METAINFO_TRACING>
)
extend_qtc_library(QmlDesignerCore

View File

@@ -9,7 +9,7 @@
#include <projectstorage/projectstorageinterface.h>
#include <projectstorage/projectstoragetypes.h>
#include <projectstorageids.h>
#include <sqlite/sourcelocation.h>
#include <tracing/qmldesignertracingsourcelocation.h>
#include <QList>
#include <QString>
@@ -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<typename String>
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<typename String>
friend void convertToString(String &, SL)
{}
};
#endif
using SL = ModelTracing::SourceLocation;
using NodeMetaInfos = std::vector<NodeMetaInfo>;
public:

View File

@@ -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)};

View File

@@ -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

View File

@@ -78,20 +78,4 @@ using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatu
[[gnu::pure]] Category &category();
} // namespace SourcePathStorageTracing
namespace MetaInfoTracing {
constexpr NanotraceHR::Tracing tracingStatus()
{
#ifdef ENABLE_METAINFO_TRACING
return NanotraceHR::Tracing::IsEnabled;
#else
return NanotraceHR::Tracing::IsDisabled;
#endif
}
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
[[gnu::pure]] Category &category();
} // namespace MetaInfoTracing
} // namespace QmlDesigner

View File

@@ -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 <nanotrace/nanotracehr.h>
#include <sqlite/sourcelocation.h>
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<typename String>
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<typename String>
friend void convertToString(String &, SourceLocation)
{}
};
#endif
} // namespace ModelTracing
} // namespace QmlDesigner