summaryrefslogtreecommitdiffstats
path: root/src/tools/tracegen/etw.cpp
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2019-03-26 14:07:03 +0100
committerMilian Wolff <milian.wolff@kdab.com>2019-04-05 11:57:39 +0000
commit6ce2a87c23bbaacece7d32df276f64a0058e447d (patch)
treeb0500378205664a2da5162e44973a159bffe0958 /src/tools/tracegen/etw.cpp
parentdf7eec6bcb0b9fdee3888c9b4683dbb533eba300 (diff)
Forward declare all types required for compilation with `-trace`
This patch fixes compilation with `-trace lttng` or `-trace etw`. We need to forward declare QEvent, QImageReader etc., otherwise the types will be unknown while compiling the trace points. In order to handle this generically, the tracegen utility is extended to support a 'prefix text' in the `*.tracepoints` input files. Any text within curly braces will be embedded as-is in the generated file. This can then be used to add forward declarations for the types we need, including potential namespaces and such. Change-Id: I5cb16763ce0fcb48ce3ea4577578d468ff3a4f4b Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'src/tools/tracegen/etw.cpp')
-rw-r--r--src/tools/tracegen/etw.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp
index 8c065f93c9..e839137915 100644
--- a/src/tools/tracegen/etw.cpp
+++ b/src/tools/tracegen/etw.cpp
@@ -110,19 +110,21 @@ static QString createGuid(const QUuid &uuid)
return guid;
}
-static void writePrologue(QTextStream &stream, const QString &fileName, const QString &providerName)
+static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
- QUuid uuid = QUuid::createUuidV5(QUuid(), providerName.toLocal8Bit());
+ QUuid uuid = QUuid::createUuidV5(QUuid(), provider.name.toLocal8Bit());
- const QString provider = providerVar(providerName);
+ const QString providerV = providerVar(provider.name);
const QString guard = includeGuard(fileName);
const QString guid = createGuid(uuid);
const QString guidString = uuid.toString();
stream << "#ifndef " << guard << "\n"
<< "#define " << guard << "\n"
+ << "\n"
<< "#include <windows.h>\n"
- << "#include <TraceLoggingProvider.h>\n";
+ << "#include <TraceLoggingProvider.h>\n"
+ << "\n";
/* TraceLogging API macros cannot deal with UTF8
* source files, so we work around it like this
@@ -132,30 +134,33 @@ static void writePrologue(QTextStream &stream, const QString &fileName, const QS
"#define _TlgPragmaUtf8Begin\n"
"#define _TlgPragmaUtf8End\n";
+ stream << "\n";
stream << qtHeaders();
-
stream << "\n";
+ if (!provider.prefixText.isEmpty())
+ stream << provider.prefixText.join(QLatin1Char('\n')) << "\n\n";
+
stream << "#ifdef TRACEPOINT_DEFINE\n"
<< "/* " << guidString << " */\n"
- << "TRACELOGGING_DEFINE_PROVIDER(" << provider << ", \""
- << providerName <<"\", " << guid << ");\n\n";
+ << "TRACELOGGING_DEFINE_PROVIDER(" << providerV << ", \""
+ << provider.name <<"\", " << guid << ");\n\n";
stream << "static inline void registerProvider()\n"
<< "{\n"
- << " TraceLoggingRegister(" << provider << ");\n"
+ << " TraceLoggingRegister(" << providerV << ");\n"
<< "}\n\n";
stream << "static inline void unregisterProvider()\n"
<< "{\n"
- << " TraceLoggingUnregister(" << provider << ");\n"
+ << " TraceLoggingUnregister(" << providerV << ");\n"
<< "}\n";
stream << "Q_CONSTRUCTOR_FUNCTION(registerProvider)\n"
<< "Q_DESTRUCTOR_FUNCTION(unregisterProvider)\n\n";
stream << "#else\n"
- << "TRACELOGGING_DECLARE_PROVIDER(" << provider << ");\n"
+ << "TRACELOGGING_DECLARE_PROVIDER(" << providerV << ");\n"
<< "#endif // TRACEPOINT_DEFINE\n\n";
}
@@ -224,7 +229,7 @@ void writeEtw(QFile &file, const Provider &provider)
const QString fileName = QFileInfo(file.fileName()).fileName();
- writePrologue(stream, fileName, provider.name);
+ writePrologue(stream, fileName, provider);
writeTracepoints(stream, provider);
writeEpilogue(stream, fileName);
}