21 qDebug() <<
"=== BEGIN TRACEPOINT ===";
27 for (
auto i =
t.args.constBegin();
i !=
t.args.constEnd(); ++
i) {
28 qDebug() <<
"ARG[" <<
j <<
"] type:" <<
i->type;
29 qDebug() <<
"ARG[" <<
j <<
"] name:" <<
i->name;
30 qDebug() <<
"ARG[" <<
j <<
"] arrayLen:" <<
i->arrayLen;
38 for (
auto i =
t.fields.constBegin();
i !=
t.fields.constEnd(); ++
i) {
39 qDebug() <<
"FIELD[" <<
j <<
"] backend_type" <<
static_cast<int>(
i->backendType);
40 qDebug() <<
"FIELD[" <<
j <<
"] param_type" <<
i->paramType;
41 qDebug() <<
"FIELD[" <<
j <<
"] name" <<
i->name;
42 qDebug() <<
"FIELD[" <<
j <<
"] arrayLen" <<
i->arrayLen;
43 qDebug() <<
"FIELD[" <<
j <<
"] seqLen" <<
i->seqLen;
47 qDebug() <<
"=== END TRACEPOINT ===\n";
60 if (!
match.hasMatch())
63 return match.captured(1).toInt();
76 if (!
match.hasMatch())
79 return match.captured(1);
99#define TYPEDATA_ENTRY(type, backendType) \
100{ QT_STRINGIFY(type), backendType }
104 static const struct TypeData {
149 static const size_t tableSize =
sizeof (typeTable) /
sizeof (typeTable[0]);
151 for (
size_t i = 0;
i < tableSize; ++
i) {
168 rawType.remove(constMatch);
169 rawType.remove(u
'&');
173 rawType = rawType.trimmed();
176 if (rawType ==
"char_ptr"_L1)
179 if (rawType.endsWith(
"_ptr"_L1))
183 return d.backendType;
192 auto findEnumeration = [](
const QList<TraceEnum> &enums,
const QString &
name) {
193 for (
const auto &e : enums) {
200 for (
const auto &
f :
flags) {
223 panic(
"Missing parameter type for argument %d of %s (%s:%d)",
230 panic(
"Missing parameter name for argument %d of %s (%s:%d)",
241 t.args << std::move(
a);
249 }
else if (!
f.name.isEmpty()) {
259 t.fields << std::move(field);
270 if (min >= std::numeric_limits<char>::min() && max <= std::numeric_limits<char>::max())
272 if (min >= std::numeric_limits<short>::min() && max <= std::numeric_limits<short>::max())
276 if (max <= std::numeric_limits<unsigned char>::max())
278 if (max <= std::numeric_limits<unsigned short>::max())
309 bool parsingPrefixText =
false;
310 bool parsingEnum =
false;
311 bool parsingFlags =
false;
314 int currentEnumValue = 0;
315 int minEnumValue = std::numeric_limits<int>::max();
316 int maxEnumValue = std::numeric_limits<int>::min();
317 for (
int lineNumber = 1; !
s.atEnd(); ++lineNumber) {
320 if (
line ==
"{"_L1) {
321 parsingPrefixText =
true;
323 }
else if (parsingPrefixText &&
line ==
"}"_L1) {
324 parsingPrefixText =
false;
326 }
else if (parsingPrefixText) {
329 }
else if (
line ==
"ENUM {"_L1) {
332 }
else if (
line ==
"FLAGS {"_L1) {
335 }
else if (
line.
startsWith(
"}"_L1) && (parsingEnum || parsingFlags)) {
337 if (
match.hasMatch()) {
339 currentEnum.name =
match.captured(1);
348 parsingFlags =
false;
351 minEnumValue = std::numeric_limits<int>::max();
352 maxEnumValue = std::numeric_limits<int>::min();
354 panic(
"Syntax error while processing '%s' line %d:\n"
355 " '%s' end of enum/flags does not match",
366 if (parsingEnum || parsingFlags) {
367 auto m = enumdef.match(
line);
369 auto m = rangedef.match(
line);
372 value.name =
m.captured(1);
373 value.value =
m.captured(2).toInt();
374 value.range =
m.captured(3).toInt();
375 currentEnumValue =
value.range + 1;
376 currentEnum.values.push_back(
value);
377 maxEnumValue =
qMax(maxEnumValue,
value.range);
378 minEnumValue =
qMin(minEnumValue,
value.value);
380 }
else if (
m.hasMatch()) {
381 if (
m.hasCaptured(3)) {
384 value.name =
m.captured(1);
385 value.value =
m.captured(3).toInt();
387 currentEnumValue =
value.value + 1;
388 currentEnum.values.push_back(
value);
389 maxEnumValue =
qMax(maxEnumValue,
value.value);
390 minEnumValue =
qMin(minEnumValue,
value.value);
393 value.name =
m.captured(1);
395 value.value =
m.captured(3).toInt(
nullptr, 16);
397 value.value =
m.captured(3).toInt();
399 printf(
"Warning: '%s' line %d:\n"
400 " '%s' flag value is not power of two.\n",
409 maxEnumValue =
qMax(maxEnumValue, currentEnumValue);
410 minEnumValue =
qMin(minEnumValue, currentEnumValue);
412 currentEnum.values.push_back({
m.captured(0), currentEnumValue++, 0});
414 panic(
"Syntax error while processing '%s' line %d:\n"
415 " '%s' flags value not set",
421 panic(
"Syntax error while processing '%s' line %d:\n"
422 " '%s' enum/flags does not match",
430 if (
match.hasMatch()) {
437 panic(
"Syntax error while processing '%s' line %d:\n"
438 " '%s' does not look like a tracepoint definition",
444 if (parsingPrefixText) {
445 panic(
"Syntax error while processing '%s': "
446 "no closing brace found for prefix text block",
QString baseName() const
Returns the base name of the file without the path.
bool isEmpty() const noexcept
void push_back(parameter_type t)
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
QString trimmed() const &
void panic(const char *fmt,...)
static bool isPow2OrZero(quint32 value)
static int arrayLength(const QString &rawType)
static Tracepoint::Field::Type backendType(QString rawType)
#define TYPEDATA_ENTRY(type, backendType)
static QString decayArrayToPointer(QString type)
static quint32 pow2Log2(quint32 v)
static int minumumValueSize(int min, int max)
Provider parseProvider(const QString &filename)
static QString removeBraces(QString type)
static QString sequenceLength(const QString &rawType)
static Tracepoint parseTracepoint(const Provider &provider, const QString &name, const QStringList &args, const QString &fileName, const int lineNumber)
QT_POPCOUNT_RELAXED_CONSTEXPR uint qCountLeadingZeroBits(quint32 v) noexcept
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
static const struct ImageFormatTab unknown[]
#define qPrintable(string)
#define QStringLiteral(str)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
QList< TraceEnum > enumerations
QList< TraceFlags > flags
QList< Tracepoint > tracepoints
QList< FlagValue > values