Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | QV4::CppStackFrame *QV4DataCollector::findFrame(int frame) | - | ||||||||||||
8 | { | - | ||||||||||||
9 | QV4::CppStackFrame *f = engine()->currentStackFrame; | - | ||||||||||||
10 | while (f
| 0-1544 | ||||||||||||
11 | --frame; | - | ||||||||||||
12 | f = f->parent; | - | ||||||||||||
13 | } executed 1200 times by 1 test: end of block Executed by:
| 1200 | ||||||||||||
14 | return executed 344 times by 1 test: f;return f; Executed by:
executed 344 times by 1 test: return f; Executed by:
| 344 | ||||||||||||
15 | } | - | ||||||||||||
16 | - | |||||||||||||
17 | QV4::Heap::ExecutionContext *QV4DataCollector::findContext(int frame) | - | ||||||||||||
18 | { | - | ||||||||||||
19 | QV4::CppStackFrame *f = findFrame(frame); | - | ||||||||||||
20 | - | |||||||||||||
21 | return executed 172 times by 1 test: f ? f->context()->d() : nullptr;return f ? f->context()->d() : nullptr; Executed by:
executed 172 times by 1 test: return f ? f->context()->d() : nullptr; Executed by:
| 172 | ||||||||||||
22 | } | - | ||||||||||||
23 | - | |||||||||||||
24 | QV4::Heap::ExecutionContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | for (; scope > 0
| 0-72 | ||||||||||||
27 | ctx = ctx->outer; executed 60 times by 1 test: ctx = ctx->outer; Executed by:
| 60 | ||||||||||||
28 | - | |||||||||||||
29 | return executed 72 times by 1 test: ctx;return ctx; Executed by:
executed 72 times by 1 test: return ctx; Executed by:
| 72 | ||||||||||||
30 | } | - | ||||||||||||
31 | - | |||||||||||||
32 | QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes(int frame) | - | ||||||||||||
33 | { | - | ||||||||||||
34 | QVector<QV4::Heap::ExecutionContext::ContextType> types; | - | ||||||||||||
35 | - | |||||||||||||
36 | QV4::Heap::ExecutionContext *it = findFrame(frame)->context()->d(); | - | ||||||||||||
37 | - | |||||||||||||
38 | for (; it
| 172-436 | ||||||||||||
39 | types.append(QV4::Heap::ExecutionContext::ContextType(it->type)); executed 436 times by 1 test: types.append(QV4::Heap::ExecutionContext::ContextType(it->type)); Executed by:
| 436 | ||||||||||||
40 | - | |||||||||||||
41 | return executed 172 times by 1 test: types;return types; Executed by:
executed 172 times by 1 test: return types; Executed by:
| 172 | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType) | - | ||||||||||||
45 | { | - | ||||||||||||
46 | switch (scopeType) { | - | ||||||||||||
47 | case executed 100 times by 1 test: QV4::Heap::ExecutionContext::Type_GlobalContext:case QV4::Heap::ExecutionContext::Type_GlobalContext: Executed by:
executed 100 times by 1 test: case QV4::Heap::ExecutionContext::Type_GlobalContext: Executed by:
| 100 | ||||||||||||
48 | break; executed 100 times by 1 test: break; Executed by:
| 100 | ||||||||||||
49 | case never executed: QV4::Heap::ExecutionContext::Type_WithContext:case QV4::Heap::ExecutionContext::Type_WithContext: never executed: case QV4::Heap::ExecutionContext::Type_WithContext: | 0 | ||||||||||||
50 | return never executed: 2;return 2; never executed: return 2; | 0 | ||||||||||||
51 | case executed 144 times by 1 test: QV4::Heap::ExecutionContext::Type_CallContext:case QV4::Heap::ExecutionContext::Type_CallContext: Executed by:
executed 144 times by 1 test: case QV4::Heap::ExecutionContext::Type_CallContext: Executed by:
| 144 | ||||||||||||
52 | return executed 144 times by 1 test: 1;return 1; Executed by:
executed 144 times by 1 test: return 1; Executed by:
| 144 | ||||||||||||
53 | case never executed: QV4::Heap::ExecutionContext::Type_QmlContext:case QV4::Heap::ExecutionContext::Type_QmlContext: never executed: case QV4::Heap::ExecutionContext::Type_QmlContext: | 0 | ||||||||||||
54 | return never executed: 3;return 3; never executed: return 3; | 0 | ||||||||||||
55 | case executed 60 times by 1 test: QV4::Heap::ExecutionContext::Type_BlockContext:case QV4::Heap::ExecutionContext::Type_BlockContext: Executed by:
executed 60 times by 1 test: case QV4::Heap::ExecutionContext::Type_BlockContext: Executed by:
| 60 | ||||||||||||
56 | return executed 60 times by 1 test: 4;return 4; Executed by:
executed 60 times by 1 test: return 4; Executed by:
| 60 | ||||||||||||
57 | } | - | ||||||||||||
58 | return executed 100 times by 1 test: 0;return 0; Executed by:
executed 100 times by 1 test: return 0; Executed by:
| 100 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | QV4DataCollector::QV4DataCollector(QV4::ExecutionEngine *engine) | - | ||||||||||||
62 | : m_engine(engine), m_namesAsObjects(true), m_redundantRefs(true) | - | ||||||||||||
63 | { | - | ||||||||||||
64 | m_values.set(engine, engine->newArrayObject()); | - | ||||||||||||
65 | } executed 194 times by 3 tests: end of block Executed by:
| 194 | ||||||||||||
66 | - | |||||||||||||
67 | - | |||||||||||||
68 | QV4DataCollector::Ref QV4DataCollector::collect(const QV4::ScopedValue &value) | - | ||||||||||||
69 | { | - | ||||||||||||
70 | Ref ref = addRef(value); | - | ||||||||||||
71 | if (m_redundantRefs
| 110-134 | ||||||||||||
72 | m_collectedRefs.append(ref); executed 134 times by 1 test: m_collectedRefs.append(ref); Executed by:
| 134 | ||||||||||||
73 | return executed 244 times by 1 test: ref;return ref; Executed by:
executed 244 times by 1 test: return ref; Executed by:
| 244 | ||||||||||||
74 | } | - | ||||||||||||
75 | - | |||||||||||||
76 | const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::ExecutionEngine *engine, | - | ||||||||||||
77 | QJsonObject &dict) | - | ||||||||||||
78 | { | - | ||||||||||||
79 | QV4::Scope scope(engine); | - | ||||||||||||
80 | QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(engine, value)); | - | ||||||||||||
81 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "type")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "type" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 684 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 684 times by 1 test: }()), typeString->toQStringNoThrow());return qstring_literal_temp; Executed by:
| 684 | ||||||||||||
82 | - | |||||||||||||
83 | const QLatin1String valueKey("value"); | - | ||||||||||||
84 | switch (value->type()) { | - | ||||||||||||
85 | case never executed: QV4::Value::Empty_Type:case QV4::Value::Empty_Type: never executed: case QV4::Value::Empty_Type: | 0 | ||||||||||||
86 | ((!"empty Value encountered") ? static_cast<void>(0) : qt_assert("!\"empty Value encountered\"", __FILE__, 138)); | - | ||||||||||||
87 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
88 | case executed 24 times by 1 test: QV4::Value::Undefined_Type:case QV4::Value::Undefined_Type: Executed by:
executed 24 times by 1 test: case QV4::Value::Undefined_Type: Executed by:
| 24 | ||||||||||||
89 | dict.insert(valueKey, QJsonValue::Undefined); | - | ||||||||||||
90 | return executed 24 times by 1 test: nullptr;return nullptr; Executed by:
executed 24 times by 1 test: return nullptr; Executed by:
| 24 | ||||||||||||
91 | case executed 12 times by 1 test: QV4::Value::Null_Type:case QV4::Value::Null_Type: Executed by:
executed 12 times by 1 test: case QV4::Value::Null_Type: Executed by:
| 12 | ||||||||||||
92 | dict.insert(valueKey, QJsonValue::Null); | - | ||||||||||||
93 | return executed 12 times by 1 test: nullptr;return nullptr; Executed by:
executed 12 times by 1 test: return nullptr; Executed by:
| 12 | ||||||||||||
94 | case never executed: QV4::Value::Boolean_Type:case QV4::Value::Boolean_Type: never executed: case QV4::Value::Boolean_Type: | 0 | ||||||||||||
95 | dict.insert(valueKey, value->booleanValue()); | - | ||||||||||||
96 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
97 | case executed 346 times by 1 test: QV4::Value::Managed_Type:case QV4::Value::Managed_Type: Executed by:
executed 346 times by 1 test: case QV4::Value::Managed_Type: Executed by:
| 346 | ||||||||||||
98 | if (const
| 14-332 | ||||||||||||
99 | dict.insert(valueKey, s->toQString()); | - | ||||||||||||
100 | } executed 14 times by 1 test: else if (constend of block Executed by:
| 0-332 | ||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | dict.insert(valueKey, qint64(a->getLength())); | - | ||||||||||||
104 | return never executed: a;return a; never executed: return a; | 0 | ||||||||||||
105 | } else if (const
| 0-332 | ||||||||||||
106 | int numProperties = 0; | - | ||||||||||||
107 | QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly); | - | ||||||||||||
108 | QV4::PropertyAttributes attrs; | - | ||||||||||||
109 | uint index; | - | ||||||||||||
110 | QV4::ScopedProperty p(scope); | - | ||||||||||||
111 | QV4::ScopedString name(scope); | - | ||||||||||||
112 | while (true) { | - | ||||||||||||
113 | it.next(name.getRef(), &index, p, &attrs); | - | ||||||||||||
114 | if (attrs.isEmpty()
| 332-414 | ||||||||||||
115 | break; executed 332 times by 1 test: break; Executed by:
| 332 | ||||||||||||
116 | else | - | ||||||||||||
117 | ++ executed 414 times by 1 test: numProperties;++numProperties; Executed by:
executed 414 times by 1 test: ++numProperties; Executed by:
| 414 | ||||||||||||
118 | } | - | ||||||||||||
119 | dict.insert(valueKey, numProperties); | - | ||||||||||||
120 | return executed 332 times by 1 test: o;return o; Executed by:
executed 332 times by 1 test: return o; Executed by:
| 332 | ||||||||||||
121 | } else { | - | ||||||||||||
122 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 174)); __builtin_unreachable(); } while (false); | - | ||||||||||||
123 | } never executed: end of block | 0 | ||||||||||||
124 | return executed 14 times by 1 test: nullptr;return nullptr; Executed by:
executed 14 times by 1 test: return nullptr; Executed by:
| 14 | ||||||||||||
125 | case executed 302 times by 1 test: QV4::Value::Integer_Type:case QV4::Value::Integer_Type: Executed by:
executed 302 times by 1 test: case QV4::Value::Integer_Type: Executed by:
| 302 | ||||||||||||
126 | dict.insert(valueKey, value->integerValue()); | - | ||||||||||||
127 | return executed 302 times by 1 test: nullptr;return nullptr; Executed by:
executed 302 times by 1 test: return nullptr; Executed by:
| 302 | ||||||||||||
128 | default never executed: :default: never executed: {default: | 0 | ||||||||||||
129 | const double val = value->doubleValue(); | - | ||||||||||||
130 | if (qIsFinite(val)
| 0 | ||||||||||||
131 | dict.insert(valueKey, val); never executed: dict.insert(valueKey, val); | 0 | ||||||||||||
132 | else if (qIsNaN(val)
| 0 | ||||||||||||
133 | dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "NaN")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "NaN" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; never executed: dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "NaN")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "NaN" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||
134 | else if (val < 0
| 0 | ||||||||||||
135 | dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "-Infinity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "-Infinity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; never executed: dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "-Infinity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "-Infinity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||
136 | else | - | ||||||||||||
137 | dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "Infinity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Infinity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; never executed: dict.insert(valueKey, ([]() noexcept -> QString { enum { Size = sizeof(u"" "Infinity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Infinity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||
138 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
139 | } | - | ||||||||||||
140 | } | - | ||||||||||||
141 | } | - | ||||||||||||
142 | - | |||||||||||||
143 | QJsonObject QV4DataCollector::lookupRef(Ref ref, bool deep) | - | ||||||||||||
144 | { | - | ||||||||||||
145 | QJsonObject dict; | - | ||||||||||||
146 | - | |||||||||||||
147 | if (m_namesAsObjects
| 0-426 | ||||||||||||
148 | if (lookupSpecialRef(ref, &dict)
| 116-310 | ||||||||||||
149 | return executed 116 times by 1 test: dict;return dict; Executed by:
executed 116 times by 1 test: return dict; Executed by:
| 116 | ||||||||||||
150 | } executed 310 times by 1 test: end of block Executed by:
| 310 | ||||||||||||
151 | - | |||||||||||||
152 | if (m_redundantRefs
| 44-266 | ||||||||||||
153 | deep = true; executed 266 times by 1 test: deep = true; Executed by:
| 266 | ||||||||||||
154 | - | |||||||||||||
155 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "handle")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "handle" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 310 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 310 times by 1 test: }()), qint64(ref));return qstring_literal_temp; Executed by:
| 310 | ||||||||||||
156 | QV4::Scope scope(engine()); | - | ||||||||||||
157 | QV4::ScopedValue value(scope, getValue(ref)); | - | ||||||||||||
158 | - | |||||||||||||
159 | const QV4::Object *object = collectProperty(value, engine(), dict); | - | ||||||||||||
160 | if (deep
| 0-310 | ||||||||||||
161 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "properties")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "properties" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 204 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 204 times by 1 test: }()), collectProperties(object));return qstring_literal_temp; Executed by:
executed 204 times by 1 test: dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "properties")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "properties" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), collectProperties(object)); Executed by:
| 204 | ||||||||||||
162 | - | |||||||||||||
163 | return executed 310 times by 1 test: dict;return dict; Executed by:
executed 310 times by 1 test: return dict; Executed by:
| 310 | ||||||||||||
164 | } | - | ||||||||||||
165 | - | |||||||||||||
166 | - | |||||||||||||
167 | QV4DataCollector::Ref QV4DataCollector::addFunctionRef(const QString &functionName) | - | ||||||||||||
168 | { | - | ||||||||||||
169 | ((m_namesAsObjects) ? static_cast<void>(0) : qt_assert("m_namesAsObjects", __FILE__, 221)); | - | ||||||||||||
170 | Ref ref = addRef(QV4::Primitive::emptyValue(), false); | - | ||||||||||||
171 | - | |||||||||||||
172 | QJsonObject dict; | - | ||||||||||||
173 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "handle")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "handle" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), qint64(ref));return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
174 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "type")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "type" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn qstring_literal_temp; Executed by:
executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()));return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
175 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "name")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "name" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), functionName);return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
176 | m_specialRefs.insert(ref, dict); | - | ||||||||||||
177 | m_collectedRefs.append(ref); | - | ||||||||||||
178 | - | |||||||||||||
179 | return executed 100 times by 1 test: ref;return ref; Executed by:
executed 100 times by 1 test: return ref; Executed by:
| 100 | ||||||||||||
180 | } | - | ||||||||||||
181 | - | |||||||||||||
182 | - | |||||||||||||
183 | QV4DataCollector::Ref QV4DataCollector::addScriptRef(const QString &scriptName) | - | ||||||||||||
184 | { | - | ||||||||||||
185 | ((m_namesAsObjects) ? static_cast<void>(0) : qt_assert("m_namesAsObjects", __FILE__, 237)); | - | ||||||||||||
186 | Ref ref = addRef(QV4::Primitive::emptyValue(), false); | - | ||||||||||||
187 | - | |||||||||||||
188 | QJsonObject dict; | - | ||||||||||||
189 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "handle")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "handle" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), qint64(ref));return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
190 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "type")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "type" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "script")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "script" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn qstring_literal_temp; Executed by:
executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()));return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
191 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "name")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "name" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 100 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 100 times by 1 test: }()), scriptName);return qstring_literal_temp; Executed by:
| 100 | ||||||||||||
192 | m_specialRefs.insert(ref, dict); | - | ||||||||||||
193 | m_collectedRefs.append(ref); | - | ||||||||||||
194 | - | |||||||||||||
195 | return executed 100 times by 1 test: ref;return ref; Executed by:
executed 100 times by 1 test: return ref; Executed by:
| 100 | ||||||||||||
196 | } | - | ||||||||||||
197 | - | |||||||||||||
198 | bool QV4DataCollector::isValidRef(QV4DataCollector::Ref ref) const | - | ||||||||||||
199 | { | - | ||||||||||||
200 | QV4::Scope scope(engine()); | - | ||||||||||||
201 | QV4::ScopedObject array(scope, m_values.value()); | - | ||||||||||||
202 | return never executed: ref < array->getLength();return ref < array->getLength(); never executed: return ref < array->getLength(); | 0 | ||||||||||||
203 | } | - | ||||||||||||
204 | - | |||||||||||||
205 | bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) | - | ||||||||||||
206 | { | - | ||||||||||||
207 | QV4::Scope scope(engine()); | - | ||||||||||||
208 | - | |||||||||||||
209 | QV4::Scoped<QV4::ExecutionContext> ctxt(scope, findScope(findContext(frameNr), scopeNr)); | - | ||||||||||||
210 | if (!ctxt
| 0-72 | ||||||||||||
211 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
212 | - | |||||||||||||
213 | QV4::ScopedObject scopeObject(scope, engine()->newObject()); | - | ||||||||||||
214 | if (ctxt->d()->type == QV4::Heap::ExecutionContext::Type_CallContext
| 0-72 | ||||||||||||
215 | QStringList names; | - | ||||||||||||
216 | Refs collectedRefs; | - | ||||||||||||
217 | - | |||||||||||||
218 | QV4::ScopedValue v(scope); | - | ||||||||||||
219 | QV4::Heap::InternalClass *ic = ctxt->internalClass(); | - | ||||||||||||
220 | for (uint i = 0; i < ic->size
| 72-224 | ||||||||||||
221 | QString name = ic->nameMap[i].toQString(); | - | ||||||||||||
222 | names.append(name); | - | ||||||||||||
223 | v = static_cast<QV4::Heap::CallContext *>(ctxt->d())->locals[i]; | - | ||||||||||||
224 | collectedRefs.append(collect(v)); | - | ||||||||||||
225 | } executed 224 times by 1 test: end of block Executed by:
| 224 | ||||||||||||
226 | - | |||||||||||||
227 | ((names.size() == collectedRefs.size()) ? static_cast<void>(0) : qt_assert("names.size() == collectedRefs.size()", __FILE__, 279)); | - | ||||||||||||
228 | QV4::ScopedString propName(scope); | - | ||||||||||||
229 | for (int i = 0, ei = collectedRefs.size(); i != ei
| 72-224 | ||||||||||||
230 | propName = engine()->newString(names.at(i)); | - | ||||||||||||
231 | scopeObject->put(propName, (v = getValue(collectedRefs.at(i)))); | - | ||||||||||||
232 | } executed 224 times by 1 test: end of block Executed by:
| 224 | ||||||||||||
233 | } executed 72 times by 1 test: end of block Executed by:
| 72 | ||||||||||||
234 | - | |||||||||||||
235 | Ref scopeObjectRef = addRef(scopeObject); | - | ||||||||||||
236 | if (m_redundantRefs
| 32-40 | ||||||||||||
237 | dict->insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "ref")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ref" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 40 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 40 times by 1 test: }()), qint64(scopeObjectRef));return qstring_literal_temp; Executed by:
| 40 | ||||||||||||
238 | m_collectedRefs.append(scopeObjectRef); | - | ||||||||||||
239 | } executed 40 times by 1 test: else {end of block Executed by:
| 40 | ||||||||||||
240 | *dict = lookupRef(scopeObjectRef, true); | - | ||||||||||||
241 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||
242 | - | |||||||||||||
243 | return executed 72 times by 1 test: true;return true; Executed by:
executed 72 times by 1 test: return true; Executed by:
| 72 | ||||||||||||
244 | } | - | ||||||||||||
245 | - | |||||||||||||
246 | QJsonObject toRef(QV4DataCollector::Ref ref) { | - | ||||||||||||
247 | QJsonObject dict; | - | ||||||||||||
248 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "ref")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ref" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 200 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 200 times by 1 test: }()), qint64(ref));return qstring_literal_temp; Executed by:
| 200 | ||||||||||||
249 | return executed 200 times by 1 test: dict;return dict; Executed by:
executed 200 times by 1 test: return dict; Executed by:
| 200 | ||||||||||||
250 | } | - | ||||||||||||
251 | - | |||||||||||||
252 | QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int frameNr) | - | ||||||||||||
253 | { | - | ||||||||||||
254 | QJsonObject frame; | - | ||||||||||||
255 | frame[QLatin1String("index")] = frameNr; | - | ||||||||||||
256 | frame[QLatin1String("debuggerFrame")] = false; | - | ||||||||||||
257 | if (m_namesAsObjects
| 0-100 | ||||||||||||
258 | frame[QLatin1String("func")] = toRef(addFunctionRef(stackFrame.function)); | - | ||||||||||||
259 | frame[QLatin1String("script")] = toRef(addScriptRef(stackFrame.source)); | - | ||||||||||||
260 | } executed 100 times by 1 test: else {end of block Executed by:
| 100 | ||||||||||||
261 | frame[QLatin1String("func")] = stackFrame.function; | - | ||||||||||||
262 | frame[QLatin1String("script")] = stackFrame.source; | - | ||||||||||||
263 | } never executed: end of block | 0 | ||||||||||||
264 | frame[QLatin1String("line")] = stackFrame.line - 1; | - | ||||||||||||
265 | if (stackFrame.column >= 0
| 0-100 | ||||||||||||
266 | frame[QLatin1String("column")] = stackFrame.column; never executed: frame[QLatin1String("column")] = stackFrame.column; | 0 | ||||||||||||
267 | - | |||||||||||||
268 | QJsonArray scopes; | - | ||||||||||||
269 | QV4::Scope scope(engine()); | - | ||||||||||||
270 | QV4::ScopedContext ctxt(scope, findContext(frameNr)); | - | ||||||||||||
271 | while (ctxt
| 100-232 | ||||||||||||
272 | if (QV4::CallContext *cCtxt = ctxt->asCallContext()
| 72-160 | ||||||||||||
273 | if (cCtxt->d()->activation
| 0-72 | ||||||||||||
274 | break; never executed: break; | 0 | ||||||||||||
275 | } executed 72 times by 1 test: end of block Executed by:
| 72 | ||||||||||||
276 | ctxt = ctxt->d()->outer; | - | ||||||||||||
277 | } executed 232 times by 1 test: end of block Executed by:
| 232 | ||||||||||||
278 | - | |||||||||||||
279 | if (ctxt
| 0-100 | ||||||||||||
280 | QV4::ScopedValue o(scope, ctxt->d()->activation); | - | ||||||||||||
281 | frame[QLatin1String("receiver")] = toRef(collect(o)); | - | ||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||
283 | - | |||||||||||||
284 | - | |||||||||||||
285 | QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(frameNr); | - | ||||||||||||
286 | for (int i = 0, ei = scopeTypes.count(); i != ei
| 100-232 | ||||||||||||
287 | int type = encodeScopeType(scopeTypes[i]); | - | ||||||||||||
288 | if (type == -1
| 0-232 | ||||||||||||
289 | continue; never executed: continue; | 0 | ||||||||||||
290 | - | |||||||||||||
291 | QJsonObject scope; | - | ||||||||||||
292 | scope[QLatin1String("index")] = i; | - | ||||||||||||
293 | scope[QLatin1String("type")] = type; | - | ||||||||||||
294 | scopes.push_back(scope); | - | ||||||||||||
295 | } executed 232 times by 1 test: end of block Executed by:
| 232 | ||||||||||||
296 | - | |||||||||||||
297 | frame[QLatin1String("scopes")] = scopes; | - | ||||||||||||
298 | - | |||||||||||||
299 | return executed 100 times by 1 test: frame;return frame; Executed by:
executed 100 times by 1 test: return frame; Executed by:
| 100 | ||||||||||||
300 | } | - | ||||||||||||
301 | - | |||||||||||||
302 | - | |||||||||||||
303 | QJsonArray QV4DataCollector::flushCollectedRefs() | - | ||||||||||||
304 | { | - | ||||||||||||
305 | ((m_redundantRefs) ? static_cast<void>(0) : qt_assert("m_redundantRefs", __FILE__, 357)); | - | ||||||||||||
306 | QJsonArray refs; | - | ||||||||||||
307 | std::sort(m_collectedRefs.begin(), m_collectedRefs.end()); | - | ||||||||||||
308 | for (int i = 0, ei = m_collectedRefs.size(); i != ei
| 108-330 | ||||||||||||
309 | QV4DataCollector::Ref ref = m_collectedRefs.at(i); | - | ||||||||||||
310 | if (i > 0
| 4-222 | ||||||||||||
311 | continue; executed 4 times by 1 test: continue; Executed by:
| 4 | ||||||||||||
312 | refs.append(lookupRef(ref, true)); | - | ||||||||||||
313 | } executed 326 times by 1 test: end of block Executed by:
| 326 | ||||||||||||
314 | - | |||||||||||||
315 | m_collectedRefs.clear(); | - | ||||||||||||
316 | return executed 108 times by 1 test: refs;return refs; Executed by:
executed 108 times by 1 test: return refs; Executed by:
| 108 | ||||||||||||
317 | } | - | ||||||||||||
318 | - | |||||||||||||
319 | void QV4DataCollector::clear() | - | ||||||||||||
320 | { | - | ||||||||||||
321 | m_values.set(engine(), engine()->newArrayObject()); | - | ||||||||||||
322 | m_collectedRefs.clear(); | - | ||||||||||||
323 | m_specialRefs.clear(); | - | ||||||||||||
324 | m_namesAsObjects = true; | - | ||||||||||||
325 | m_redundantRefs = true; | - | ||||||||||||
326 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||
327 | - | |||||||||||||
328 | QV4DataCollector::Ref QV4DataCollector::addRef(QV4::Value value, bool deduplicate) | - | ||||||||||||
329 | { | - | ||||||||||||
330 | class ExceptionStateSaver | - | ||||||||||||
331 | { | - | ||||||||||||
332 | quint8 *hasExceptionLoc; | - | ||||||||||||
333 | quint8 hadException; | - | ||||||||||||
334 | - | |||||||||||||
335 | public: | - | ||||||||||||
336 | ExceptionStateSaver(QV4::ExecutionEngine *engine) | - | ||||||||||||
337 | : hasExceptionLoc(&engine->hasException) | - | ||||||||||||
338 | , hadException(false) | - | ||||||||||||
339 | { std::swap(*hasExceptionLoc, hadException); } executed 644 times by 1 test: end of block Executed by:
| 644 | ||||||||||||
340 | - | |||||||||||||
341 | ~ExceptionStateSaver() | - | ||||||||||||
342 | { std::swap(*hasExceptionLoc, hadException); } executed 644 times by 1 test: end of block Executed by:
| 644 | ||||||||||||
343 | }; | - | ||||||||||||
344 | - | |||||||||||||
345 | - | |||||||||||||
346 | ExceptionStateSaver resetExceptionState(engine()); | - | ||||||||||||
347 | QV4::Scope scope(engine()); | - | ||||||||||||
348 | QV4::ScopedObject array(scope, m_values.value()); | - | ||||||||||||
349 | if (deduplicate
| 200-444 | ||||||||||||
350 | for (Ref i = 0; i < array->getLength()
| 208-4858 | ||||||||||||
351 | if (array->get(i) == value.rawValue()
| 24-4598 | ||||||||||||
352 | return executed 236 times by 1 test: i;return i; Executed by:
executed 236 times by 1 test: return i; Executed by:
| 236 | ||||||||||||
353 | } executed 4622 times by 1 test: end of block Executed by:
| 4622 | ||||||||||||
354 | } executed 208 times by 1 test: end of block Executed by:
| 208 | ||||||||||||
355 | Ref ref = array->getLength(); | - | ||||||||||||
356 | array->put(ref, value); | - | ||||||||||||
357 | ((array->getLength() - 1 == ref) ? static_cast<void>(0) : qt_assert("array->getLength() - 1 == ref", __FILE__, 409)); | - | ||||||||||||
358 | return executed 408 times by 1 test: ref;return ref; Executed by:
executed 408 times by 1 test: return ref; Executed by:
| 408 | ||||||||||||
359 | } | - | ||||||||||||
360 | - | |||||||||||||
361 | QV4::ReturnedValue QV4DataCollector::getValue(Ref ref) | - | ||||||||||||
362 | { | - | ||||||||||||
363 | QV4::Scope scope(engine()); | - | ||||||||||||
364 | QV4::ScopedObject array(scope, m_values.value()); | - | ||||||||||||
365 | ((ref < array->getLength()) ? static_cast<void>(0) : qt_assert("ref < array->getLength()", __FILE__, 417)); | - | ||||||||||||
366 | return executed 534 times by 1 test: array->get(ref, nullptr);return array->get(ref, nullptr); Executed by:
executed 534 times by 1 test: return array->get(ref, nullptr); Executed by:
| 534 | ||||||||||||
367 | } | - | ||||||||||||
368 | - | |||||||||||||
369 | - | |||||||||||||
370 | bool QV4DataCollector::lookupSpecialRef(Ref ref, QJsonObject *dict) | - | ||||||||||||
371 | { | - | ||||||||||||
372 | ((m_namesAsObjects) ? static_cast<void>(0) : qt_assert("m_namesAsObjects", __FILE__, 424)); | - | ||||||||||||
373 | SpecialRefs::const_iterator it = m_specialRefs.constFind(ref); | - | ||||||||||||
374 | if (it == m_specialRefs.cend()
| 116-310 | ||||||||||||
375 | return executed 310 times by 1 test: false;return false; Executed by:
executed 310 times by 1 test: return false; Executed by:
| 310 | ||||||||||||
376 | - | |||||||||||||
377 | *dict = it.value(); | - | ||||||||||||
378 | return executed 116 times by 1 test: true;return true; Executed by:
executed 116 times by 1 test: return true; Executed by:
| 116 | ||||||||||||
379 | } | - | ||||||||||||
380 | - | |||||||||||||
381 | QJsonArray QV4DataCollector::collectProperties(const QV4::Object *object) | - | ||||||||||||
382 | { | - | ||||||||||||
383 | QJsonArray res; | - | ||||||||||||
384 | - | |||||||||||||
385 | QV4::Scope scope(engine()); | - | ||||||||||||
386 | QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::EnumerableOnly); | - | ||||||||||||
387 | QV4::ScopedValue name(scope); | - | ||||||||||||
388 | QV4::ScopedValue value(scope); | - | ||||||||||||
389 | while (true) { | - | ||||||||||||
390 | QV4::Value v; | - | ||||||||||||
391 | name = it.nextPropertyNameAsString(&v); | - | ||||||||||||
392 | if (name->isNull()
| 204-374 | ||||||||||||
393 | break; executed 204 times by 1 test: break; Executed by:
| 204 | ||||||||||||
394 | QString key = name->toQStringNoThrow(); | - | ||||||||||||
395 | value = v; | - | ||||||||||||
396 | res.append(collectAsJson(key, value)); | - | ||||||||||||
397 | } executed 374 times by 1 test: end of block Executed by:
| 374 | ||||||||||||
398 | - | |||||||||||||
399 | return executed 204 times by 1 test: res;return res; Executed by:
executed 204 times by 1 test: return res; Executed by:
| 204 | ||||||||||||
400 | } | - | ||||||||||||
401 | - | |||||||||||||
402 | QJsonObject QV4DataCollector::collectAsJson(const QString &name, const QV4::ScopedValue &value) | - | ||||||||||||
403 | { | - | ||||||||||||
404 | QJsonObject dict; | - | ||||||||||||
405 | if (!name.isNull()
| 0-374 | ||||||||||||
406 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "name")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "name" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 374 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 374 times by 1 test: }()), name);return qstring_literal_temp; Executed by:
executed 374 times by 1 test: dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "name")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "name" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), name); Executed by:
| 374 | ||||||||||||
407 | if (value->isManaged()
| 10-236 | ||||||||||||
408 | Ref ref = addRef(value); | - | ||||||||||||
409 | dict.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "ref")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ref" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 128 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 128 times by 1 test: }()), qint64(ref));return qstring_literal_temp; Executed by:
| 128 | ||||||||||||
410 | if (m_redundantRefs
| 38-90 | ||||||||||||
411 | m_collectedRefs.append(ref); executed 90 times by 1 test: m_collectedRefs.append(ref); Executed by:
| 90 | ||||||||||||
412 | } executed 128 times by 1 test: end of block Executed by:
| 128 | ||||||||||||
413 | - | |||||||||||||
414 | collectProperty(value, engine(), dict); | - | ||||||||||||
415 | return executed 374 times by 1 test: dict;return dict; Executed by:
executed 374 times by 1 test: return dict; Executed by:
| 374 | ||||||||||||
416 | } | - | ||||||||||||
417 | - | |||||||||||||
418 | - | |||||||||||||
Switch to Source code | Preprocessed file |