Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qmldebug/qqmlprofilerclient.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | QQmlProfilerClientPrivate::~QQmlProfilerClientPrivate() | - | ||||||
5 | { | - | ||||||
6 | } | - | ||||||
7 | - | |||||||
8 | int QQmlProfilerClientPrivate::resolveType(const QQmlProfilerTypedEvent &event) | - | ||||||
9 | { | - | ||||||
10 | int typeIndex = -1; | - | ||||||
11 | if (event.serverTypeId != 0
| 296-594 | ||||||
12 | QHash<qint64, int>::ConstIterator it = serverTypeIds.constFind(event.serverTypeId); | - | ||||||
13 | - | |||||||
14 | if (it != serverTypeIds.constEnd()
| 86-210 | ||||||
15 | typeIndex = it.value(); | - | ||||||
16 | } executed 210 times by 1 test: else {end of block Executed by:
| 210 | ||||||
17 | typeIndex = eventReceiver->numLoadedEventTypes(); | - | ||||||
18 | eventReceiver->addEventType(event.type); | - | ||||||
19 | serverTypeIds[event.serverTypeId] = typeIndex; | - | ||||||
20 | } executed 86 times by 1 test: end of block Executed by:
| 86 | ||||||
21 | } else { | - | ||||||
22 | QHash<QQmlProfilerEventType, int>::ConstIterator it = eventTypeIds.constFind(event.type); | - | ||||||
23 | - | |||||||
24 | if (it != eventTypeIds.constEnd()
| 132-462 | ||||||
25 | typeIndex = it.value(); | - | ||||||
26 | } executed 462 times by 1 test: else {end of block Executed by:
| 462 | ||||||
27 | typeIndex = eventReceiver->numLoadedEventTypes(); | - | ||||||
28 | eventReceiver->addEventType(event.type); | - | ||||||
29 | eventTypeIds[event.type] = typeIndex; | - | ||||||
30 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||
31 | } | - | ||||||
32 | return executed 890 times by 1 test: typeIndex;return typeIndex; Executed by:
executed 890 times by 1 test: return typeIndex; Executed by:
| 890 | ||||||
33 | } | - | ||||||
34 | - | |||||||
35 | int QQmlProfilerClientPrivate::resolveStackTop() | - | ||||||
36 | { | - | ||||||
37 | if (rangesInProgress.isEmpty()
| 159-435 | ||||||
38 | return executed 159 times by 1 test: -1;return -1; Executed by:
executed 159 times by 1 test: return -1; Executed by:
| 159 | ||||||
39 | - | |||||||
40 | QQmlProfilerTypedEvent &typedEvent = rangesInProgress.top(); | - | ||||||
41 | int typeIndex = typedEvent.event.typeIndex(); | - | ||||||
42 | if (typeIndex >= 0
| 139-296 | ||||||
43 | return executed 139 times by 1 test: typeIndex;return typeIndex; Executed by:
executed 139 times by 1 test: return typeIndex; Executed by:
| 139 | ||||||
44 | - | |||||||
45 | typeIndex = resolveType(typedEvent); | - | ||||||
46 | typedEvent.event.setTypeIndex(typeIndex); | - | ||||||
47 | while (!pendingMessages.isEmpty()
| 78-260 | ||||||
48 | && pendingMessages.head().timestamp() < typedEvent.event.timestamp()
| 36-42 | ||||||
49 | forwardEvents(pendingMessages.dequeue()); | - | ||||||
50 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||
51 | forwardEvents(typedEvent.event); | - | ||||||
52 | return executed 296 times by 1 test: typeIndex;return typeIndex; Executed by:
executed 296 times by 1 test: return typeIndex; Executed by:
| 296 | ||||||
53 | } | - | ||||||
54 | - | |||||||
55 | void QQmlProfilerClientPrivate::forwardEvents(const QQmlProfilerEvent &last) | - | ||||||
56 | { | - | ||||||
57 | while (!pendingDebugMessages.isEmpty()
| 182-554 | ||||||
58 | && pendingDebugMessages.front().timestamp() <= last.timestamp()
| 16-166 | ||||||
59 | eventReceiver->addEvent(pendingDebugMessages.dequeue()); | - | ||||||
60 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||
61 | eventReceiver->addEvent(last); | - | ||||||
62 | } executed 720 times by 1 test: end of block Executed by:
| 720 | ||||||
63 | - | |||||||
64 | void QQmlProfilerClientPrivate::processCurrentEvent() | - | ||||||
65 | { | - | ||||||
66 | - | |||||||
67 | - | |||||||
68 | - | |||||||
69 | - | |||||||
70 | Message rangeStage = currentEvent.type.rangeType() == MaximumRangeType
| 594-744 | ||||||
71 | currentEvent.type.message() : currentEvent.event.rangeStage(); | - | ||||||
72 | switch (rangeStage) { | - | ||||||
73 | case executed 296 times by 1 test: RangeStart:case RangeStart: Executed by:
executed 296 times by 1 test: case RangeStart: Executed by:
| 296 | ||||||
74 | resolveStackTop(); | - | ||||||
75 | rangesInProgress.push(currentEvent); | - | ||||||
76 | break; executed 296 times by 1 test: break; Executed by:
| 296 | ||||||
77 | case executed 298 times by 1 test: RangeEnd:case RangeEnd: Executed by:
executed 298 times by 1 test: {case RangeEnd: Executed by:
| 298 | ||||||
78 | int typeIndex = resolveStackTop(); | - | ||||||
79 | if (typeIndex == -1
| 2-296 | ||||||
80 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||
81 | currentEvent.event.setTypeIndex(typeIndex); | - | ||||||
82 | while (!pendingMessages.isEmpty()
| 86-296 | ||||||
83 | forwardEvents(pendingMessages.dequeue()); executed 86 times by 1 test: forwardEvents(pendingMessages.dequeue()); Executed by:
| 86 | ||||||
84 | forwardEvents(currentEvent.event); | - | ||||||
85 | rangesInProgress.pop(); | - | ||||||
86 | break; executed 296 times by 1 test: break; Executed by:
| 296 | ||||||
87 | } | - | ||||||
88 | case executed 64 times by 1 test: RangeData:case RangeData: Executed by:
executed 64 times by 1 test: case RangeData: Executed by:
| 64 | ||||||
89 | if (!rangesInProgress.isEmpty()
| 0-64 | ||||||
90 | rangesInProgress.top().type.setData(currentEvent.type.data()); executed 64 times by 1 test: rangesInProgress.top().type.setData(currentEvent.type.data()); Executed by:
| 64 | ||||||
91 | break; executed 64 times by 1 test: break; Executed by:
| 64 | ||||||
92 | case executed 86 times by 1 test: RangeLocation:case RangeLocation: Executed by:
executed 86 times by 1 test: case RangeLocation: Executed by:
| 86 | ||||||
93 | if (!rangesInProgress.isEmpty()
| 0-86 | ||||||
94 | rangesInProgress.top().type.setLocation(currentEvent.type.location()); executed 86 times by 1 test: rangesInProgress.top().type.setLocation(currentEvent.type.location()); Executed by:
| 86 | ||||||
95 | break; executed 86 times by 1 test: break; Executed by:
| 86 | ||||||
96 | case executed 18 times by 1 test: DebugMessage:case DebugMessage: Executed by:
executed 18 times by 1 test: case DebugMessage: Executed by:
| 18 | ||||||
97 | currentEvent.event.setTypeIndex(resolveType(currentEvent)); | - | ||||||
98 | pendingDebugMessages.enqueue(currentEvent.event); | - | ||||||
99 | break; executed 18 times by 1 test: break; Executed by:
| 18 | ||||||
100 | default executed 576 times by 1 test: :default: Executed by:
executed 576 times by 1 test: {default: Executed by:
| 576 | ||||||
101 | int typeIndex = resolveType(currentEvent); | - | ||||||
102 | currentEvent.event.setTypeIndex(typeIndex); | - | ||||||
103 | if (rangesInProgress.isEmpty()
| 128-448 | ||||||
104 | eventReceiver->addEvent(currentEvent.event); executed 448 times by 1 test: eventReceiver->addEvent(currentEvent.event); Executed by:
| 448 | ||||||
105 | else | - | ||||||
106 | pendingMessages.enqueue(currentEvent.event); executed 128 times by 1 test: pendingMessages.enqueue(currentEvent.event); Executed by:
| 128 | ||||||
107 | break; executed 576 times by 1 test: break; Executed by:
| 576 | ||||||
108 | } | - | ||||||
109 | } | - | ||||||
110 | } | - | ||||||
111 | - | |||||||
112 | void QQmlProfilerClientPrivate::sendRecordingStatus(int engineId) | - | ||||||
113 | { | - | ||||||
114 | QQmlProfilerClient * const q = q_func(); | - | ||||||
115 | QPacket stream(connection->currentDataStreamVersion()); | - | ||||||
116 | stream << recording << engineId; | - | ||||||
117 | if (recording
| 40-60 | ||||||
118 | stream << requestedFeatures << flushInterval; | - | ||||||
119 | stream << true; | - | ||||||
120 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||
121 | q->sendMessage(stream.data()); | - | ||||||
122 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||
123 | - | |||||||
124 | QQmlProfilerClient::QQmlProfilerClient(QQmlDebugConnection *connection, | - | ||||||
125 | QQmlProfilerEventReceiver *eventReceiver, | - | ||||||
126 | quint64 features) | - | ||||||
127 | : QQmlDebugClient(*(new QQmlProfilerClientPrivate(connection, eventReceiver))) | - | ||||||
128 | { | - | ||||||
129 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
130 | setRequestedFeatures(features); | - | ||||||
131 | connect(this, &QQmlDebugClient::stateChanged, this, &QQmlProfilerClient::onStateChanged); | - | ||||||
132 | connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeAdded, | - | ||||||
133 | this, &QQmlProfilerClient::sendRecordingStatus); | - | ||||||
134 | connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeRemoved, | - | ||||||
135 | this, [d](int engineId) { | - | ||||||
136 | - | |||||||
137 | if (d->trackedEngines.contains(engineId)
| 2-4 | ||||||
138 | d->engineControl->blockEngine(engineId); executed 4 times by 1 test: d->engineControl->blockEngine(engineId); Executed by:
| 4 | ||||||
139 | } executed 6 times by 1 test: );end of block Executed by:
| 6 | ||||||
140 | connect(this, &QQmlProfilerClient::traceFinished, | - | ||||||
141 | d->engineControl.data(), [d](qint64 timestamp, const QList<int> &engineIds) { | - | ||||||
142 | (void)timestamp;; | - | ||||||
143 | - | |||||||
144 | - | |||||||
145 | for (int blocked : d->engineControl->blockedEngines()) { | - | ||||||
146 | if (engineIds.contains(blocked)
| 0-4 | ||||||
147 | d->engineControl->releaseEngine(blocked); executed 4 times by 1 test: d->engineControl->releaseEngine(blocked); Executed by:
| 4 | ||||||
148 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
149 | } executed 34 times by 1 test: );end of block Executed by:
| 34 | ||||||
150 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||
151 | - | |||||||
152 | QQmlProfilerClient::~QQmlProfilerClient() | - | ||||||
153 | { | - | ||||||
154 | - | |||||||
155 | - | |||||||
156 | if (isRecording()
| 8-28 | ||||||
157 | setRecording(false); executed 8 times by 1 test: setRecording(false); Executed by:
| 8 | ||||||
158 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||
159 | - | |||||||
160 | void QQmlProfilerClient::clearEvents() | - | ||||||
161 | { | - | ||||||
162 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
163 | d->rangesInProgress.clear(); | - | ||||||
164 | d->pendingMessages.clear(); | - | ||||||
165 | d->pendingDebugMessages.clear(); | - | ||||||
166 | if (d->recordedFeatures != 0
| 0 | ||||||
167 | d->recordedFeatures = 0; | - | ||||||
168 | recordedFeaturesChanged(0); | - | ||||||
169 | } never executed: end of block | 0 | ||||||
170 | cleared(); | - | ||||||
171 | } never executed: end of block | 0 | ||||||
172 | - | |||||||
173 | void QQmlProfilerClient::clearAll() | - | ||||||
174 | { | - | ||||||
175 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
176 | d->serverTypeIds.clear(); | - | ||||||
177 | d->eventTypeIds.clear(); | - | ||||||
178 | d->trackedEngines.clear(); | - | ||||||
179 | clearEvents(); | - | ||||||
180 | } never executed: end of block | 0 | ||||||
181 | - | |||||||
182 | void QQmlProfilerClientPrivate::finalize() | - | ||||||
183 | { | - | ||||||
184 | while (!rangesInProgress.isEmpty()
| 2-34 | ||||||
185 | currentEvent = rangesInProgress.top(); | - | ||||||
186 | currentEvent.event.setRangeStage(RangeEnd); | - | ||||||
187 | currentEvent.event.setTimestamp(maximumTime); | - | ||||||
188 | processCurrentEvent(); | - | ||||||
189 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
190 | while (!pendingDebugMessages.isEmpty()
| 0-34 | ||||||
191 | eventReceiver->addEvent(pendingDebugMessages.dequeue()); never executed: eventReceiver->addEvent(pendingDebugMessages.dequeue()); | 0 | ||||||
192 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||
193 | - | |||||||
194 | - | |||||||
195 | void QQmlProfilerClient::sendRecordingStatus(int engineId) | - | ||||||
196 | { | - | ||||||
197 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
198 | d->sendRecordingStatus(engineId); | - | ||||||
199 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||
200 | - | |||||||
201 | bool QQmlProfilerClient::isRecording() const | - | ||||||
202 | { | - | ||||||
203 | const QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
204 | return executed 36 times by 1 test: d->recording;return d->recording; Executed by:
executed 36 times by 1 test: return d->recording; Executed by:
| 36 | ||||||
205 | } | - | ||||||
206 | - | |||||||
207 | void QQmlProfilerClient::setRecording(bool v) | - | ||||||
208 | { | - | ||||||
209 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
210 | if (v == d->recording
| 12-68 | ||||||
211 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||
212 | - | |||||||
213 | d->recording = v; | - | ||||||
214 | - | |||||||
215 | if (state() == Enabled
| 32-36 | ||||||
216 | sendRecordingStatus(); executed 36 times by 1 test: sendRecordingStatus(); Executed by:
| 36 | ||||||
217 | - | |||||||
218 | recordingChanged(v); | - | ||||||
219 | } executed 68 times by 1 test: end of block Executed by:
| 68 | ||||||
220 | - | |||||||
221 | quint64 QQmlProfilerClient::recordedFeatures() const | - | ||||||
222 | { | - | ||||||
223 | const QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
224 | return never executed: d->recordedFeatures;return d->recordedFeatures; never executed: return d->recordedFeatures; | 0 | ||||||
225 | } | - | ||||||
226 | - | |||||||
227 | void QQmlProfilerClient::setRequestedFeatures(quint64 features) | - | ||||||
228 | { | - | ||||||
229 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
230 | d->requestedFeatures = features; | - | ||||||
231 | if (features & static_cast<quint64>(1) << ProfileDebugMessages
| 0-36 | ||||||
232 | if (d->messageClient.isNull()
| 0-36 | ||||||
233 | d->messageClient.reset(new QQmlDebugMessageClient(connection())); | - | ||||||
234 | connect(d->messageClient.data(), &QQmlDebugMessageClient::message, this, | - | ||||||
235 | [this](QtMsgType type, const QString &text, const QQmlDebugContextInfo &context) | - | ||||||
236 | { | - | ||||||
237 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
238 | d->updateFeatures(ProfileDebugMessages); | - | ||||||
239 | d->currentEvent.event.setTimestamp(context.timestamp > 0 ? context.timestamp : 0); | - | ||||||
240 | d->currentEvent.event.setTypeIndex(-1); | - | ||||||
241 | d->currentEvent.event.setString(text); | - | ||||||
242 | d->currentEvent.type = QQmlProfilerEventType( | - | ||||||
243 | DebugMessage, MaximumRangeType, type, | - | ||||||
244 | QQmlProfilerEventLocation(context.file, context.line, 1)); | - | ||||||
245 | d->currentEvent.serverTypeId = 0; | - | ||||||
246 | d->processCurrentEvent(); | - | ||||||
247 | } executed 18 times by 1 test: );end of block Executed by:
| 18 | ||||||
248 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||
249 | } executed 36 times by 1 test: else {end of block Executed by:
| 36 | ||||||
250 | d->messageClient.reset(); | - | ||||||
251 | } never executed: end of block | 0 | ||||||
252 | } | - | ||||||
253 | - | |||||||
254 | void QQmlProfilerClient::setFlushInterval(quint32 flushInterval) | - | ||||||
255 | { | - | ||||||
256 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
257 | d->flushInterval = flushInterval; | - | ||||||
258 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||
259 | - | |||||||
260 | QQmlProfilerClient::QQmlProfilerClient(QQmlProfilerClientPrivate &dd) : | - | ||||||
261 | QQmlDebugClient(dd) | - | ||||||
262 | { | - | ||||||
263 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
264 | connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeAdded, | - | ||||||
265 | this, &QQmlProfilerClient::sendRecordingStatus); | - | ||||||
266 | } never executed: end of block | 0 | ||||||
267 | - | |||||||
268 | bool QQmlProfilerClientPrivate::updateFeatures(ProfileFeature feature) | - | ||||||
269 | { | - | ||||||
270 | QQmlProfilerClient * const q = q_func(); | - | ||||||
271 | quint64 flag = 1ULL << feature; | - | ||||||
272 | if (!(requestedFeatures & flag)
| 0-1336 | ||||||
273 | return never executed: false;return false; never executed: return false; | 0 | ||||||
274 | if (!(recordedFeatures & flag)
| 124-1212 | ||||||
275 | recordedFeatures |= flag; | - | ||||||
276 | q->recordedFeaturesChanged(recordedFeatures); | - | ||||||
277 | } executed 124 times by 1 test: end of block Executed by:
| 124 | ||||||
278 | return executed 1336 times by 1 test: true;return true; Executed by:
executed 1336 times by 1 test: return true; Executed by:
| 1336 | ||||||
279 | } | - | ||||||
280 | - | |||||||
281 | void QQmlProfilerClient::onStateChanged(State status) | - | ||||||
282 | { | - | ||||||
283 | if (status == Enabled
| 0-36 | ||||||
284 | sendRecordingStatus(-1); | - | ||||||
285 | } executed 36 times by 1 test: else {end of block Executed by:
| 36 | ||||||
286 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
287 | d->finalize(); | - | ||||||
288 | } never executed: end of block | 0 | ||||||
289 | - | |||||||
290 | } | - | ||||||
291 | - | |||||||
292 | void QQmlProfilerClient::messageReceived(const QByteArray &data) | - | ||||||
293 | { | - | ||||||
294 | QQmlProfilerClientPrivate * const d = d_func(); | - | ||||||
295 | QPacket stream(d->connection->currentDataStreamVersion(), data); | - | ||||||
296 | - | |||||||
297 | stream >> d->currentEvent; | - | ||||||
298 | - | |||||||
299 | d->maximumTime = qMax(d->currentEvent.event.timestamp(), d->maximumTime); | - | ||||||
300 | if (d->currentEvent.type.message() == Complete
| 34-1388 | ||||||
301 | d->finalize(); | - | ||||||
302 | complete(d->maximumTime); | - | ||||||
303 | } executed 34 times by 1 test: else if (d->currentEvent.type.message() == Eventend of block Executed by:
| 34-1215 | ||||||
304 | && d->currentEvent.type.detailType() == StartTrace
| 36-137 | ||||||
305 | const QList<int> engineIds = d->currentEvent.event.numbers<QList<int>, qint32>(); | - | ||||||
306 | d->trackedEngines.append(engineIds); | - | ||||||
307 | traceStarted(d->currentEvent.event.timestamp(), engineIds); | - | ||||||
308 | } executed 36 times by 1 test: else if (d->currentEvent.type.message() == Eventend of block Executed by:
| 36-1215 | ||||||
309 | && d->currentEvent.type.detailType() == EndTrace
| 34-103 | ||||||
310 | const QList<int> engineIds = d->currentEvent.event.numbers<QList<int>, qint32>(); | - | ||||||
311 | for (int engineId : engineIds) | - | ||||||
312 | d->trackedEngines.removeAll(engineId); executed 34 times by 1 test: d->trackedEngines.removeAll(engineId); Executed by:
| 34 | ||||||
313 | traceFinished(d->currentEvent.event.timestamp(), engineIds); | - | ||||||
314 | } executed 34 times by 1 test: else if (d->updateFeatures(d->currentEvent.type.feature())end of block Executed by:
| 0-1318 | ||||||
315 | d->processCurrentEvent(); | - | ||||||
316 | } executed 1318 times by 1 test: end of block Executed by:
| 1318 | ||||||
317 | } executed 1422 times by 1 test: end of block Executed by:
| 1422 | ||||||
318 | - | |||||||
319 | - | |||||||
320 | - | |||||||
Switch to Source code | Preprocessed file |