Commit 2e256e52 authored by hjk's avatar hjk

Debugger: Remove remaining direct uses of QmlEngine::sendMessage

Ready to introduce callbacks.

Change-Id: If26566ed71ce1283f9f42b62e75a1c793a21ef32
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 65c867db
...@@ -130,9 +130,6 @@ public: ...@@ -130,9 +130,6 @@ public:
void messageReceived(const QByteArray &data); void messageReceived(const QByteArray &data);
void stateChanged(State state); void stateChanged(State state);
void connect();
void disconnect();
void continueDebugging(StepAction stepAction); void continueDebugging(StepAction stepAction);
void evaluate(const QString expr, bool global = false, bool disableBreak = false, void evaluate(const QString expr, bool global = false, bool disableBreak = false,
...@@ -152,8 +149,6 @@ public: ...@@ -152,8 +149,6 @@ public:
void clearCache(); void clearCache();
QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
void expandObject(const QByteArray &iname, quint64 objectId); void expandObject(const QByteArray &iname, quint64 objectId);
void flushSendBuffer(); void flushSendBuffer();
...@@ -166,7 +161,9 @@ public: ...@@ -166,7 +161,9 @@ public:
bool canEvaluateScript(const QString &script); bool canEvaluateScript(const QString &script);
void updateScriptSource(const QString &fileName, int lineOffset, int columnOffset, const QString &source); void updateScriptSource(const QString &fileName, int lineOffset, int columnOffset, const QString &source);
void runCommand(const DebuggerCommand &command); void runCommand(const DebuggerCommand &command);
void runDirectCommand(const QByteArray &type, const QByteArray &msg = QByteArray());
public: public:
int sequence = -1; int sequence = -1;
...@@ -604,7 +601,11 @@ void QmlEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel, ...@@ -604,7 +601,11 @@ void QmlEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel,
void QmlEngine::shutdownInferior() void QmlEngine::shutdownInferior()
{ {
// End session. // End session.
d->disconnect(); // { "seq" : <number>,
// "type" : "request",
// "command" : "disconnect",
// }
d->runCommand(DISCONNECT);
if (isSlaveEngine()) if (isSlaveEngine())
resetLocation(); resetLocation();
...@@ -661,7 +662,7 @@ void QmlEngine::continueInferior() ...@@ -661,7 +662,7 @@ void QmlEngine::continueInferior()
void QmlEngine::interruptInferior() void QmlEngine::interruptInferior()
{ {
showMessage(_(INTERRUPT), LogInput); showMessage(_(INTERRUPT), LogInput);
d->sendMessage(d->packMessage(INTERRUPT)); d->runDirectCommand(INTERRUPT);
notifyInferiorStopOk(); notifyInferiorStopOk();
} }
...@@ -1307,30 +1308,6 @@ void QmlEngine::logServiceActivity(const QString &service, const QString &logMes ...@@ -1307,30 +1308,6 @@ void QmlEngine::logServiceActivity(const QString &service, const QString &logMes
showMessage(service + QLatin1Char(' ') + logMessage, LogDebug); showMessage(service + QLatin1Char(' ') + logMessage, LogDebug);
} }
void QmlEnginePrivate::connect()
{
engine->showMessage(_(CONNECT), LogInput);
sendMessage(packMessage(CONNECT));
}
void QmlEnginePrivate::disconnect()
{
// { "seq" : <number>,
// "type" : "request",
// "command" : "disconnect",
// }
QJsonObject jsonVal = {
{_(SEQ), ++sequence},
{_(TYPE), _(REQUEST)}
};
jsonVal.insert(_(COMMAND), _(DISCONNECT));
const QByteArray msg = QJsonDocument(jsonVal).toJson(QJsonDocument::Compact);
engine->showMessage(QString::fromUtf8(msg), LogInput);
sendMessage(packMessage(DISCONNECT, msg));
}
void QmlEnginePrivate::continueDebugging(StepAction action) void QmlEnginePrivate::continueDebugging(StepAction action)
{ {
// { "seq" : <number>, // { "seq" : <number>,
...@@ -1547,7 +1524,7 @@ void QmlEnginePrivate::setBreakpoint(const QString type, const QString target, ...@@ -1547,7 +1524,7 @@ void QmlEnginePrivate::setBreakpoint(const QString type, const QString target,
QmlDebugStream rs(&params, QIODevice::WriteOnly); QmlDebugStream rs(&params, QIODevice::WriteOnly);
rs << target.toUtf8() << enabled; rs << target.toUtf8() << enabled;
engine->showMessage(QString(_("%1 %2 %3")).arg(_(BREAKONSIGNAL), target, enabled ? _("enabled") : _("disabled")), LogInput); engine->showMessage(QString(_("%1 %2 %3")).arg(_(BREAKONSIGNAL), target, enabled ? _("enabled") : _("disabled")), LogInput);
sendMessage(packMessage(BREAKONSIGNAL, params)); runDirectCommand(BREAKONSIGNAL, params);
} else { } else {
DebuggerCommand cmd(SETBREAKPOINT); DebuggerCommand cmd(SETBREAKPOINT);
...@@ -1743,27 +1720,21 @@ void QmlEnginePrivate::clearCache() ...@@ -1743,27 +1720,21 @@ void QmlEnginePrivate::clearCache()
updateLocalsAndWatchers.clear(); updateLocalsAndWatchers.clear();
} }
QByteArray QmlEnginePrivate::packMessage(const QByteArray &type, const QByteArray &message)
{
SDEBUG(message);
QByteArray request;
QmlDebugStream rs(&request, QIODevice::WriteOnly);
QByteArray cmd = V8DEBUG;
rs << cmd << type << message;
return request;
}
void QmlEnginePrivate::runCommand(const DebuggerCommand &command) void QmlEnginePrivate::runCommand(const DebuggerCommand &command)
{ {
// Leave items as variables, serialization depends on it.
QByteArray cmd = V8DEBUG;
QByteArray type = V8REQUEST;
QByteArray msg = "{\"seq\":" + QByteArray::number(++sequence) + "," QByteArray msg = "{\"seq\":" + QByteArray::number(++sequence) + ","
+ "\"type\":\"request\"," + "\"type\":\"request\","
+ "\"command\":\"" + command.function + "\"," + "\"command\":\"" + command.function + "\","
+ "\"arguments\":{" + command.arguments() + "}}"; + "\"arguments\":{" + command.arguments() + "}}";
runDirectCommand(V8REQUEST, msg);
}
void QmlEnginePrivate::runDirectCommand(const QByteArray &type, const QByteArray &msg)
{
// Leave item as variable, serialization depends on it.
QByteArray cmd = V8DEBUG;
engine->showMessage(QString::fromLatin1("%1 %2").arg(_(V8REQUEST), QString::fromUtf8(msg)), LogInput); engine->showMessage(QString::fromLatin1("%1 %2").arg(_(type), _(msg)), LogInput);
QByteArray request; QByteArray request;
QmlDebugStream rs(&request, QIODevice::WriteOnly); QmlDebugStream rs(&request, QIODevice::WriteOnly);
...@@ -2561,9 +2532,8 @@ void QmlEnginePrivate::stateChanged(State state) ...@@ -2561,9 +2532,8 @@ void QmlEnginePrivate::stateChanged(State state)
if (state == QmlDebugClient::Enabled) { if (state == QmlDebugClient::Enabled) {
/// Start session. /// Start session.
flushSendBuffer(); flushSendBuffer();
connect(); runDirectCommand(CONNECT);
// Query for the V8 version. This is only for logging to the log. runCommand(VERSION); // Only used for logging.
runCommand(VERSION);
} }
} }
......
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