OpenCoverage

qv4debugger.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6QV4Debugger::BreakPoint::BreakPoint(const QString &fileName, int line)-
7 : fileName(fileName), lineNumber(line)-
8{}
executed 810 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
810
9-
10inline uint qHash(const QV4Debugger::BreakPoint &b, uint seed = 0) noexcept-
11{-
12 return
executed 810 times by 2 tests: return qHash(b.fileName, seed) ^ b.lineNumber;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
qHash(b.fileName, seed) ^ b.lineNumber;
executed 810 times by 2 tests: return qHash(b.fileName, seed) ^ b.lineNumber;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
810
13}-
14-
15inline bool operator==(const QV4Debugger::BreakPoint &a,-
16 const QV4Debugger::BreakPoint &b)-
17{-
18 return
executed 124 times by 2 tests: return a.lineNumber == b.lineNumber && a.fileName == b.fileName;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
a.lineNumber == b.lineNumber && a.fileName == b.fileName;
executed 124 times by 2 tests: return a.lineNumber == b.lineNumber && a.fileName == b.fileName;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
124
19}-
20-
21QV4Debugger::QV4Debugger(QV4::ExecutionEngine *engine)-
22 : m_engine(engine)-
23 , m_state(Running)-
24 , m_stepping(NotStepping)-
25 , m_pauseRequested(false)-
26 , m_haveBreakPoints(false)-
27 , m_breakOnThrow(false)-
28 , m_returnedValue(engine, QV4::Primitive::undefinedValue())-
29 , m_gatherSources(nullptr)-
30 , m_runningJob(nullptr)-
31 , m_collector(engine)-
32{-
33 static int debuggerId = qRegisterMetaType<QV4Debugger*>();-
34 static int pauseReasonId = qRegisterMetaType<QV4Debugger::PauseReason>();-
35 (void)debuggerId;;-
36 (void)pauseReasonId;;-
37 connect(this, &QV4Debugger::scheduleJob,-
38 this, &QV4Debugger::runJobUnpaused, Qt::QueuedConnection);-
39}
executed 110 times by 3 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qv4debugger
110
40-
41QV4::ExecutionEngine *QV4Debugger::engine() const-
42{-
43 return
executed 2128 times by 2 tests: return m_engine;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
m_engine;
executed 2128 times by 2 tests: return m_engine;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
2128
44}-
45-
46const QV4DataCollector *QV4Debugger::collector() const-
47{-
48 return
never executed: return &m_collector;
&m_collector;
never executed: return &m_collector;
0
49}-
50-
51QV4DataCollector *QV4Debugger::collector()-
52{-
53 return
executed 16 times by 1 test: return &m_collector;
Executed by:
  • tst_qqmldebugjs
&m_collector;
executed 16 times by 1 test: return &m_collector;
Executed by:
  • tst_qqmldebugjs
16
54}-
55-
56void QV4Debugger::pause()-
57{-
58 QMutexLocker locker(&m_lock);-
59 if (m_state == Paused
m_state == PausedDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-4
60 return;
never executed: return;
0
61 m_pauseRequested = true;-
62}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
4
63-
64void QV4Debugger::resume(Speed speed)-
65{-
66 QMutexLocker locker(&m_lock);-
67 if (m_state != Paused
m_state != PausedDescription
TRUEnever evaluated
FALSEevaluated 480 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
0-480
68 return;
never executed: return;
0
69-
70 if (!m_returnedValue.isUndefined()
!m_returnedValue.isUndefined()Description
TRUEnever evaluated
FALSEevaluated 480 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
0-480
71 m_returnedValue.set(m_engine, QV4::Encode::undefined());
never executed: m_returnedValue.set(m_engine, QV4::Encode::undefined());
0
72-
73 m_currentFrame = m_engine->currentStackFrame;-
74 m_stepping = speed;-
75 m_runningCondition.wakeAll();-
76}
executed 480 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
480
77-
78QV4Debugger::State QV4Debugger::state() const-
79{-
80 return
executed 722 times by 2 tests: return m_state;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
m_state;
executed 722 times by 2 tests: return m_state;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
722
81}-
82-
83void QV4Debugger::addBreakPoint(const QString &fileName, int lineNumber, const QString &condition)-
84{-
85 QMutexLocker locker(&m_lock);-
86 m_breakPoints.insert(BreakPoint(fileName.mid(fileName.lastIndexOf('/') + 1),-
87 lineNumber), condition);-
88 m_haveBreakPoints = true;-
89}
executed 104 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
104
90-
91void QV4Debugger::removeBreakPoint(const QString &fileName, int lineNumber)-
92{-
93 QMutexLocker locker(&m_lock);-
94 m_breakPoints.remove(BreakPoint(fileName.mid(fileName.lastIndexOf('/') + 1),-
95 lineNumber));-
96 m_haveBreakPoints = !m_breakPoints.isEmpty();-
97}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
4
98-
99void QV4Debugger::setBreakOnThrow(bool onoff)-
100{-
101 QMutexLocker locker(&m_lock);-
102-
103 m_breakOnThrow = onoff;-
104}
executed 28 times by 3 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qv4debugger
28
105-
106void QV4Debugger::clearPauseRequest()-
107{-
108 QMutexLocker locker(&m_lock);-
109 m_pauseRequested = false;-
110}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qqmldebugjs
24
111-
112QV4Debugger::ExecutionState QV4Debugger::currentExecutionState() const-
113{-
114 ExecutionState state;-
115 state.fileName = getFunction()->sourceFile();-
116 state.lineNumber = engine()->currentStackFrame->lineNumber();-
117-
118 return
executed 464 times by 1 test: return state;
Executed by:
  • tst_qv4debugger
state;
executed 464 times by 1 test: return state;
Executed by:
  • tst_qv4debugger
464
119}-
120-
121bool QV4Debugger::pauseAtNextOpportunity() const {-
122 return
executed 1208 times by 2 tests: return m_pauseRequested || m_haveBreakPoints || m_gatherSources || m_stepping >= StepOver;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
m_pauseRequested || m_haveBreakPoints || m_gatherSources || m_stepping >= StepOver;
executed 1208 times by 2 tests: return m_pauseRequested || m_haveBreakPoints || m_gatherSources || m_stepping >= StepOver;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
1208
123}-
124-
125QVector<QV4::StackFrame> QV4Debugger::stackTrace(int frameLimit) const-
126{-
127 return
executed 464 times by 1 test: return m_engine->stackTrace(frameLimit);
Executed by:
  • tst_qv4debugger
m_engine->stackTrace(frameLimit);
executed 464 times by 1 test: return m_engine->stackTrace(frameLimit);
Executed by:
  • tst_qv4debugger
464
128}-
129-
130void QV4Debugger::maybeBreakAtInstruction()-
131{-
132 if (m_runningJob
m_runningJobDescription
TRUEevaluated 100 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 1082 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
100-1082
133 return;
executed 100 times by 1 test: return;
Executed by:
  • tst_qv4debugger
100
134-
135 QMutexLocker locker(&m_lock);-
136-
137 if (m_gatherSources
m_gatherSourcesDescription
TRUEnever evaluated
FALSEevaluated 1082 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
) {
0-1082
138 m_gatherSources->run();-
139 delete m_gatherSources;-
140 m_gatherSources = nullptr;-
141 }
never executed: end of block
0
142-
143 switch (m_stepping) {-
144 case
executed 376 times by 1 test: case StepOver:
Executed by:
  • tst_qv4debugger
StepOver:
executed 376 times by 1 test: case StepOver:
Executed by:
  • tst_qv4debugger
376
145 if (m_currentFrame != m_engine->currentStackFrame
m_currentFrame...rentStackFrameDescription
TRUEnever evaluated
FALSEevaluated 376 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-376
146 break;
never executed: break;
0
147 (void)0;-
148 case
never executed: case StepIn:
code before this statement executed 376 times by 1 test: case StepIn:
Executed by:
  • tst_qv4debugger
never executed: case StepIn:
StepIn:
code before this statement executed 376 times by 1 test: case StepIn:
Executed by:
  • tst_qv4debugger
never executed: case StepIn:
0-376
149 pauseAndWait(Step);-
150 return;
executed 376 times by 1 test: return;
Executed by:
  • tst_qv4debugger
376
151 case
never executed: case StepOut:
StepOut:
never executed: case StepOut:
0
152 case
executed 706 times by 2 tests: case NotStepping:
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
NotStepping:
executed 706 times by 2 tests: case NotStepping:
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
706
153 break;
executed 706 times by 2 tests: break;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
706
154 }-
155-
156 if (m_pauseRequested
m_pauseRequestedDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 702 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
) {
4-702
157 m_pauseRequested = false;-
158 pauseAndWait(PauseRequest);-
159 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
else if (m_haveBreakPoints
m_haveBreakPointsDescription
TRUEevaluated 702 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEnever evaluated
) {
0-702
160 if (QV4::Function *f = getFunction()
QV4::Function ... getFunction()Description
TRUEevaluated 702 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEnever evaluated
) {
0-702
161-
162 const int lineNumber = engine()->currentStackFrame->lineNumber();-
163 if (reallyHitTheBreakPoint(f->sourceFile(), lineNumber)
reallyHitTheBr...), lineNumber)Description
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEevaluated 604 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
98-604
164 pauseAndWait(BreakPointHit);
executed 98 times by 2 tests: pauseAndWait(BreakPointHit);
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
98
165 }
executed 702 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
702
166 }
executed 702 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
702
167}
executed 706 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
706
168-
169void QV4Debugger::enteringFunction()-
170{-
171 if (m_runningJob
m_runningJobDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 170 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
50-170
172 return;
executed 50 times by 1 test: return;
Executed by:
  • tst_qv4debugger
50
173 QMutexLocker locker(&m_lock);-
174-
175 if (m_stepping == StepIn
m_stepping == StepInDescription
TRUEnever evaluated
FALSEevaluated 170 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
0-170
176 m_currentFrame = m_engine->currentStackFrame;
never executed: m_currentFrame = m_engine->currentStackFrame;
0
177}
executed 170 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
170
178-
179void QV4Debugger::leavingFunction(const QV4::ReturnedValue &retVal)-
180{-
181 if (m_runningJob
m_runningJobDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 170 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
50-170
182 return;
executed 50 times by 1 test: return;
Executed by:
  • tst_qv4debugger
50
183 (void)retVal;;-
184-
185 QMutexLocker locker(&m_lock);-
186-
187 if (m_stepping != NotStepping
m_stepping != NotSteppingDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 134 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
&& m_currentFrame == m_engine->currentStackFrame
m_currentFrame...rentStackFrameDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
) {
0-134
188 m_currentFrame = m_currentFrame->parent;-
189 m_stepping = StepOver;-
190 m_returnedValue.set(m_engine, retVal);-
191 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
36
192}
executed 170 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
170
193-
194void QV4Debugger::aboutToThrow()-
195{-
196 if (!m_breakOnThrow
!m_breakOnThrowDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
2-6
197 return;
executed 6 times by 1 test: return;
Executed by:
  • tst_qv4debugger
6
198-
199 if (m_runningJob
m_runningJobDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-2
200 return;
never executed: return;
0
201-
202 QMutexLocker locker(&m_lock);-
203 pauseAndWait(Throwing);-
204}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
2
205-
206QV4::Function *QV4Debugger::getFunction() const-
207{-
208 if (m_engine->currentStackFrame
m_engine->currentStackFrameDescription
TRUEevaluated 1166 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEnever evaluated
)
0-1166
209 return
executed 1166 times by 2 tests: return m_engine->currentStackFrame->v4Function;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
m_engine->currentStackFrame->v4Function;
executed 1166 times by 2 tests: return m_engine->currentStackFrame->v4Function;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
1166
210 else-
211 return
never executed: return m_engine->globalCode;
m_engine->globalCode;
never executed: return m_engine->globalCode;
0
212}-
213-
214void QV4Debugger::runJobUnpaused()-
215{-
216 QMutexLocker locker(&m_lock);-
217 if (m_runningJob
m_runningJobDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
218 m_runningJob->run();
never executed: m_runningJob->run();
0
219 m_jobIsRunning.wakeAll();-
220}
never executed: end of block
0
221-
222void QV4Debugger::pauseAndWait(PauseReason reason)-
223{-
224 if (m_runningJob
m_runningJobDescription
TRUEnever evaluated
FALSEevaluated 480 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
0-480
225 return;
never executed: return;
0
226-
227 m_state = Paused;-
228 debuggerPaused(this, reason);-
229-
230 while (true) {-
231 m_runningCondition.wait(&m_lock);-
232 if (m_runningJob
m_runningJobDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 480 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
) {
192-480
233 m_runningJob->run();-
234 m_jobIsRunning.wakeAll();-
235 }
executed 192 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
else {
192
236 break;
executed 480 times by 2 tests: break;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
480
237 }-
238 }-
239-
240 m_state = Running;-
241}
executed 480 times by 2 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
480
242-
243bool QV4Debugger::reallyHitTheBreakPoint(const QString &filename, int linenr)-
244{-
245 QHash<BreakPoint, QString>::iterator it = m_breakPoints.find(-
246 BreakPoint(filename.mid(filename.lastIndexOf('/') + 1), linenr));-
247 if (it == m_breakPoints.end()
it == m_breakPoints.end()Description
TRUEevaluated 582 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEevaluated 120 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
)
120-582
248 return
executed 582 times by 2 tests: return false;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
false;
executed 582 times by 2 tests: return false;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
582
249 QString condition = it.value();-
250 if (condition.isEmpty()
condition.isEmpty()Description
TRUEevaluated 88 times by 2 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qv4debugger
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
32-88
251 return
executed 88 times by 2 tests: return true;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
true;
executed 88 times by 2 tests: return true;
Executed by:
  • tst_qqmldebugjs
  • tst_qv4debugger
88
252-
253 ((m_runningJob == nullptr) ? static_cast<void>(0) : qt_assert("m_runningJob == nullptr", __FILE__, 298));-
254 EvalJob evilJob(m_engine, condition);-
255 m_runningJob = &evilJob;-
256 m_runningJob->run();-
257 m_runningJob = nullptr;-
258-
259 return
executed 32 times by 1 test: return evilJob.resultAsBoolean();
Executed by:
  • tst_qv4debugger
evilJob.resultAsBoolean();
executed 32 times by 1 test: return evilJob.resultAsBoolean();
Executed by:
  • tst_qv4debugger
32
260}-
261-
262void QV4Debugger::runInEngine(QV4DebugJob *job)-
263{-
264 QMutexLocker locker(&m_lock);-
265 runInEngine_havingLock(job);-
266}
executed 192 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
192
267-
268void QV4Debugger::runInEngine_havingLock(QV4DebugJob *job)-
269{-
270 ((job) ? static_cast<void>(0) : qt_assert("job", __FILE__, 315));-
271 ((m_runningJob == nullptr) ? static_cast<void>(0) : qt_assert("m_runningJob == nullptr", __FILE__, 316));-
272-
273 m_runningJob = job;-
274 if (state() == Paused
state() == PausedDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
)
0-192
275 m_runningCondition.wakeAll();
executed 192 times by 1 test: m_runningCondition.wakeAll();
Executed by:
  • tst_qv4debugger
192
276 else-
277 scheduleJob();
never executed: scheduleJob();
0
278 m_jobIsRunning.wait(&m_lock);-
279 m_runningJob = nullptr;-
280}
executed 192 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
192
281-
282-
283-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0