summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2023-03-08 10:41:37 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-26 10:46:19 +0000
commit3c06bf14322670782991c39cda9ee9dac63b19a9 (patch)
treeabcb88df266128397bbd73de56dabb9c998fb450
parenta49b768a70360725dfbec4a32333e3452f8b30c8 (diff)
downloadqtbase-3c06bf14322670782991c39cda9ee9dac63b19a9.tar.gz
tracegen: Add common prologue
Add common prologue and add error message when tracing is used in a module that doesn't have Q_TRACEPOINT enabled, but tracing is enabled. Change-Id: I64ca074942f6e89b4f5b5e3b6048b2b713c06df8 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> (cherry picked from commit 257b3161c5c5e46cd040371da77cb6a06987cf50) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/tools/tracegen/ctf.cpp1
-rw-r--r--src/tools/tracegen/etw.cpp1
-rw-r--r--src/tools/tracegen/helpers.cpp9
-rw-r--r--src/tools/tracegen/helpers.h3
-rw-r--r--src/tools/tracegen/lttng.cpp1
5 files changed, 15 insertions, 0 deletions
diff --git a/src/tools/tracegen/ctf.cpp b/src/tools/tracegen/ctf.cpp
index 5a3902dd71..03de8a5f15 100644
--- a/src/tools/tracegen/ctf.cpp
+++ b/src/tools/tracegen/ctf.cpp
@@ -15,6 +15,7 @@
static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
+ writeCommonPrologue(stream);
const QString guard = includeGuard(fileName);
// include prefix text or qt headers only once
diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp
index 0bf8d0e2d2..0ae58f9dac 100644
--- a/src/tools/tracegen/etw.cpp
+++ b/src/tools/tracegen/etw.cpp
@@ -104,6 +104,7 @@ static QString createGuid(const QUuid &uuid)
static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
+ writeCommonPrologue(stream);
QUuid uuid = QUuid::createUuidV5(QUuid(), provider.name.toLocal8Bit());
const QString providerV = providerVar(provider.name);
diff --git a/src/tools/tracegen/helpers.cpp b/src/tools/tracegen/helpers.cpp
index db0fdb142e..c65c57abe3 100644
--- a/src/tools/tracegen/helpers.cpp
+++ b/src/tools/tracegen/helpers.cpp
@@ -6,6 +6,15 @@
using namespace Qt::StringLiterals;
+void writeCommonPrologue(QTextStream &stream)
+{
+ stream << R"CPP(
+#ifndef Q_TRACEPOINT
+#error "Q_TRACEPOINT not set for the module, Q_TRACE not enabled."
+#endif
+)CPP";
+}
+
QString typeToTypeName(const QString &name)
{
QString ret = name;
diff --git a/src/tools/tracegen/helpers.h b/src/tools/tracegen/helpers.h
index 00a1f99686..45156b4361 100644
--- a/src/tools/tracegen/helpers.h
+++ b/src/tools/tracegen/helpers.h
@@ -8,6 +8,7 @@
#include <qlist.h>
#include <qstring.h>
+#include <qtextstream.h>
enum ParamType {
LTTNG,
@@ -20,6 +21,8 @@ QString includeGuard(const QString &filename);
QString formatFunctionSignature(const QList<Tracepoint::Argument> &args);
QString formatParameterList(const Provider &provider, const QList<Tracepoint::Argument> &args, const QList<Tracepoint::Field> &fields, ParamType type);
+void writeCommonPrologue(QTextStream &stream);
+
template <typename T>
static QString aggregateListValues(int value, const QList<T> &list)
{
diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp
index 7bb64259e8..c368376c4c 100644
--- a/src/tools/tracegen/lttng.cpp
+++ b/src/tools/tracegen/lttng.cpp
@@ -101,6 +101,7 @@ static void writeCtfMacro(QTextStream &stream, const Provider &provider, const T
static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
+ writeCommonPrologue(stream);
const QString guard = includeGuard(fileName);
stream << "#undef TRACEPOINT_PROVIDER\n";