aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2011-11-04 14:04:56 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-07 10:44:47 +0100
commit1ce5760f1f710f1d82d888250ea9683cbc63c5f4 (patch)
tree3ff349e94f1b2634bc7d5e6cdd65579f5f3dbbb9 /src
parentcd483db1be2ef7cd5c768fa37c7f8333b04e84b1 (diff)
QV8DebugService: Return JSON messages for internal requests.
Internal requests are not handles by V8. Hence, create a JSON message similar to v8 debugging protocol and send it to client. This is only for uniformity wrt to debug requests. Change-Id: Ia0a3cda0ef157b852fb4402fde62b4651a95bd56 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/debugger/qv8debugservice.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp
index e4d6960b22..2f7ca348fd 100644
--- a/src/declarative/debugger/qv8debugservice.cpp
+++ b/src/declarative/debugger/qv8debugservice.cpp
@@ -265,9 +265,65 @@ void QV8DebugService::messageReceived(const QByteArray &message)
if (debugCommand == QLatin1String("connect")) {
d->initialized = true;
+ //Prepare the response string
+ //Create a json message using v8 debugging protocol
+ //and send it to client
+
+ // { "type" : "response",
+ // "request_seq" : <number>,
+ // "command" : "connect",
+ // "running" : <is the VM running after sending this response>
+ // "success" : true
+ // }
+ {
+ v8::Isolate::Scope i_scope(d->isolate);
+ const QString obj(QLatin1String("{}"));
+ QJSValue parser = d->engine->evaluate(QLatin1String("JSON.parse"));
+ QJSValue jsonVal = parser.call(QJSValue(), QJSValueList() << obj);
+ jsonVal.setProperty(QLatin1String("type"), QJSValue(QLatin1String("response")));
+
+ const int sequence = reqMap.value(QLatin1String("seq")).toInt();
+ jsonVal.setProperty(QLatin1String("request_seq"), QJSValue(sequence));
+ jsonVal.setProperty(QLatin1String("command"), QJSValue(debugCommand));
+ jsonVal.setProperty(QLatin1String("success"), QJSValue(true));
+ jsonVal.setProperty(QLatin1String("running"), QJSValue(!d->loop.isRunning()));
+
+ QJSValue stringify = d->engine->evaluate(QLatin1String("JSON.stringify"));
+ QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
+ debugMessageHandler(json.toString());
+
+ }
} else if (debugCommand == QLatin1String("interrupt")) {
v8::Debug::DebugBreak();
+ //Prepare the response string
+ //Create a json message using v8 debugging protocol
+ //and send it to client
+
+ // { "type" : "response",
+ // "request_seq" : <number>,
+ // "command" : "connect",
+ // "running" : <is the VM running after sending this response>
+ // "success" : true
+ // }
+ {
+ v8::Isolate::Scope i_scope(d->isolate);
+ const QString obj(QLatin1String("{}"));
+ QJSValue parser = d->engine->evaluate(QLatin1String("JSON.parse"));
+ QJSValue jsonVal = parser.call(QJSValue(), QJSValueList() << obj);
+ jsonVal.setProperty(QLatin1String("type"), QJSValue(QLatin1String("response")));
+
+ const int sequence = reqMap.value(QLatin1String("seq")).toInt();
+ jsonVal.setProperty(QLatin1String("request_seq"), QJSValue(sequence));
+ jsonVal.setProperty(QLatin1String("command"), QJSValue(debugCommand));
+ jsonVal.setProperty(QLatin1String("success"), QJSValue(true));
+ jsonVal.setProperty(QLatin1String("running"), QJSValue(!d->loop.isRunning()));
+
+ QJSValue stringify = d->engine->evaluate(QLatin1String("JSON.stringify"));
+ QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
+ debugMessageHandler(json.toString());
+
+ }
} else {
bool forwardRequestToV8 = true;