OpenCoverage

qv4debugjob.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6QV4DebugJob::~QV4DebugJob()-
7{-
8}-
9-
10JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context,-
11 const QString &script) :-
12 engine(engine), frameNr(frameNr), context(context), script(script),-
13 resultIsException(false)-
14{}
executed 50 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
50
15-
16void JavaScriptJob::run()-
17{-
18 QV4::Scope scope(engine);-
19-
20 QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext()-
21 : engine->scriptContext());-
22 QObject scopeObject;-
23-
24 QV4::CppStackFrame *frame = engine->currentStackFrame;-
25-
26 for (int i = 0; frame
frameDescription
TRUEevaluated 62 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
&& i < frameNr
i < frameNrDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
; ++i)
0-62
27 frame = frame->parent;
executed 12 times by 1 test: frame = frame->parent;
Executed by:
  • tst_qv4debugger
12
28 if (frameNr > 0
frameNr > 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qv4debugger
&& frame
frameDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
)
0-38
29 ctx = static_cast<QV4::ExecutionContext *>(&frame->jsFrame->context);
executed 12 times by 1 test: ctx = static_cast<QV4::ExecutionContext *>(&frame->jsFrame->context);
Executed by:
  • tst_qv4debugger
12
30-
31 if (context >= 0
context >= 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qv4debugger
) {
8-42
32 QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context));-
33 if (extraContext
extraContextDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-8
34 ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), &scopeObject);
never executed: ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), &scopeObject);
0
35 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
else if (frameNr < 0
frameNr < 0Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qv4debugger
) {
8-32
36 QQmlEngine *qmlEngine = engine->qmlEngine();-
37 if (qmlEngine
qmlEngineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qv4debugger
) {
2-30
38 QQmlContext *qmlRootContext = qmlEngine->rootContext();-
39 QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(qmlRootContext);-
40-
41 QV4::ScopedObject withContext(scope, engine->newObject());-
42 QV4::ScopedString k(scope);-
43 QV4::ScopedValue v(scope);-
44 for (int ii = 0; ii < ctxtPriv->instances.count()
ii < ctxtPriv-...tances.count()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qv4debugger
; ++ii) {
0-2
45 QObject *object = ctxtPriv->instances.at(ii);-
46 if (QQmlContext *context = qmlContext(object)
QQmlContext *c...ontext(object)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
47 if (QQmlContextData *cdata = QQmlContextData::get(context)
QQmlContextDat...::get(context)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
48 v = QV4::QObjectWrapper::wrap(engine, object);-
49 k = engine->newString(cdata->findObjectId(object));-
50 withContext->put(k, v);-
51 }
never executed: end of block
0
52 }
never executed: end of block
0
53 }
never executed: end of block
0
54 if (!engine->qmlContext()
!engine->qmlContext()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-2
55 ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), &scopeObject);
never executed: ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), &scopeObject);
0
56 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
2
57 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
32
58-
59 QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, this->script);-
60 if (const
const QV4::Fun...ne->globalCodeDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
QV4::Function *function = frame
frameDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
? frame->v4Function : engine->globalCode
const QV4::Fun...ne->globalCodeDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
)
0-50
61 script.strictMode = function->isStrict();
executed 50 times by 1 test: script.strictMode = function->isStrict();
Executed by:
  • tst_qv4debugger
