Some V8 debuging messages

This commit is contained in:
ksuprynowicz 2022-12-18 10:35:26 +01:00
parent da458ccef9
commit cc20ced1ca
4 changed files with 24 additions and 3 deletions

View file

@ -1410,3 +1410,12 @@ void ScriptEngineV8::compileTest() {
Q_ASSERT(false);
}
}
/*QStringList ScriptEngineV8::getCurrentStackTrace() {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(_v8Isolate, 100);
QStringList backtrace;
for (int n = 0; n < stackTrace->GetFrameCount(); n++) {
v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(_v8Isolate, n);
}
}*/

View file

@ -180,6 +180,8 @@ public: // not for public use, but I don't like how Qt strings this along with p
v8::EscapableHandleScope handleScope(_v8Isolate);
return handleScope.Escape(_v8Context.Get(_v8Isolate));
}
// Useful for debugging
//QStringList getCurrentStackTrace();
using ObjectWrapperMap = QMap<QObject*, QWeakPointer<ScriptObjectV8Proxy>>;
mutable QMutex _qobjectWrapperMapProtect;

View file

@ -375,6 +375,9 @@ bool ScriptEngineV8::castValueToVariant(const V8ScriptValue& v8Val, QVariant& de
}
}
// V8TODO
errorMessage = QString() + "Conversion failure: " + QString(*v8::String::Utf8Value(_v8Isolate, val->ToDetailString(getConstContext()).ToLocalChecked()))
+ "to variant. Destination type: " + QMetaType::typeName(destTypeId);
qDebug() << errorMessage;
Q_ASSERT(false);
//dest = val->ToVariant();
break;

View file

@ -206,7 +206,7 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue
return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result)));
}
}
qCritical() << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate)));
qDebug() << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate)));
return _engine->undefinedValue();
/*v8::Local<v8::Value> nullValue = v8::Null(_engine->getIsolate());
V8ScriptValue nullScriptValue(_engine->getIsolate(), std::move(nullValue));
@ -241,7 +241,14 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v
qDebug(scriptengine) << "Failed to set property";
}
} else {
qDebug(scriptengine) << "Failed to set property - parent is not an object";
v8::Local<v8::String> details;
QString detailsString("");
if(_value.get()->ToDetailString(_engine->getContext()).ToLocal(&details)) {
v8::String::Utf8Value utf8Value(isolate,details);
detailsString = *utf8Value;
}
qDebug(scriptengine) << "Failed to set property:" + name + " - parent is not an object. Parent details: " + " Type: " + QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate)));
qDebug(scriptengine) << _engine->currentContext()->backtrace();
}
//V8TODO: what about flags?
//_value.setProperty(name, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags);
@ -260,7 +267,7 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va
qDebug(scriptengine) << "Failed to set property";
}
} else {
qDebug(scriptengine) << "Failed to set property - parent is not an object";
qDebug(scriptengine) << "Failed to set property: " + QString(arrayIndex) + " - parent is not an object";
}
//V8TODO: what about flags?
//_value.setProperty(arrayIndex, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags);