forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -51,7 +51,7 @@ public:
|
|||||||
ThreadEndTypeId = -3,
|
ThreadEndTypeId = -3,
|
||||||
LostTypeId = -4,
|
LostTypeId = -4,
|
||||||
ContextSwitchTypeId = -5,
|
ContextSwitchTypeId = -5,
|
||||||
LastSpecialTypeId = -256
|
LastSpecialTypeId = -6
|
||||||
};
|
};
|
||||||
|
|
||||||
int numAttributes() const { return m_values.length() + 1; }
|
int numAttributes() const { return m_values.length() + 1; }
|
||||||
|
@@ -143,6 +143,7 @@ public:
|
|||||||
case ThreadEnd:
|
case ThreadEnd:
|
||||||
case LostDefinition:
|
case LostDefinition:
|
||||||
case ContextSwitchDefinition:
|
case ContextSwitchDefinition:
|
||||||
|
case InvalidFeature:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@@ -177,6 +177,14 @@ void PerfProfilerTraceFile::readMessages(const QByteArray &buffer)
|
|||||||
case PerfEventType::LocationDefinition: {
|
case PerfEventType::LocationDefinition: {
|
||||||
PerfEventType location(PerfEventType::LocationDefinition);
|
PerfEventType location(PerfEventType::LocationDefinition);
|
||||||
dataStream >> id >> location;
|
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));
|
traceManager->setEventType(id, std::move(location));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -219,6 +219,8 @@ void PerfProfilerTraceManager::resetAttributes()
|
|||||||
tr("Samples lost")));
|
tr("Samples lost")));
|
||||||
setEventType(PerfEvent::ContextSwitchTypeId,
|
setEventType(PerfEvent::ContextSwitchTypeId,
|
||||||
PerfEventType(PerfEventType::ContextSwitchDefinition, tr("Context switch")));
|
PerfEventType(PerfEventType::ContextSwitchDefinition, tr("Context switch")));
|
||||||
|
setEventType(PerfEvent::LastSpecialTypeId,
|
||||||
|
PerfEventType(PerfEventType::InvalidFeature, tr("Invalid")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTraceManager::finalize()
|
void PerfProfilerTraceManager::finalize()
|
||||||
|
Reference in New Issue
Block a user