Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update tracepoint format #37

Open
wants to merge 2 commits into
base: hotspot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 4 additions & 2 deletions tests/auto/shared/perfparsertestclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void PerfParserTestClient::extractTrace(QIODevice *device)
checkAttribute(value.first);

if (eventType == TracePointSample) {
stream >> sample.tracePointData;
qint32 formatId;
stream >> formatId >> sample.tracePointData;
for (auto it = sample.tracePointData.constBegin(),
end = sample.tracePointData.constEnd();
it != end; ++it) {
Expand All @@ -183,9 +184,10 @@ void PerfParserTestClient::extractTrace(QIODevice *device)
qint32 id;
TracePointFormatEvent tracePointFormat;
stream >> id >> tracePointFormat.system >> tracePointFormat.name
>> tracePointFormat.flags;
>> tracePointFormat.flags >> tracePointFormat.format;
checkString(tracePointFormat.system);
checkString(tracePointFormat.name);
checkString(tracePointFormat.format);
QVERIFY(!m_tracePointFormats.contains(id));
m_tracePointFormats.insert(id, tracePointFormat);
break;
Expand Down
1 change: 1 addition & 0 deletions tests/auto/shared/perfparsertestclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class PerfParserTestClient : public QObject
qint32 system = -1;
qint32 name = -1;
quint32 flags = 0;
qint32 format = -1;
};

// Repeated here, as we want to check against accidental changes in enum values.
Expand Down