Debugger: Use Qt's JSON encoder for debugger protocol

The V4 debug service expects correct JSON as input and gdb, lldb, and
pdb expect Python object literals. There is a subset of JSON that is
also valid as Python object literals and we use that for the protocol
spoken with gdb, lldb, and pdb. The strings passed to CDB are tunneled
through JSON strings and converted to byte arrays before sending them.

Change-Id: I87319b5450e5c3c3b29c565b75cddaa612767611
Task-number: QTCREATORBUG-14931
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-09-14 13:40:35 +02:00
parent 7d3bb6fdee
commit d5707e0e32
8 changed files with 99 additions and 119 deletions

View File

@@ -1733,14 +1733,15 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const
void QmlEnginePrivate::runCommand(const DebuggerCommand &command, const QmlCallback &cb)
{
QByteArray msg = "{\"seq\":" + QByteArray::number(++sequence) + ","
+ "\"type\":\"request\","
+ "\"command\":\"" + command.function + "\","
+ "\"arguments\":{" + command.arguments() + "}}";
QJsonObject object;
object.insert(QStringLiteral("seq"), ++sequence);
object.insert(QStringLiteral("type"), QStringLiteral("request"));
object.insert(QStringLiteral("command"), QLatin1String(command.function));
object.insert(QStringLiteral("arguments"), command.args);
if (cb)
callbackForToken[sequence] = cb;
runDirectCommand(V8REQUEST, msg);
runDirectCommand(V8REQUEST, QJsonDocument(object).toJson(QJsonDocument::Compact));
}
void QmlEnginePrivate::runDirectCommand(const QByteArray &type, const QByteArray &msg)