diff --git a/src/tools/tracegen/ctf.cpp b/src/tools/tracegen/ctf.cpp index 5a3902dd71d..03de8a5f155 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 0bf8d0e2d27..0ae58f9daca 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 db0fdb142e2..c65c57abe33 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 00a1f996863..45156b43610 100644 --- a/src/tools/tracegen/helpers.h +++ b/src/tools/tracegen/helpers.h @@ -8,6 +8,7 @@ #include #include +#include enum ParamType { LTTNG, @@ -20,6 +21,8 @@ QString includeGuard(const QString &filename); QString formatFunctionSignature(const QList &args); QString formatParameterList(const Provider &provider, const QList &args, const QList &fields, ParamType type); +void writeCommonPrologue(QTextStream &stream); + template static QString aggregateListValues(int value, const QList &list) { diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp index 7bb64259e88..c368376c4c6 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";