From: Aurindam Jana Date: Thu, 15 Dec 2011 09:54:45 +0000 (+0100) Subject: QV8DebugService: add version command X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b6291c914d9a6f24dbfb0e92e8caedae889b709b;p=konrad%2Fqtdeclarative.git QV8DebugService: add version command Version command to retrieve debugger version info. Change-Id: I711e2a3d639c648cef50498fe5bbb9b6b8c6c1fe Reviewed-by: Kai Koehne --- diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp index 2fd54dc..933c37a 100644 --- a/src/declarative/debugger/qv8debugservice.cpp +++ b/src/declarative/debugger/qv8debugservice.cpp @@ -48,6 +48,20 @@ #include #include +//V8 DEBUG SERVICE PROTOCOL +//
+//
: "V8DEBUG" +// : ["connect", "disconnect", "interrupt", "version", +// "v8request", "v8message", "breakonsignal", +// "breakaftercompile"] +// : connect, disconnect, interrupt: empty +// version: +// v8request, v8message: +// breakonsignal: +// breakaftercompile: + +const char *V8_DEBUGGER_KEY_VERSION_NUMBER = "1.1"; +const char *V8_DEBUGGER_KEY_VERSION = "version"; const char *V8_DEBUGGER_KEY_CONNECT = "connect"; const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt"; const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect"; @@ -147,15 +161,6 @@ void QV8DebugService::setEngine(const QV8Engine *engine) d->engine = engine; } -//V8 DEBUG SERVICE PROTOCOL -//
-//
: "V8DEBUG" -// : ("connect", "disconnect", "interrupt", "v8request", "v8message", -// "breakonsignal", "breakaftercompile") -// : For _v8request_ and _v8message_ it is the JSON request string. -// For _breakonsignal_ it is -// For _breakaftercompile_ it is -// Empty string for the other types void QV8DebugService::debugMessageHandler(const QString &message, const v8::DebugEvent &event) { Q_D(QV8DebugService); @@ -164,7 +169,6 @@ void QV8DebugService::debugMessageHandler(const QString &message, const v8::Debu scheduledDebugBreak(true); } - void QV8DebugService::signalEmitted(const QString &signal) { //This function is only called by QDeclarativeBoundSignal @@ -213,49 +217,39 @@ void QV8DebugService::statusChanged(QDeclarativeDebugService::Status newStatus) } } - -//V8 DEBUG SERVICE PROTOCOL -//
-//
: "V8DEBUG" -// : ("connect", "disconnect", "interrupt", "v8request", "v8message", -// "breakonsignal", "breakaftercompile") -// : For _v8request_ and _v8message_ it is the JSON request string. -// For _breakonsignal_ it is -// For _breakaftercompile_ it is -// Empty string for the other types // executed in the debugger thread void QV8DebugService::messageReceived(const QByteArray &message) { Q_D(QV8DebugService); QDataStream ds(message); - QByteArray command; - ds >> command; + QByteArray header; + ds >> header; - if (command == "V8DEBUG") { - QByteArray type; + if (header == "V8DEBUG") { + QByteArray command; QByteArray data; - ds >> type >> data; + ds >> command >> data; - if (type == V8_DEBUGGER_KEY_CONNECT) { + if (command == V8_DEBUGGER_KEY_CONNECT) { QMutexLocker locker(&d->initializeMutex); d->connectReceived = true; sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT))); - } else if (type == V8_DEBUGGER_KEY_INTERRUPT) { + } else if (command == V8_DEBUGGER_KEY_INTERRUPT) { // break has to be executed in gui thread QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true)); sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT))); - } else if (type == V8_DEBUGGER_KEY_DISCONNECT) { + } else if (command == V8_DEBUGGER_KEY_DISCONNECT) { // cancel break has to be executed in gui thread QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false)); sendDebugMessage(QString::fromUtf8(data)); - } else if (type == V8_DEBUGGER_KEY_REQUEST) { + } else if (command == V8_DEBUGGER_KEY_REQUEST) { sendDebugMessage(QString::fromUtf8(data)); - } else if (type == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) { + } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) { QDataStream rs(data); QByteArray signal; bool enabled; @@ -268,10 +262,17 @@ void QV8DebugService::messageReceived(const QByteArray &message) d->breakOnSignals.removeOne(signalName); sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL))); - } else if (type == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) { + } else if (command == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) { QDataStream rs(data); rs >> d->breakAfterCompile; sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE))); + + } else if (command == V8_DEBUGGER_KEY_VERSION) { + //We dont check the client version + //just send the debugger version + sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_VERSION), + QLatin1String(V8_DEBUGGER_KEY_VERSION_NUMBER))); + } } } diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index 0f9da03..f2c0282 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -174,6 +174,7 @@ private slots: void connect(); void interrupt(); void breakAfterCompile(); + void getDebuggerVersion(); void getVersion(); void getVersionWhenAttaching(); @@ -270,6 +271,7 @@ public: void connect(); void interrupt(); void breakAfterCompile(bool enabled); + void debuggerVersion(); void continueDebugging(StepAction stepAction, int stepCount = 1); void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); @@ -301,6 +303,7 @@ signals: void connected(); void interruptRequested(); void breakAfterCompileRequested(); + void gotVersion(); void result(); void stopped(); @@ -339,6 +342,11 @@ void QJSDebugClient::breakAfterCompile(bool enabled) sendMessage(packMessage(BREAKAFTERCOMPILE, request)); } +void QJSDebugClient::debuggerVersion() +{ + sendMessage(packMessage(VERSION)); +} + void QJSDebugClient::continueDebugging(StepAction action, int count) { // { "seq" : , @@ -951,6 +959,8 @@ void QJSDebugClient::messageReceived(const QByteArray &data) } else if (type == BREAKAFTERCOMPILE) { emit breakAfterCompileRequested(); + } else if (type == VERSION) { + emit gotVersion(); } } } @@ -1079,6 +1089,17 @@ void tst_QDeclarativeDebugJS::breakAfterCompile() QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); } +void tst_QDeclarativeDebugJS::getDebuggerVersion() +{ + QVERIFY(init()); + client->debuggerVersion(); + + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(gotVersion()))); + + QString version(client->response); + QCOMPARE(version, QLatin1String("1.1")); +} + void tst_QDeclarativeDebugJS::getVersion() { //void version()