Skip to content

Commit 1e2ae7b

Browse files
lievenheymilianw
authored andcommitted
feat: Parse tracepoint data in hotspot
1 parent 7b4802a commit 1e2ae7b

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

src/parsers/perf/perfparser.cpp

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ struct Sample : Record
299299
QVector<qint32> frames;
300300
quint8 guessedFrames = 0;
301301
QVector<SampleCost> costs;
302+
quint32 tracePointFormat = std::numeric_limits<quint32>::max();
303+
quint32 tracePointData = std::numeric_limits<quint32>::max();
302304
};
303305

304306
QDataStream& operator>>(QDataStream& stream, Sample& sample)
@@ -539,6 +541,43 @@ QDebug operator<<(QDebug stream, const Error& error)
539541
return stream;
540542
}
541543

544+
struct TracePointFormat
545+
{
546+
StringId systemId;
547+
StringId nameId;
548+
quint32 flags = 0;
549+
StringId format;
550+
};
551+
552+
QDataStream& operator>>(QDataStream& stream, TracePointFormat& format)
553+
{
554+
stream >> format.systemId >> format.nameId >> format.flags >> format.format;
555+
return stream;
556+
}
557+
558+
QDebug operator<<(QDebug stream, TracePointFormat format)
559+
{
560+
stream.noquote().nospace() << "TracePointFormat{"
561+
<< "systemId=" << format.systemId << ", "
562+
<< "nameId=" << format.nameId << ", "
563+
<< "flags=" << format.flags << ", "
564+
<< "format=" << format.format << "}";
565+
return stream;
566+
}
567+
568+
using TracePointData = QHash<qint32, QVariant>;
569+
570+
QDebug operator<<(QDebug stream, const TracePointData& traceData)
571+
{
572+
auto s = stream.noquote().nospace();
573+
s << "TracePointData{";
574+
for (auto it = traceData.cbegin(), end = traceData.cend(); it != end; it++) {
575+
s << it.key() << "=" << it.value() << ", ";
576+
}
577+
s << "}";
578+
return stream;
579+
}
580+
542581
void addCallerCalleeEvent(const Data::Symbol& symbol, const Data::Location& location, int type, quint64 cost,
543582
QSet<Data::Symbol>* recursionGuard, Data::CallerCalleeResults* callerCalleeResult,
544583
int numCosts)
@@ -760,11 +799,19 @@ class PerfParserPrivate : public QObject
760799
}
761800
}
762801

802+
if (static_cast<EventType>(eventType) == EventType::TracePointSample) {
803+
quint32 eventFormatId;
804+
TracePointData traceData;
805+
stream >> eventFormatId >> traceData;
806+
tracepointData[eventFormatId].push_back(traceData);
807+
qCDebug(LOG_PERFPARSER) << "parsed:" << traceData;
808+
sample.tracePointFormat = eventFormatId;
809+
sample.tracePointData = tracepointData.size() - 1;
810+
}
811+
763812
addRecord(sample);
764813
addSample(sample);
765814

766-
if (static_cast<EventType>(eventType) == EventType::TracePointSample)
767-
return true; // TODO: read full data
768815
break;
769816
}
770817
case EventType::ThreadStart: {
@@ -876,9 +923,14 @@ class PerfParserPrivate : public QObject
876923
emit debugInfoDownloadProgress(strings.value(module.id), strings.value(url.id), numerator, denominator);
877924
break;
878925
}
879-
case EventType::TracePointFormat:
880-
// TODO: implement me
881-
return true;
926+
case EventType::TracePointFormat: {
927+
qint32 id;
928+
TracePointFormat format;
929+
stream >> id >> format;
930+
qCDebug(LOG_PERFPARSER) << "parsed:" << format;
931+
tracepointFormat[id] = format;
932+
break;
933+
}
882934
case EventType::InvalidType:
883935
break;
884936
}
@@ -1435,6 +1487,8 @@ class PerfParserPrivate : public QObject
14351487
QHash<quint32, quint64> m_lastSampleTimePerCore;
14361488
Settings::CostAggregation costAggregation;
14371489
bool perfMapFileExists = false;
1490+
QHash<quint32, TracePointFormat> tracepointFormat;
1491+
QHash<quint32, QVector<TracePointData>> tracepointData;
14381492

14391493
// samples recorded without --call-graph have only one frame
14401494
int m_numSamplesWithMoreThanOneFrame = 0;

0 commit comments

Comments
 (0)