Skip to content

Commit

Permalink
Tracegen: add support for pointers and intptr-like types
Browse files Browse the repository at this point in the history
In general we want to support pointers and pointer-like types
(intptr and its variations); the main use case is tracing an object's
address. Adjust the lttgt generator to use hex formatting
for this kind of aguments; ETW recognizes the pointer argument type
automatically.

Change-Id: I8249a49b6d0b2d468b84c0fbb7624625421cde9a
Reviewed-by: Rafael Roquetto <[email protected]>
  • Loading branch information
dangelog committed Jun 28, 2018
1 parent 40668b8 commit 5e39b83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/tools/tracegen/lttng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ static void writeCtfMacro(QTextStream &stream, const Tracepoint::Field &field)
case Tracepoint::Field::Integer:
stream << "ctf_integer(" << paramType << ", " << name << ", " << name << ")";
return;
case Tracepoint::Field::IntegerHex:
case Tracepoint::Field::Pointer:
stream << "ctf_integer_hex(" << paramType << ", " << name << ", " << name << ")";
return;
case Tracepoint::Field::Float:
stream << "ctf_float(" << paramType << ", " << name << ", " << name << ")";
return;
Expand Down
14 changes: 11 additions & 3 deletions src/tools/tracegen/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,20 @@ static Tracepoint::Field::BackendType backendType(QString rawType)
{ "signed_long_long_int", Tracepoint::Field::Integer },
{ "unsigned_long_long", Tracepoint::Field::Integer },
{ "char", Tracepoint::Field::Integer },
{ "intptr_t", Tracepoint::Field::IntegerHex },
{ "uintptr_t", Tracepoint::Field::IntegerHex },
{ "std::intptr_t", Tracepoint::Field::IntegerHex },
{ "std::uintptr_t", Tracepoint::Field::IntegerHex },
{ "float", Tracepoint::Field::Float },
{ "double", Tracepoint::Field::Float },
{ "long_double", Tracepoint::Field::Float },
{ "char_ptr", Tracepoint::Field::String },
{ "QString", Tracepoint::Field::QtString },
{ "QByteArray", Tracepoint::Field::QtByteArray },
{ "QUrl", Tracepoint::Field::QtUrl },
{ "QRect", Tracepoint::Field::QtRect }
};

auto backendType = [](const QString &rawType) {

static const size_t tableSize = sizeof (typeTable) / sizeof (typeTable[0]);

for (size_t i = 0; i < tableSize; ++i) {
Expand All @@ -194,7 +196,13 @@ static Tracepoint::Field::BackendType backendType(QString rawType)
rawType = rawType.trimmed();
rawType.replace(QStringLiteral(" "), QStringLiteral("_"));

return backendType(rawType.trimmed());
if (rawType == QLatin1String("char_ptr"))
return Tracepoint::Field::String;

if (rawType.endsWith(QLatin1String("_ptr")))
return Tracepoint::Field::Pointer;

return backendType(rawType);
}

static Tracepoint parseTracepoint(const QString &name, const QStringList &args,
Expand Down
2 changes: 2 additions & 0 deletions src/tools/tracegen/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ struct Tracepoint
Array,
Sequence,
Integer,
IntegerHex,
Float,
String,
Pointer,
QtString,
QtByteArray,
QtUrl,
Expand Down

0 comments on commit 5e39b83

Please sign in to comment.