diff --git a/app/perfdata.h b/app/perfdata.h index 6b2d913..a2946bb 100644 --- a/app/perfdata.h +++ b/app/perfdata.h @@ -454,6 +454,8 @@ class PerfRecordLost : public PerfRecord { public: PerfRecordLost(PerfEventHeader *header = nullptr, quint64 sampleType = 0, bool sampleIdAll = false); + + quint64 lost() const { return m_lost; } private: quint64 m_id; quint64 m_lost; diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 5c241eb..35c6148 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -218,7 +218,7 @@ void PerfUnwind::comm(const PerfRecordComm &comm) const qint32 commId = resolveString(comm.comm()); bufferEvent(TaskEvent{comm.pid(), comm.tid(), comm.time(), comm.cpu(), - commId, Command}, + Command, commId}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -294,7 +294,7 @@ void PerfUnwind::sendEventFormat(qint32 id, const EventFormat &format) void PerfUnwind::lost(const PerfRecordLost &lost) { bufferEvent(TaskEvent{lost.pid(), lost.tid(), lost.time(), lost.cpu(), - 0, LostDefinition}, + LostDefinition, lost.lost()}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -684,14 +684,14 @@ void PerfUnwind::analyze(const PerfRecordSample &sample) void PerfUnwind::fork(const PerfRecordFork &sample) { bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(), - sample.parentPid(), ThreadStart}, + ThreadStart, sample.parentPid()}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } void PerfUnwind::exit(const PerfRecordExit &sample) { bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(), - 0, ThreadEnd}, + ThreadEnd, {}}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -950,7 +950,7 @@ void PerfUnwind::flushEventBuffer(uint desiredBufferSize) if (taskEventIt->m_type == ThreadStart && taskEventIt->m_pid != taskEventIt->m_payload) { forwardMmapBuffer(mmapIt, mmapEnd, taskEventIt->time()); const auto childPid = taskEventIt->m_pid; - const auto parentPid = taskEventIt->m_payload; + const auto parentPid = taskEventIt->m_payload.value(); symbolTable(childPid)->initAfterFork(symbolTable(parentPid)); } else if (taskEventIt->m_type == ThreadEnd && taskEventIt->m_pid == taskEventIt->m_tid) { delete m_symbolTables.take(taskEventIt->m_pid); @@ -1025,7 +1025,8 @@ void PerfUnwind::contextSwitch(const PerfRecordContextSwitch& contextSwitch) { bufferEvent(TaskEvent{contextSwitch.pid(), contextSwitch.tid(), contextSwitch.time(), contextSwitch.cpu(), - contextSwitch.misc() & PERF_RECORD_MISC_SWITCH_OUT, ContextSwitchDefinition}, + ContextSwitchDefinition, + static_cast(contextSwitch.misc() & PERF_RECORD_MISC_SWITCH_OUT)}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -1038,9 +1039,11 @@ void PerfUnwind::sendTaskEvent(const TaskEvent& taskEvent) << taskEvent.m_time << taskEvent.m_cpu; if (taskEvent.m_type == ContextSwitchDefinition) - stream << static_cast(taskEvent.m_payload); + stream << taskEvent.m_payload.value(); else if (taskEvent.m_type == Command || taskEvent.m_type == ThreadStart) - stream << taskEvent.m_payload; + stream << taskEvent.m_payload.value(); + else if (taskEvent.m_type == LostDefinition) + stream << taskEvent.m_payload.value(); sendBuffer(buffer); } diff --git a/app/perfunwind.h b/app/perfunwind.h index 5e5a0b1..0792baf 100644 --- a/app/perfunwind.h +++ b/app/perfunwind.h @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -280,8 +281,8 @@ class PerfUnwind : public QObject qint32 m_tid; quint64 m_time; quint32 m_cpu; - qint32 m_payload; EventType m_type; + QVariant m_payload; quint64 time() const { return m_time; } quint64 size() const { return sizeof(TaskEvent); } diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp index 208b3ba..5ba08c1 100644 --- a/tests/auto/perfdata/tst_perfdata.cpp +++ b/tests/auto/perfdata/tst_perfdata.cpp @@ -156,7 +156,7 @@ void TestPerfData::testTracingData() QCOMPARE(stats.numBufferFlushes, flushes); QCOMPARE(stats.numTimeViolatingSamples, 0u); QCOMPARE(stats.numTimeViolatingMmaps, 0u); - QCOMPARE(stats.maxBufferSize, 15584u); + QCOMPARE(stats.maxBufferSize, 15608u); QCOMPARE(stats.maxTime, maxTime); return; }