Commit 70f3f5d0 authored by Olivier Goffart's avatar Olivier Goffart
Browse files

QML JS Debugger: Asynchronous call to watchHandler()->endCycle()

All the expended item need to be retreived before we can call endCycle
parent 3114c47c
...@@ -176,7 +176,7 @@ public: ...@@ -176,7 +176,7 @@ public:
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters) QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters) : DebuggerEngine(startParameters), m_ping(0)
{ {
/* /*
m_conn = 0; m_conn = 0;
...@@ -339,7 +339,6 @@ void QmlEngine::setupConnection() ...@@ -339,7 +339,6 @@ void QmlEngine::setupConnection()
void QmlEngine::continueInferior() void QmlEngine::continueInferior()
{ {
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
SDEBUG("QmlEngine::continueInferior()");
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("CONTINUE"); rs << QByteArray("CONTINUE");
...@@ -359,7 +358,6 @@ void QmlEngine::interruptInferior() ...@@ -359,7 +358,6 @@ void QmlEngine::interruptInferior()
void QmlEngine::executeStep() void QmlEngine::executeStep()
{ {
SDEBUG("QmlEngine::executeStep()");
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPINTO"); rs << QByteArray("STEPINTO");
...@@ -370,7 +368,6 @@ void QmlEngine::executeStep() ...@@ -370,7 +368,6 @@ void QmlEngine::executeStep()
void QmlEngine::executeStepI() void QmlEngine::executeStepI()
{ {
SDEBUG("QmlEngine::executeStepI()");
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPINTO"); rs << QByteArray("STEPINTO");
...@@ -381,7 +378,6 @@ void QmlEngine::executeStepI() ...@@ -381,7 +378,6 @@ void QmlEngine::executeStepI()
void QmlEngine::executeStepOut() void QmlEngine::executeStepOut()
{ {
SDEBUG("QmlEngine::executeStepOut()");
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("STEPOUT"); rs << QByteArray("STEPOUT");
...@@ -398,7 +394,6 @@ void QmlEngine::executeNext() ...@@ -398,7 +394,6 @@ void QmlEngine::executeNext()
sendMessage(reply); sendMessage(reply);
notifyInferiorRunRequested(); notifyInferiorRunRequested();
notifyInferiorRunOk(); notifyInferiorRunOk();
SDEBUG("QmlEngine::nextExec()");
} }
void QmlEngine::executeNextI() void QmlEngine::executeNextI()
...@@ -571,6 +566,17 @@ void QmlEngine::expandObject(const QByteArray& iname, quint64 objectId) ...@@ -571,6 +566,17 @@ void QmlEngine::expandObject(const QByteArray& iname, quint64 objectId)
sendMessage(reply); sendMessage(reply);
} }
void QmlEngine::sendPing()
{
m_ping++;
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("PING");
rs << m_ping;
sendMessage(reply);
}
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp) DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
{ {
...@@ -622,24 +628,32 @@ void QmlEngine::messageReceived(const QByteArray &message) ...@@ -622,24 +628,32 @@ void QmlEngine::messageReceived(const QByteArray &message)
stackHandler()->setFrames(stackFrames); stackHandler()->setFrames(stackFrames);
watchHandler()->beginCycle(); watchHandler()->beginCycle();
bool needPing = false;
foreach (WatchData data, watches) { foreach (WatchData data, watches) {
data.iname = watchHandler()->watcherName(data.exp); data.iname = watchHandler()->watcherName(data.exp);
watchHandler()->insertData(data); watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname)) if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId); expandObject(data.iname, data.objectId);
}
} }
foreach (WatchData data, locals) { foreach (WatchData data, locals) {
data.iname = "local." + data.exp; data.iname = "local." + data.exp;
watchHandler()->insertData(data); watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname)) if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId); expandObject(data.iname, data.objectId);
}
} }
watchHandler()->endCycle(); if (needPing)
sendPing();
else
watchHandler()->endCycle();
} else if (command == "RESULT") { } else if (command == "RESULT") {
WatchData data; WatchData data;
...@@ -652,25 +666,42 @@ void QmlEngine::messageReceived(const QByteArray &message) ...@@ -652,25 +666,42 @@ void QmlEngine::messageReceived(const QByteArray &message)
QList<WatchData> result; QList<WatchData> result;
QByteArray iname; QByteArray iname;
stream >> iname >> result; stream >> iname >> result;
bool needPing = false;
foreach (WatchData data, result) { foreach (WatchData data, result) {
data.iname = iname + '.' + data.exp; data.iname = iname + '.' + data.exp;
watchHandler()->insertData(data); watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname)) if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId); expandObject(data.iname, data.objectId);
}
} }
if (needPing)
sendPing();
} else if (command == "LOCALS") { } else if (command == "LOCALS") {
QList<WatchData> locals; QList<WatchData> locals;
int frameId; int frameId;
stream >> frameId >> locals; stream >> frameId >> locals;
watchHandler()->beginCycle(); watchHandler()->beginCycle();
bool needPing = false;
foreach (WatchData data, locals) { foreach (WatchData data, locals) {
data.iname = "local." + data.exp; data.iname = "local." + data.exp;
watchHandler()->insertData(data); watchHandler()->insertData(data);
if (watchHandler()->expandedINames().contains(data.iname)) if (watchHandler()->expandedINames().contains(data.iname)) {
needPing = true;
expandObject(data.iname, data.objectId); expandObject(data.iname, data.objectId);
}
} }
watchHandler()->endCycle(); if (needPing)
sendPing();
else
watchHandler()->endCycle();
} else if (command == "PONG") {
int ping;
stream >> ping;
if (ping == m_ping)
watchHandler()->endCycle();
} else { } else {
qDebug() << Q_FUNC_INFO << "Unknown command: " << command; qDebug() << Q_FUNC_INFO << "Unknown command: " << command;
} }
......
...@@ -70,6 +70,7 @@ class DEBUGGER_EXPORT QmlEngine : public DebuggerEngine ...@@ -70,6 +70,7 @@ class DEBUGGER_EXPORT QmlEngine : public DebuggerEngine
{ {
Q_OBJECT Q_OBJECT
int m_ping;
public: public:
explicit QmlEngine(const DebuggerStartParameters &startParameters); explicit QmlEngine(const DebuggerStartParameters &startParameters);
~QmlEngine(); ~QmlEngine();
...@@ -117,7 +118,6 @@ private: ...@@ -117,7 +118,6 @@ private:
void reloadFullStack() {} void reloadFullStack() {}
bool supportsThreads() const { return true; } bool supportsThreads() const { return true; }
void maybeBreakNow(bool byFunction);
void updateWatchData(const WatchData &data); void updateWatchData(const WatchData &data);
unsigned int debuggerCapabilities() const; unsigned int debuggerCapabilities() const;
...@@ -128,6 +128,7 @@ signals: ...@@ -128,6 +128,7 @@ signals:
private: private:
void expandObject(const QByteArray &iname, quint64 objectId); void expandObject(const QByteArray &iname, quint64 objectId);
void sendPing();
#if 0 #if 0
void createDockWidgets(); void createDockWidgets();
......
...@@ -408,6 +408,13 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message) ...@@ -408,6 +408,13 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
} }
state = oldState; state = oldState;
//TODO: feedback //TODO: feedback
} else if (command == "PING") {
int ping;
ds >> ping;
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("PONG") << ping;
sendMessage(reply);
} else { } else {
qDebug() << Q_FUNC_INFO << "Unknown command" << command; qDebug() << Q_FUNC_INFO << "Unknown command" << command;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment