diff options
author | Aurindam Jana <aurindam.jana@nokia.com> | 2011-08-18 11:11:44 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-19 11:53:32 +0200 |
commit | 7059861a8b8d48b5187eb46a2678f306ba288320 (patch) | |
tree | 9eb103e7ceacd264125871643f65c1cb4f66277e /src | |
parent | 247b9e38849e4c3aef4c0a02ec87eca6301f2821 (diff) |
v8 debugging: delay setting of breakpoints till afterCompile
The setting of breakpoints is delayed till the complete filepath of the script is determined.
Change-Id: I8875eea3cecf5093c5d43741e26222e03123af84
Reviewed-on: http://codereview.qt.nokia.com/3169
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/debugger/qv8debugservice.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp index 0358d082d3..0020c44099 100644 --- a/src/declarative/debugger/qv8debugservice.cpp +++ b/src/declarative/debugger/qv8debugservice.cpp @@ -79,10 +79,11 @@ public: QList<QDeclarativeEngine *> engines; QEventLoop loop; QHash<QString,QString> sourcePath; + QHash<QString,QByteArray> requestCache; }; QV8DebugService::QV8DebugService(QObject *parent) - : QDeclarativeDebugService(*(new QV8DebugServicePrivate()),QLatin1String("V8Debugger"), parent) + : QDeclarativeDebugService(*(new QV8DebugServicePrivate()), QLatin1String("V8Debugger"), parent) { v8::Debug::SetMessageHandler2(DebugMessageHandler); } @@ -134,14 +135,24 @@ void QV8DebugService::appendSourcePath(QByteArray message) { QString msg(message); QJSValue parser = d->engine.evaluate("JSON.parse"); - QJSValue out = parser.call(QJSValue(),QJSValueList() << QJSValue(msg)); + QJSValue out = parser.call(QJSValue(), QJSValueList() << QJSValue(msg)); msgMap = out.toVariant().toMap(); } QString sourcePath(msgMap.value("body").toMap().value("script").toMap().value("name").toString()); QString fileName(QFileInfo(sourcePath).fileName()); - d->sourcePath.insert(fileName,sourcePath); + d->sourcePath.insert(fileName, sourcePath); + + //Check if there are any pending breakpoint requests for this file + if (d->requestCache.contains(fileName)) { + QList<QByteArray> list = d->requestCache.values(fileName); + d->requestCache.remove(fileName); + foreach (QByteArray request, list) { + request.replace(fileName.toUtf8(), sourcePath.toUtf8()); + sendDebugMessage(request); + } + } } void QV8DebugService::messageReceived(const QByteArray &message) @@ -160,7 +171,7 @@ void QV8DebugService::messageReceived(const QByteArray &message) { QString req(request); QJSValue parser = d->engine.evaluate("JSON.parse"); - QJSValue out = parser.call(QJSValue(),QJSValueList() << QJSValue(req)); + QJSValue out = parser.call(QJSValue(), QJSValueList() << QJSValue(req)); reqMap = out.toVariant().toMap(); } @@ -170,16 +181,25 @@ void QV8DebugService::messageReceived(const QByteArray &message) v8::Debug::DebugBreak(); } else { + bool ok = true; if (debugCommand == QString("setbreakpoint")){ QVariantMap arguments = reqMap.value("arguments").toMap(); QString type(arguments.value("type").toString()); if (type == QString("script")) { QString fileName(arguments.value("target").toString()); - QString filePath = d->sourcePath.value(fileName); - request.replace(fileName.toUtf8(),filePath.toUtf8()); + //Check if the filepath has been cached + if (d->sourcePath.contains(fileName)) { + QString filePath = d->sourcePath.value(fileName); + request.replace(fileName.toUtf8(), filePath.toUtf8()); + } else { + //Store the setbreakpoint message till filepath is resolved + d->requestCache.insertMulti(fileName, request); + ok = false; + } } } - sendDebugMessage(request); + if (ok) + sendDebugMessage(request); } } |