Skip to content

Commit

Permalink
Fix array handling in tracegen tool
Browse files Browse the repository at this point in the history
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ää <[email protected]>
  • Loading branch information
anttimaa committed Jan 13, 2023
1 parent 135a792 commit f488c65
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/tools/tracegen/etw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("
Expand Down
6 changes: 4 additions & 2 deletions src/tools/tracegen/lttng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/tools/tracegen/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/tools/tracegen/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct Tracepoint
struct Field
{
enum BackendType {
Array,
Sequence,
Integer,
IntegerHex,
Expand Down

0 comments on commit f488c65

Please sign in to comment.