Skip to content

Commit

Permalink
Forward more tracepoint information to hotspot
Browse files Browse the repository at this point in the history
This patch forwards the tracepoint formatstring and the event format id
for tracepoints to hotspot.
  • Loading branch information
lievenhey committed Nov 18, 2024
1 parent a6aeb01 commit 18dff5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 8 additions & 5 deletions app/perftracingdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ static void processLine(const QByteArray &line,
const std::function<void(const QByteArray &, const QByteArray &)> &handler)
{
const auto chunks = line.split('\t');
for (const auto &chunk : chunks) {
QList<QByteArray> segments = chunk.split(':');
if (segments.size() != 2)
for (const auto& chunk : chunks) {
auto split = chunk.indexOf(':');
if (split == -1) {
continue;
}

QByteArray name = segments[0].toLower();
QByteArray value = segments[1].trimmed();
auto name = chunk.left(split).toLower().trimmed();
auto value = chunk.mid(split + 1).trimmed();
if (value.endsWith(';'))
value.chop(1);
handler(name, value);
Expand Down Expand Up @@ -240,6 +241,8 @@ bool PerfTracingData::readEventFormats(QDataStream &stream, const QByteArray &sy
seenId = true;
} else if (name == "format") {
stage = CommonFields;
} else if (name == "print fmt") {
event.format = value;
}
});
}
Expand Down
1 change: 1 addition & 0 deletions app/perftracingdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct EventFormat
QVector<FormatField> commonFields;
QVector<FormatField> fields;
quint32 flags = 0;
QByteArray format;
};

class PerfTracingData
Expand Down
13 changes: 6 additions & 7 deletions app/perfunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void PerfUnwind::sendEventFormat(qint32 id, const EventFormat &format)

QByteArray buffer;
QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(TracePointFormat) << id
<< systemId << nameId << format.flags;
<< systemId << nameId << format.flags << resolveString(format.format);
sendBuffer(buffer);
}

Expand Down Expand Up @@ -809,13 +809,12 @@ void PerfUnwind::analyze(const PerfRecordSample &sample)

if (type == TracePointSample) {
QHash<qint32, QVariant> traceData;
const QByteArray &data = sample.rawData();
const EventFormat &format = m_tracingData.eventFormat(eventFormatId);
for (const FormatField &field : format.fields) {
traceData[lookupString(field.name)]
= readTraceData(data, field, m_byteOrder != QSysInfo::ByteOrder);
const QByteArray& data = sample.rawData();
const EventFormat& format = m_tracingData.eventFormat(eventFormatId);
for (const FormatField& field : format.fields) {
traceData[lookupString(field.name)] = readTraceData(data, field, m_byteOrder != QSysInfo::ByteOrder);
}
stream << traceData;
stream << eventFormatId << traceData;
}

sendBuffer(buffer);
Expand Down

0 comments on commit 18dff5a

Please sign in to comment.