Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | QV4DebugJob::~QV4DebugJob() | - | ||||||||||||||||||
7 | { | - | ||||||||||||||||||
8 | } | - | ||||||||||||||||||
9 | - | |||||||||||||||||||
10 | JavaScriptJob::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:
| 50 | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | void 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
| 0-62 | ||||||||||||||||||
27 | frame = frame->parent; executed 12 times by 1 test: frame = frame->parent; Executed by:
| 12 | ||||||||||||||||||
28 | if (frameNr > 0
| 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:
| 12 | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | if (context >= 0
| 8-42 | ||||||||||||||||||
32 | QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context)); | - | ||||||||||||||||||
33 | if (extraContext
| 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: else if (frameNr < 0end of block Executed by:
| 8-32 | ||||||||||||||||||
36 | QQmlEngine *qmlEngine = engine->qmlEngine(); | - | ||||||||||||||||||
37 | if (qmlEngine
| 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()
| 0-2 | ||||||||||||||||||
45 | QObject *object = ctxtPriv->instances.at(ii); | - | ||||||||||||||||||
46 | if (QQmlContext *context = qmlContext(object)
| 0 | ||||||||||||||||||
47 | if (QQmlContextData *cdata = QQmlContextData::get(context)
| 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()
| 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:
| 2 | ||||||||||||||||||
57 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, this->script); | - | ||||||||||||||||||
60 | if (const
| 0-50 | ||||||||||||||||||
61 | script.strictMode = function->isStrict(); executed 50 times by 1 test: script.strictMode = function->isStrict(); Executed by:
| 50 | ||||||||||||||||||
62 | - | |||||||||||||||||||
63 | - | |||||||||||||||||||
64 | - | |||||||||||||||||||
65 | script.inheritContext = true; | - | ||||||||||||||||||
66 | script.parse(); | - | ||||||||||||||||||
67 | QV4::ScopedValue result(scope); | - | ||||||||||||||||||
68 | if (!scope.engine->hasException
| 0-50 | ||||||||||||||||||
69 | if (frame
| 0-50 | ||||||||||||||||||
70 | QV4::ScopedValue thisObject(scope, frame->thisObject()); | - | ||||||||||||||||||
71 | result = script.run(thisObject); | - | ||||||||||||||||||
72 | } executed 50 times by 1 test: else {end of block Executed by:
| 50 | ||||||||||||||||||
73 | result = script.run(); | - | ||||||||||||||||||
74 | } never executed: end of block | 0 | ||||||||||||||||||
75 | } | - | ||||||||||||||||||
76 | if (scope.engine->hasException
| 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:
| 50 | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | bool JavaScriptJob::hasExeption() const | - | ||||||||||||||||||
84 | { | - | ||||||||||||||||||
85 | return executed 18 times by 1 test: resultIsException;return resultIsException; Executed by:
executed 18 times by 1 test: return resultIsException; Executed by:
| 18 | ||||||||||||||||||
86 | } | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | BacktraceJob::BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame) : | - | ||||||||||||||||||
89 | CollectJob(collector), fromFrame(fromFrame), toFrame(toFrame) | - | ||||||||||||||||||
90 | { | - | ||||||||||||||||||
91 | } never executed: end of block | 0 | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | void BacktraceJob::run() | - | ||||||||||||||||||
94 | { | - | ||||||||||||||||||
95 | QJsonArray frameArray; | - | ||||||||||||||||||
96 | QVector<QV4::StackFrame> frames = collector->engine()->stackTrace(toFrame); | - | ||||||||||||||||||
97 | for (int i = fromFrame; i < toFrame
| 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()
| 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: qstring_literal_temp;return qstring_literal_temp; never executed: }()), 0);return qstring_literal_temp; | 0 | ||||||||||||||||||
101 | } never executed: else {end of block | 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: qstring_literal_temp;return qstring_literal_temp; never executed: }()), fromFrame);return qstring_literal_temp; | 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: qstring_literal_temp;return qstring_literal_temp; never executed: }()), fromFrame + frameArray.size());return qstring_literal_temp; | 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: qstring_literal_temp;return qstring_literal_temp; never executed: }()), frameArray);return qstring_literal_temp; | 0 | ||||||||||||||||||
105 | } never executed: end of block | 0 | ||||||||||||||||||
106 | flushRedundantRefs(); | - | ||||||||||||||||||
107 | } never executed: end of block | 0 | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | FrameJob::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:
| 100 | ||||||||||||||||||
113 | - | |||||||||||||||||||
114 | void FrameJob::run() | - | ||||||||||||||||||
115 | { | - | ||||||||||||||||||
116 | QVector<QV4::StackFrame> frames = collector->engine()->stackTrace(frameNr + 1); | - | ||||||||||||||||||
117 | if (frameNr >= frames.length()
| 0-100 | ||||||||||||||||||
118 | success = false; | - | ||||||||||||||||||
119 | } never executed: else {end of block | 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:
| 100 | ||||||||||||||||||
124 | } | - | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | bool FrameJob::wasSuccessful() const | - | ||||||||||||||||||
127 | { | - | ||||||||||||||||||
128 | return never executed: success;return success; never executed: return success; | 0 | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | ScopeJob::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:
| 72 | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | void ScopeJob::run() | - | ||||||||||||||||||
137 | { | - | ||||||||||||||||||
138 | QJsonObject object; | - | ||||||||||||||||||
139 | success = collector->collectScope(&object, frameNr, scopeNr); | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | if (success
| 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: else {end of block Executed by:
| 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:
| 72 | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | bool ScopeJob::wasSuccessful() const | - | ||||||||||||||||||
155 | { | - | ||||||||||||||||||
156 | return never executed: success;return success; never executed: return success; | 0 | ||||||||||||||||||
157 | } | - | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | ValueLookupJob::ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector) : | - | ||||||||||||||||||
160 | CollectJob(collector), handles(handles) {} never executed: end of block | 0 | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | void 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()
| 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)
| 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 | - | |||||||||||||||||||
189 | const QString &ValueLookupJob::exceptionMessage() const | - | ||||||||||||||||||
190 | { | - | ||||||||||||||||||
191 | return never executed: exception;return exception; never executed: return exception; | 0 | ||||||||||||||||||
192 | } | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | ExpressionEvalJob::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:
| 18 | ||||||||||||||||||
200 | - | |||||||||||||||||||
201 | void ExpressionEvalJob::handleResult(QV4::ScopedValue &value) | - | ||||||||||||||||||
202 | { | - | ||||||||||||||||||
203 | if (hasExeption()
| 0-18 | ||||||||||||||||||
204 | exception = value->toQStringNoThrow(); never executed: exception = value->toQStringNoThrow(); | 0 | ||||||||||||||||||
205 | result = collector->lookupRef(collector->collect(value), true); | - | ||||||||||||||||||
206 | if (collector->redundantRefs()
| 8-10 | ||||||||||||||||||
207 | collectedRefs = collector->flushCollectedRefs(); executed 10 times by 1 test: collectedRefs = collector->flushCollectedRefs(); Executed by:
| 10 | ||||||||||||||||||
208 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | const QString &ExpressionEvalJob::exceptionMessage() const | - | ||||||||||||||||||
211 | { | - | ||||||||||||||||||
212 | return never executed: exception;return exception; never executed: return exception; | 0 | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | const QJsonObject &ExpressionEvalJob::returnValue() const | - | ||||||||||||||||||
216 | { | - | ||||||||||||||||||
217 | return executed 18 times by 1 test: result;return result; Executed by:
executed 18 times by 1 test: return result; Executed by:
| 18 | ||||||||||||||||||
218 | } | - | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | - | |||||||||||||||||||
221 | const QJsonArray &ExpressionEvalJob::refs() const | - | ||||||||||||||||||
222 | { | - | ||||||||||||||||||
223 | ((collector->redundantRefs()) ? static_cast<void>(0) : qt_assert("collector->redundantRefs()", __FILE__, 270)); | - | ||||||||||||||||||
224 | return never executed: collectedRefs;return collectedRefs; never executed: return collectedRefs; | 0 | ||||||||||||||||||
225 | } | - | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | GatherSourcesJob::GatherSourcesJob(QV4::ExecutionEngine *engine) | - | ||||||||||||||||||
228 | : engine(engine) | - | ||||||||||||||||||
229 | {} never executed: end of block | 0 | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | void GatherSourcesJob::run() | - | ||||||||||||||||||
232 | { | - | ||||||||||||||||||
233 | for (QV4::CompiledData::CompilationUnit *unit : engine->compilationUnits) { | - | ||||||||||||||||||
234 | QString fileName = unit->fileName(); | - | ||||||||||||||||||
235 | if (!fileName.isEmpty()
| 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 | - | |||||||||||||||||||
240 | const QStringList &GatherSourcesJob::result() const | - | ||||||||||||||||||
241 | { | - | ||||||||||||||||||
242 | return never executed: sources;return sources; never executed: return sources; | 0 | ||||||||||||||||||
243 | } | - | ||||||||||||||||||
244 | - | |||||||||||||||||||
245 | EvalJob::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:
| 32 | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | void EvalJob::handleResult(QV4::ScopedValue &result) | - | ||||||||||||||||||
250 | { | - | ||||||||||||||||||
251 | this->result = result->toBoolean(); | - | ||||||||||||||||||
252 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | bool EvalJob::resultAsBoolean() const | - | ||||||||||||||||||
255 | { | - | ||||||||||||||||||
256 | return executed 32 times by 1 test: result;return result; Executed by:
executed 32 times by 1 test: return result; Executed by:
| 32 | ||||||||||||||||||
257 | } | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |