aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-03 15:44:49 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-05-08 09:27:57 +0000
commitd0839bc1de52acd0902364565b6f9d030e591646 (patch)
treeafd2c7c447ed000fcb31fa22252d375d06ddc32d /src/plugins/perfprofiler
parent63beec8921c3195be3b95a7394de2711918227bf (diff)
PerfProfiler: Guard against some malformed input
If there is no attribute we actually set the attribute to be the invalid one. Therefore an entry for the invalid attribute should exist. Also, cycles in the parent location IDs need to be avoided. Change-Id: Id1962744ef476ddad737cf108d9f9ab83a4eaf55 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/perfevent.h2
-rw-r--r--src/plugins/perfprofiler/perfeventtype.h1
-rw-r--r--src/plugins/perfprofiler/perfprofilertracefile.cpp8
-rw-r--r--src/plugins/perfprofiler/perfprofilertracemanager.cpp2
4 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/perfprofiler/perfevent.h b/src/plugins/perfprofiler/perfevent.h
index e57712a722..dcee855e38 100644
--- a/src/plugins/perfprofiler/perfevent.h
+++ b/src/plugins/perfprofiler/perfevent.h
@@ -51,7 +51,7 @@ public:
ThreadEndTypeId = -3,
LostTypeId = -4,
ContextSwitchTypeId = -5,
- LastSpecialTypeId = -256
+ LastSpecialTypeId = -6
};
int numAttributes() const { return m_values.length() + 1; }
diff --git a/src/plugins/perfprofiler/perfeventtype.h b/src/plugins/perfprofiler/perfeventtype.h
index 245b25991a..457b6afeb2 100644
--- a/src/plugins/perfprofiler/perfeventtype.h
+++ b/src/plugins/perfprofiler/perfeventtype.h
@@ -143,6 +143,7 @@ public:
case ThreadEnd:
case LostDefinition:
case ContextSwitchDefinition:
+ case InvalidFeature:
return true;
default:
return false;
diff --git a/src/plugins/perfprofiler/perfprofilertracefile.cpp b/src/plugins/perfprofiler/perfprofilertracefile.cpp
index cccdc6f7da..c6ea883c79 100644
--- a/src/plugins/perfprofiler/perfprofilertracefile.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracefile.cpp
@@ -177,6 +177,14 @@ void PerfProfilerTraceFile::readMessages(const QByteArray &buffer)
case PerfEventType::LocationDefinition: {
PerfEventType location(PerfEventType::LocationDefinition);
dataStream >> id >> location;
+ for (int parent = location.location().parentLocationId; parent != -1;
+ parent = traceManager->location(parent).parentLocationId) {
+ if (parent == id) {
+ qWarning() << "A location cannot be its own parent location:" << id;
+ location = PerfEventType(PerfEventType::LocationDefinition);
+ break;
+ }
+ }
traceManager->setEventType(id, std::move(location));
break;
}
diff --git a/src/plugins/perfprofiler/perfprofilertracemanager.cpp b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
index 6f93a4797d..75c31af32a 100644
--- a/src/plugins/perfprofiler/perfprofilertracemanager.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
@@ -219,6 +219,8 @@ void PerfProfilerTraceManager::resetAttributes()
tr("Samples lost")));
setEventType(PerfEvent::ContextSwitchTypeId,
PerfEventType(PerfEventType::ContextSwitchDefinition, tr("Context switch")));
+ setEventType(PerfEvent::LastSpecialTypeId,
+ PerfEventType(PerfEventType::InvalidFeature, tr("Invalid")));
}
void PerfProfilerTraceManager::finalize()