From f488c657216115d33753429e8500b99b6e8e7c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Wed, 14 Dec 2022 09:32:59 +0200 Subject: [PATCH] Fix array handling in tracegen tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the array field type. We need to know the basic datatype as well for future backends. Use the arrayLen instead. Add the missing array handling for etw backend. Task-number: QTBUG-106399 Pick-to: 6.5 Change-Id: I97c38240bd1c79c0e61d268a7d780016b341f110 Reviewed-by: Tomi Korpipää --- src/tools/tracegen/etw.cpp | 9 +++++++++ src/tools/tracegen/lttng.cpp | 6 ++++-- src/tools/tracegen/provider.cpp | 5 +++-- src/tools/tracegen/provider.h | 1 - 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp index cf185c3fddf..755470af153 100644 --- a/src/tools/tracegen/etw.cpp +++ b/src/tools/tracegen/etw.cpp @@ -22,6 +22,15 @@ static void writeEtwMacro(QTextStream &stream, const Tracepoint::Field &field) { const QString &name = field.name; + if (field.arrayLen > 0) { + for (int i = 0; i < field.arrayLen; i++) { + stream << "TraceLoggingValue(" << name << "[" << i << "], \"" << name << "[" << i << "]\")"; + if (i + 1 < field.arrayLen) + stream << ",\n "; + } + return; + } + switch (field.backendType) { case Tracepoint::Field::QtString: stream << "TraceLoggingCountedWideString(reinterpret_cast(" diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp index 1ca3f4a974f..d230e024c7f 100644 --- a/src/tools/tracegen/lttng.cpp +++ b/src/tools/tracegen/lttng.cpp @@ -19,11 +19,13 @@ static void writeCtfMacro(QTextStream &stream, const Tracepoint::Field &field) const QString &seqLen = field.seqLen; const int arrayLen = field.arrayLen; - switch (field.backendType) { - case Tracepoint::Field::Array: + if (arrayLen > 0) { stream << "ctf_array(" < 0) - return Tracepoint::Field::Array; + int arrayLen = arrayLength(rawType); + if (arrayLen > 0) + rawType = removeBraces(rawType); if (!sequenceLength(rawType).isNull()) return Tracepoint::Field::Sequence; diff --git a/src/tools/tracegen/provider.h b/src/tools/tracegen/provider.h index 86749de502e..18392baaef2 100644 --- a/src/tools/tracegen/provider.h +++ b/src/tools/tracegen/provider.h @@ -21,7 +21,6 @@ struct Tracepoint struct Field { enum BackendType { - Array, Sequence, Integer, IntegerHex,