summaryrefslogtreecommitdiffstats
path: root/src/tools/tracegen/ctf.cpp
diff options
context:
space:
mode:
authorAntti Määttä <[email protected]>2023-01-30 09:01:54 +0200
committerAntti Määttä <[email protected]>2023-02-20 06:39:07 +0000
commitb3f77d25aa30156cf9b93ed2289624118eda9f30 (patch)
tree80565d90df2f0618b87444d0517616ff69edf20d /src/tools/tracegen/ctf.cpp
parent1f23ed3c8532814bfbd81468668b04fa914479fc (diff)
tracegen: Fix handling enumerators with duplicate values
Aggregate the names of the same value enumerators. The values can also be hexadecimal so handle them also. Change-Id: I89693d7e3b8f6c051b298401dcbe8a9f5c0a38aa Reviewed-by: Antti Määttä <[email protected]> Reviewed-by: Tomi Korpipää <[email protected]> (cherry picked from commit 83effb3a3f6bf73e682f7a9ccedebf4073ade776)
Diffstat (limited to 'src/tools/tracegen/ctf.cpp')
-rw-r--r--src/tools/tracegen/ctf.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/tools/tracegen/ctf.cpp b/src/tools/tracegen/ctf.cpp
index e49f5622c64..1d47e646fea 100644
--- a/src/tools/tracegen/ctf.cpp
+++ b/src/tools/tracegen/ctf.cpp
@@ -305,11 +305,20 @@ static void writeEnums(QTextStream &stream, const Provider &provider)
name.replace(QStringLiteral("::"), QStringLiteral("_"));
stream << "TRACEPOINT_METADATA(" << provider.name << ", " << name << ", \n";
stream << "QStringLiteral(\"typealias enum : integer { size = " << e.valueSize << "; } {\\n\\\n";
- for (const auto &v : e.values) {
- if (v.range)
+
+ const auto values = e.values;
+ QList<int> handledValues;
+
+ for (const auto &v : values) {
+ if (handledValues.contains(v.value))
+ continue;
+ if (v.range) {
stream << v.name << " = " << v.value << " ... " << v.range << ", \\n\\\n";
- else
- stream << v.name << " = " << v.value << ", \\n\\\n";
+ } else {
+ const QString names = aggregateListValues(v.value, values);
+ stream << names << " = " << v.value << ", \\n\\\n";
+ handledValues.append(v.value);
+ }
}
stream << "} := " << name << ";\\n\\n\"));\n\n";
}
@@ -323,8 +332,16 @@ static void writeFlags(QTextStream &stream, const Provider &provider)
name.replace(QStringLiteral("::"), QStringLiteral("_"));
stream << "TRACEPOINT_METADATA(" << provider.name << ", " << name << ", \n";
stream << "QStringLiteral(\"typealias enum : integer { size = 8; } {\\n\\\n";
- for (const auto &v : e.values) {
- stream << v.name << " = " << v.value << ", \\n\\\n";
+
+ const auto values = e.values;
+ QList<int> handledValues;
+
+ for (const auto &v : values) {
+ if (handledValues.contains(v.value))
+ continue;
+ const QString names = aggregateListValues(v.value, values);
+ stream << names << " = " << v.value << ", \\n\\\n";
+ handledValues.append(v.value);
}
stream << "} := " << name << ";\\n\\n\"));\n\n";
}