diff options
author | Charles Yin <charles.yin@nokia.com> | 2011-11-14 10:35:51 +1000 |
---|---|---|
committer | Charles Yin <charles.yin@nokia.com> | 2011-11-14 10:35:51 +1000 |
commit | fc54db69809a16f613f65a2761fab55d5911b02c (patch) | |
tree | a00d9284eb13f81f5b195f8a4c6cfee03edb4f17 /src/declarative/debugger/qv8debugservice.cpp | |
parent | 35275892ca8a7046451b8e943985dd779fee4794 (diff) | |
parent | 2557ff5a940242b398dee65c3c79cec088164e32 (diff) | |
download | qtdeclarative-fc54db69809a16f613f65a2761fab55d5911b02c.tar.gz |
Merge branch 'master' into animation-refactor
Conflicts:
tools/qmlviewer/qdeclarativetester.cpp
tools/qmlviewer/qmlruntime.cpp
Change-Id: I48f0eb02df27e4b524f45927939b4c257452b0aa
Diffstat (limited to 'src/declarative/debugger/qv8debugservice.cpp')
-rw-r--r-- | src/declarative/debugger/qv8debugservice.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp index 49091529a0..2f7ca348fd 100644 --- a/src/declarative/debugger/qv8debugservice.cpp +++ b/src/declarative/debugger/qv8debugservice.cpp @@ -124,6 +124,13 @@ QV8DebugService::QV8DebugService(QObject *parent) { Q_D(QV8DebugService); v8::Debug::SetMessageHandler2(DebugMessageHandler); + + // This call forces the debugger context to be loaded and made resident. + // Without this the debugger is loaded/unloaded whenever required, which + // has a very significant effect on the timing reported in the QML + // profiler in Qt Creator. + v8::Debug::GetDebugContext(); + if (status() == Enabled) { // ,block mode, client attached while (!d->initialized) { @@ -258,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; @@ -363,7 +426,10 @@ void QV8DebugService::messageReceived(const QByteArray &message) d->handlersList.remove(bp); forwardRequestToV8 = false; } + } else if (debugCommand == QLatin1String("disconnect")) { + v8::Debug::CancelDebugBreak(); } + if (forwardRequestToV8) d->sendDebugMessage(request); } |