aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-02 16:40:56 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-05-02 15:24:11 +0000
commite5ee202f85cb8544b87a86ec6595398b59b1655d (patch)
tree86cb219cfbc046ef76521475b850c17b282d59eb /src/plugins/perfprofiler
parent3830619cc864b47a9f0327dbd29f08810385cabd (diff)
PerfProfiler: Support context switch events
Change-Id: I328b518cc3674ee26975edf26d40057ceb2c21a2 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/perfevent.h17
-rw-r--r--src/plugins/perfprofiler/perfeventtype.h5
-rw-r--r--src/plugins/perfprofiler/perfprofilertracefile.cpp1
-rw-r--r--src/plugins/perfprofiler/perfprofilertracemanager.cpp2
-rw-r--r--src/plugins/perfprofiler/perftimelinemodel.cpp9
5 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/perfprofiler/perfevent.h b/src/plugins/perfprofiler/perfevent.h
index 40d94b862fb..25afa409475 100644
--- a/src/plugins/perfprofiler/perfevent.h
+++ b/src/plugins/perfprofiler/perfevent.h
@@ -50,7 +50,8 @@ public:
ThreadStartTypeId = -2,
ThreadEndTypeId = -3,
LostTypeId = -4,
- LastSpecialTypeId = -5
+ ContextSwitchTypeId = -5,
+ LastSpecialTypeId = -256
};
const QVector<qint32> &origFrames() const { return m_origFrames; }
@@ -72,6 +73,9 @@ public:
quint8 feature() const { return m_feature; }
+ quint8 extra() const { return m_extra; }
+ void setExtra(quint8 extra) { m_extra = extra; }
+
private:
friend QDataStream &operator>>(QDataStream &stream, PerfEvent &event);
friend QDataStream &operator<<(QDataStream &stream, const PerfEvent &event);
@@ -86,6 +90,7 @@ private:
quint8 m_origNumGuessedFrames = 0;
quint8 m_numGuessedFrames = 0;
quint8 m_feature = PerfEventType::InvalidFeature;
+ quint8 m_extra = 0;
};
inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
@@ -109,6 +114,7 @@ inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
case PerfEventType::Sample43:
case PerfEventType::Sample:
case PerfEventType::TracePointSample:
+ case PerfEventType::ContextSwitchDefinition:
break;
case PerfEventType::InvalidFeature:
QTC_ASSERT(false, return stream);
@@ -130,6 +136,12 @@ inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
case PerfEventType::LostDefinition:
event.setTypeIndex(PerfEvent::LostTypeId);
break;
+ case PerfEventType::ContextSwitchDefinition:
+ event.setTypeIndex(PerfEvent::ContextSwitchTypeId);
+ bool isSwitchOut;
+ stream >> isSwitchOut;
+ event.setExtra(isSwitchOut);
+ break;
default: {
qint32 typeIndex;
stream >> event.m_origFrames >> event.m_origNumGuessedFrames >> typeIndex;
@@ -155,6 +167,9 @@ inline QDataStream &operator<<(QDataStream &stream, const PerfEvent &event)
case PerfEventType::ThreadEnd:
case PerfEventType::LostDefinition:
break;
+ case PerfEventType::ContextSwitchDefinition:
+ stream << bool(event.extra());
+ break;
case PerfEventType::Sample43:
case PerfEventType::Sample:
case PerfEventType::TracePointSample:
diff --git a/src/plugins/perfprofiler/perfeventtype.h b/src/plugins/perfprofiler/perfeventtype.h
index 107b8bdb32b..53031563578 100644
--- a/src/plugins/perfprofiler/perfeventtype.h
+++ b/src/plugins/perfprofiler/perfeventtype.h
@@ -55,6 +55,7 @@ public:
TracePointFormat,
TracePointSample,
AttributesDefinition,
+ ContextSwitchDefinition,
InvalidFeature
};
@@ -66,7 +67,8 @@ public:
static quint64 metaFeatures()
{
- return (1ull << ThreadStart) | (1ull << ThreadEnd) | (1ull << LostDefinition);
+ return (1ull << ThreadStart) | (1ull << ThreadEnd) | (1ull << LostDefinition)
+ | (1ull << ContextSwitchDefinition);
}
static quint64 locationFeatures()
@@ -143,6 +145,7 @@ public:
case ThreadStart:
case ThreadEnd:
case LostDefinition:
+ case ContextSwitchDefinition:
return true;
default:
return false;
diff --git a/src/plugins/perfprofiler/perfprofilertracefile.cpp b/src/plugins/perfprofiler/perfprofilertracefile.cpp
index 8b5bac6bf4a..a4bde6011c4 100644
--- a/src/plugins/perfprofiler/perfprofilertracefile.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracefile.cpp
@@ -237,6 +237,7 @@ void PerfProfilerTraceFile::readMessages(const QByteArray &buffer)
case PerfEventType::ThreadStart:
case PerfEventType::ThreadEnd:
case PerfEventType::LostDefinition:
+ case PerfEventType::ContextSwitchDefinition:
if (acceptsSamples())
traceManager->appendEvent(std::move(event));
break;
diff --git a/src/plugins/perfprofiler/perfprofilertracemanager.cpp b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
index 5ebf1926788..6da6c3e3cb1 100644
--- a/src/plugins/perfprofiler/perfprofilertracemanager.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
@@ -217,6 +217,8 @@ void PerfProfilerTraceManager::resetAttributes()
tr("Thread ended")));
setEventType(PerfEvent::LostTypeId, PerfEventType(PerfEventType::LostDefinition,
tr("Samples lost")));
+ setEventType(PerfEvent::ContextSwitchTypeId,
+ PerfEventType(PerfEventType::ContextSwitchDefinition, tr("Context switch")));
}
void PerfProfilerTraceManager::finalize()
diff --git a/src/plugins/perfprofiler/perftimelinemodel.cpp b/src/plugins/perfprofiler/perftimelinemodel.cpp
index d7ab6cebedf..b5f30352fcd 100644
--- a/src/plugins/perfprofiler/perftimelinemodel.cpp
+++ b/src/plugins/perfprofiler/perftimelinemodel.cpp
@@ -198,6 +198,10 @@ QVariantMap PerfTimelineModel::details(int index) const
result.insert(tr("Details"), tr("lost sample"));
result.insert(tr("Timestamp"), Timeline::formatTime(startTime(index),
manager->traceDuration()));
+ } else if (typeId == PerfEvent::ContextSwitchTypeId) {
+ result.insert(tr("Details"), tr("context switch"));
+ result.insert(tr("Timestamp"), Timeline::formatTime(startTime(index),
+ manager->traceDuration()));
} else {
const PerfProfilerTraceManager::Symbol &symbol
= manager->symbol(manager->aggregateAddresses()
@@ -438,6 +442,11 @@ void PerfTimelineModel::loadEvent(const PerfEvent &event, int numConcurrentThrea
addSample(guessed, 0, 0);
break;
}
+ case PerfEvent::ContextSwitchTypeId: {
+ const int id = TimelineModel::insert(event.timestamp(), 1, PerfEvent::ContextSwitchTypeId);
+ m_data.insert(id, StackFrame::sampleFrame());
+ break;
+ }
case PerfEvent::ThreadStartTypeId: {
if (m_threadStartTimestamp < 0 || event.timestamp() <= m_threadStartTimestamp)
m_threadStartTimestamp = event.timestamp() - 1;