diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-03-20 16:19:48 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-03-23 15:16:14 +0000 |
commit | bdecee9febb1a93e27947f76740215aa9d7b4eb1 (patch) | |
tree | e86eec4c0d6a1077163eb2ef5e6b4022bc4cab87 /src/plugins/qmlprofiler | |
parent | 572ea47e97f7bfc2d2e77cc3585f449f4ca889ea (diff) |
QmlProfiler: Add some sanity checks to the various models
If we pop an event from the stack, then it should be the same type we
pushed earlier.
Change-Id: If4389cb57fa8996b3772fefca92d27c33dc35c65
Task-number: QTCREATORBUG-17885
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r-- | src/plugins/qmlprofiler/flamegraphmodel.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/memoryusagemodel.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp | 3 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index d6899f5ce6..e3f98cfbcf 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -106,6 +106,7 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type) const bool isCompiling = (type.rangeType() == Compiling); QStack<QmlEvent> &stack = isCompiling ? m_compileStack : m_callStack; FlameGraphData *&stackTop = isCompiling ? m_compileStackTop : m_callStackTop; + QTC_ASSERT(stackTop, return); if (type.message() == MemoryAllocation) { if (type.detailType() == HeapPage) @@ -121,6 +122,8 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type) } } else if (event.rangeStage() == RangeEnd) { + QTC_ASSERT(stackTop != &m_stackBottom, return); + QTC_ASSERT(stackTop->typeIndex == event.typeIndex(), return); stackTop->duration += event.timestamp() - stack.top().timestamp(); stack.pop(); stackTop = stackTop->parent; @@ -129,6 +132,7 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type) stack.push(event); stackTop = pushChild(stackTop, event); } + QTC_CHECK(stackTop); } void FlameGraphModel::finalize() diff --git a/src/plugins/qmlprofiler/memoryusagemodel.cpp b/src/plugins/qmlprofiler/memoryusagemodel.cpp index b4bd0d87ce..30d0da85c7 100644 --- a/src/plugins/qmlprofiler/memoryusagemodel.cpp +++ b/src/plugins/qmlprofiler/memoryusagemodel.cpp @@ -135,12 +135,14 @@ void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type { if (type.message() != MemoryAllocation) { if (type.rangeType() != MaximumRangeType) { + m_continuation = ContinueNothing; if (event.rangeStage() == RangeStart) m_rangeStack.push(RangeStackFrame(event.typeIndex(), event.timestamp())); - else if (event.rangeStage() == RangeEnd) + else if (event.rangeStage() == RangeEnd) { + QTC_ASSERT(!m_rangeStack.isEmpty(), return); + QTC_ASSERT(m_rangeStack.top().originTypeIndex == event.typeIndex(), return); m_rangeStack.pop(); - - m_continuation = ContinueNothing; + } } return; } diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp index 4384a10327..c43a302282 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp @@ -225,7 +225,8 @@ void QmlProfilerStatisticsModel::loadEvent(const QmlEvent &event, const QmlEvent break; case RangeEnd: { // update stats - + QTC_ASSERT(!stack.isEmpty(), return); + QTC_ASSERT(stack.top().typeIndex() == event.typeIndex(), return); QmlEventStats *stats = &d->data[event.typeIndex()]; qint64 duration = event.timestamp() - stack.top().timestamp(); stats->duration += duration; |