50
62-
63-
64-
65 script.inheritContext = true;-
66 script.parse();-
67 QV4::ScopedValue result(scope);-
68 if (!scope.engine->hasException
!scope.engine->hasExceptionDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
) {
0-50
69 if (frame
frameDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
) {
0-50
70 QV4::ScopedValue thisObject(scope, frame->thisObject());-
71 result = script.run(thisObject);-
72 }
executed 50 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
else {
50
73 result = script.run();-
74 }
never executed: end of block
0
75 }-
76 if (scope.engine->hasException
scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qv4debugger
) {
0-50
77 result = scope.engine->catchException();-
78 resultIsException = true;-
79 }
never executed: end of block
0
80 handleResult(result);-
81}
executed 50 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
50
82-
83bool JavaScriptJob::hasExeption() const-
84{-
85 return
executed 18 times by 1 test: return resultIsException;
Executed by:
  • tst_qv4debugger
resultIsException;
executed 18 times by 1 test: return resultIsException;
Executed by:
  • tst_qv4debugger
18
86}-
87-
88BacktraceJob::BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame) :-
89 CollectJob(collector), fromFrame(fromFrame), toFrame(toFrame)-
90{-
91}
never executed: end of block
0
92-
93void BacktraceJob::run()-
94{-
95 QJsonArray frameArray;-
96 QVector<QV4::StackFrame> frames = collector->engine()->stackTrace(toFrame);-
97 for (int i = fromFrame; i < toFrame
i < toFrameDescription
TRUEnever evaluated
FALSEnever evaluated
&& i < frames.size()
i < frames.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
98 frameArray.push_back(collector->buildFrame(frames[i], i));
never executed: frameArray.push_back(collector->buildFrame(frames[i], i));
0
99 if (frameArray.isEmpty()
frameArray.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
100 result.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "totalFrames")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "totalFrames" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()), 0);
0
101 }
never executed: end of block
else {
0
102 result.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "fromFrame")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "fromFrame" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()), fromFrame);
0
103 result.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "toFrame")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "toFrame" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()), fromFrame + frameArray.size());
0
104 result.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "frames")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "frames" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()), frameArray);
0
105 }
never executed: end of block
0
106 flushRedundantRefs();-
107}
never executed: end of block
0
108-
109FrameJob::FrameJob(QV4DataCollector *collector, int frameNr) :-
110 CollectJob(collector), frameNr(frameNr), success(false)-
111{-
112}
executed 100 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
100
113-
114void FrameJob::run()-
115{-
116 QVector<QV4::StackFrame> frames = collector->engine()->stackTrace(frameNr + 1);-
117 if (frameNr >= frames.length()
frameNr >= frames.length()Description
TRUEnever evaluated
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qv4debugger
) {
0-100
118 success = false;-
119 }
never executed: end of block
else {
0
120 result = collector->buildFrame(frames[frameNr], frameNr);-
121 flushRedundantRefs();-
122 success = true;-
123 }
executed 100 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
100
124}-
125-
126bool FrameJob::wasSuccessful() const-
127{-
128 return
never executed: return success;
success;
never executed: return success;
0
129}-
130-
131ScopeJob::ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr) :-
132 CollectJob(collector), frameNr(frameNr), scopeNr(scopeNr), success(false)-
133{-
134}
executed 72 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
72
135-
136void ScopeJob::run()-
137{-
138 QJsonObject object;-
139 success = collector->collectScope(&object, frameNr, scopeNr);-
140-
141 if (success
successDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEnever evaluated
) {
0-72
142 QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes =-
143 collector->getScopeTypes(frameNr);-
144 result[QLatin1String("type")] = QV4DataCollector::encodeScopeType(scopeTypes[scopeNr]);-
145 }
executed 72 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
else {
72
146 result[QLatin1String("type")] = -1;-
147 }
never executed: end of block
0
148 result[QLatin1String("index")] = scopeNr;-
149 result[QLatin1String("frameIndex")] = frameNr;-
150 result[QLatin1String("object")] = object;-
151 flushRedundantRefs();-
152}
executed 72 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
72
153-
154bool ScopeJob::wasSuccessful() const-
155{-
156 return
never executed: return success;
success;
never executed: return success;
0
157}-
158-
159ValueLookupJob::ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector) :-
160 CollectJob(collector), handles(handles) {}
never executed: end of block
0
161-
162void ValueLookupJob::run()-
163{-
164-
165-
166-
167 QScopedPointer<QObject> scopeObject;-
168 QV4::ExecutionEngine *engine = collector->engine();-
169 QV4::Scope scope(engine);-
170 QV4::Heap::ExecutionContext *qmlContext = nullptr;-
171 if (engine->qmlEngine()
engine->qmlEngine()Description
TRUEnever evaluated
FALSEnever evaluated
&& !engine->qmlContext()
!engine->qmlContext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
172 scopeObject.reset(new QObject);-
173 qmlContext = QV4::QmlContext::create(engine->currentContext(),-
174 QQmlContextData::get(engine->qmlEngine()->rootContext()),-
175 scopeObject.data());-
176 }
never executed: end of block
0
177 QV4::ScopedStackFrame frame(scope, qmlContext);-
178 for (const QJsonValue &handle : handles) {-
179 QV4DataCollector::Ref ref = handle.toInt();-
180 if (!collector->isValidRef(ref)
!collector->isValidRef(ref)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
181 exception = QString::fromLatin1("Invalid Ref: %1").arg(ref);-
182 break;
never executed: break;
0
183 }-
184 result[QString::number(ref)] = collector->lookupRef(ref, true);-
185 }
never executed: end of block
0
186 flushRedundantRefs();-
187}
never executed: end of block
0
188-
189const QString &ValueLookupJob::exceptionMessage() const-
190{-
191 return
never executed: return exception;
exception;
never executed: return exception;
0
192}-
193-
194ExpressionEvalJob::ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr,-
195 int context, const QString &expression,-
196 QV4DataCollector *collector) :-
197 JavaScriptJob(engine, frameNr, context, expression), collector(collector)-
198{-
199}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
18
200-
201void ExpressionEvalJob::handleResult(QV4::ScopedValue &value)-
202{-
203 if (hasExeption()
hasExeption()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
0-18
204 exception = value->toQStringNoThrow();
never executed: exception = value->toQStringNoThrow();
0
205 result = collector->lookupRef(collector->collect(value), true);-
206 if (collector->redundantRefs()
collector->redundantRefs()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qv4debugger
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qv4debugger
)
8-10
207 collectedRefs = collector->flushCollectedRefs();
executed 10 times by 1 test: collectedRefs = collector->flushCollectedRefs();
Executed by:
  • tst_qv4debugger
10
208}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
18
209-
210const QString &ExpressionEvalJob::exceptionMessage() const-
211{-
212 return
never executed: return exception;
exception;
never executed: return exception;
0
213}-
214-
215const QJsonObject &ExpressionEvalJob::returnValue() const-
216{-
217 return
executed 18 times by 1 test: return result;
Executed by:
  • tst_qv4debugger
result;
executed 18 times by 1 test: return result;
Executed by:
  • tst_qv4debugger
18
218}-
219-
220-
221const QJsonArray &ExpressionEvalJob::refs() const-
222{-
223 ((collector->redundantRefs()) ? static_cast<void>(0) : qt_assert("collector->redundantRefs()", __FILE__, 270));-
224 return
never executed: return collectedRefs;
collectedRefs;
never executed: return collectedRefs;
0
225}-
226-
227GatherSourcesJob::GatherSourcesJob(QV4::ExecutionEngine *engine)-
228 : engine(engine)-
229{}
never executed: end of block
0
230-
231void GatherSourcesJob::run()-
232{-
233 for (QV4::CompiledData::CompilationUnit *unit : engine->compilationUnits) {-
234 QString fileName = unit->fileName();-
235 if (!fileName.isEmpty()
!fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
236 sources.append(fileName);
never executed: sources.append(fileName);
0
237 }
never executed: end of block
0
238}
never executed: end of block
0
239-
240const QStringList &GatherSourcesJob::result() const-
241{-
242 return
never executed: return sources;
sources;
never executed: return sources;
0
243}-
244-
245EvalJob::EvalJob(QV4::ExecutionEngine *engine, const QString &script) :-
246 JavaScriptJob(engine, -1, -1, script), result(false)-
247{}
executed 32 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
32
248-
249void EvalJob::handleResult(QV4::ScopedValue &result)-
250{-
251 this->result = result->toBoolean();-
252}
executed 32 times by 1 test: end of block
Executed by:
  • tst_qv4debugger
32
253-
254bool EvalJob::resultAsBoolean() const-
255{-
256 return
executed 32 times by 1 test: return result;
Executed by:
  • tst_qv4debugger
result;
executed 32 times by 1 test: return result;
Executed by:
  • tst_qv4debugger
32
257}-
258-
259-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0