aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-11-01 11:08:26 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-11-14 08:44:39 +0000
commit8af9d69554065924f9c92b29dd09d08ba6650328 (patch)
tree9244b642cf5db61ab81281eef1671bb5d15a9caf
parentdcf41b5f69d0e199d0a6a8faaad981f73e1c9aa0 (diff)
QML Tooling: Fix ordering of memory events in V4 profiler adapter
We should not send memory events that are chronologically after the next call event, even if the time threshold given by the profiler service would allow us to do so. When the remaining call events are sent, the chronological order would otherwise be violated. Fixes: QTBUG-71515 Change-Id: Iee27304f836a899b2b35133316cecd3d34f128c6 Reviewed-by: Michael Brasser <michael.brasser@live.com>
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp7
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/batchOverflow.qml20
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro3
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp10
4 files changed, 37 insertions, 3 deletions
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
index e4f2f556fc..12c36f3dd6 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
@@ -87,14 +87,17 @@ qint64 QV4ProfilerAdapter::appendMemoryEvents(qint64 until, QList<QByteArray> &m
qint64 QV4ProfilerAdapter::finalizeMessages(qint64 until, QList<QByteArray> &messages,
qint64 callNext, QQmlDebugPacket &d)
{
+ qint64 memoryNext = -1;
+
if (callNext == -1) {
m_functionLocations.clear();
m_functionCallData.clear();
m_functionCallPos = 0;
+ memoryNext = appendMemoryEvents(until, messages, d);
+ } else {
+ memoryNext = appendMemoryEvents(qMin(callNext, until), messages, d);
}
- qint64 memoryNext = appendMemoryEvents(until, messages, d);
-
if (memoryNext == -1) {
m_memoryData.clear();
m_memoryPos = 0;
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/batchOverflow.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/batchOverflow.qml
new file mode 100644
index 0000000000..dde1def947
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/batchOverflow.qml
@@ -0,0 +1,20 @@
+import QtQml 2.2
+
+QtObject {
+ function iterate(dictionaryTable, j) {
+ var word = "a" + j.toString()
+ dictionaryTable[word] = null;
+ }
+
+ Component.onCompleted: {
+ var dictionaryTable = {};
+ for (var j = 0; j < 256; ++j)
+ iterate(dictionaryTable, j);
+ }
+
+ property Timer timer: Timer {
+ interval: 1
+ running: true;
+ onTriggered: Qt.quit();
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
index 2a685ed877..0cd4b331f2 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -21,4 +21,5 @@ OTHER_FILES += \
data/javascript.qml \
data/timer.qml \
data/qstr.qml \
- data/memory.qml
+ data/memory.qml \
+ data/batchOverflow.qml
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index eb0b0c2fe2..7fc43671c2 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -225,6 +225,7 @@ private slots:
void memory();
void compile();
void multiEngine();
+ void batchOverflow();
private:
bool m_recordFromStart = true;
@@ -826,6 +827,15 @@ void tst_QQmlProfilerService::multiEngine()
QCOMPARE(spy.count(), 1);
}
+void tst_QQmlProfilerService::batchOverflow()
+{
+ // The trace client checks that the events are received in order.
+ QCOMPARE(connect(true, "batchOverflow.qml"), ConnectSuccess);
+ checkProcessTerminated();
+ checkTraceReceived();
+ checkJsHeap();
+}
+
QTEST_MAIN(tst_QQmlProfilerService)
#include "tst_qqmlprofilerservice.moc"