Fix array handling in tracegen tool

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ää <tomi.korpipaa@qt.io>
This commit is contained in:
Antti Määttä 2022-12-14 09:32:59 +02:00
parent 135a792940
commit f488c65721
4 changed files with 16 additions and 5 deletions

View File

@ -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<LPCWSTR>("

View File

@ -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(" <<paramType << ", "
<< name << ", " << name << ", " << arrayLen << ")";
return;
}
switch (field.backendType) {
case Tracepoint::Field::Sequence:
stream << "ctf_sequence(" << paramType
<< ", " << name << ", " << name

View File

@ -150,8 +150,9 @@ static Tracepoint::Field::BackendType backendType(QString rawType)
return Tracepoint::Field::Unknown;
};
if (arrayLength(rawType) > 0)
return Tracepoint::Field::Array;
int arrayLen = arrayLength(rawType);
if (arrayLen > 0)
rawType = removeBraces(rawType);
if (!sequenceLength(rawType).isNull())
return Tracepoint::Field::Sequence;

View File

@ -21,7 +21,6 @@ struct Tracepoint
struct Field
{
enum BackendType {
Array,
Sequence,
Integer,
IntegerHex,