Debugger: Simplify LLDB communication protocol

Produce proper JSON directly.

Change-Id: I61aaba021fd4893fb521251c9b4b9572c2beef44
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2013-10-24 12:16:26 +02:00
parent 46c1769e24
commit fc4a953bb5
2 changed files with 20 additions and 45 deletions

View File

@@ -110,8 +110,8 @@ void LldbEngine::runCommand(const Command &command)
QTC_ASSERT(m_lldbProc.state() == QProcess::Running, notifyEngineIll());
++m_lastToken;
QByteArray token = QByteArray::number(m_lastToken);
QByteArray cmd = "db {'cmd':'" + command.function + "',"
+ command.args + "'token':" + token + "}\n";
QByteArray cmd = "{\"cmd\":\"" + command.function + "\","
+ command.args + "\"token\":" + token + "}\n";
showMessage(_(token + cmd), LogInput);
m_lldbProc.write(cmd);
}
@@ -156,7 +156,7 @@ void LldbEngine::setupEngine()
m_lldbProc.start(_("python"), args);
if (!m_lldbProc.waitForStarted()) {
const QString msg = tr("Unable to start LLDB '%1': %2")
const QString msg = tr("Unable to start LLDB \"%1\": %2")
.arg(m_lldbCmd, m_lldbProc.errorString());
notifyEngineSetupFailed();
showMessage(_("ADAPTER START FAILED"));
@@ -645,7 +645,7 @@ bool LldbEngine::setToolTipExpression(const QPoint &mousePos,
}
if (!hasLetterOrNumber(exp)) {
QToolTip::showText(m_toolTipPos, tr("'%1' contains no identifier.").arg(exp));
QToolTip::showText(m_toolTipPos, tr("\"%1\" contains no identifier.").arg(exp));
return true;
}
@@ -665,7 +665,7 @@ bool LldbEngine::setToolTipExpression(const QPoint &mousePos,
if (hasSideEffects(exp)) {
QToolTip::showText(m_toolTipPos,
tr("Cowardly refusing to evaluate expression '%1' "
tr("Cowardly refusing to evaluate expression \"%1\" "
"with potential side effects.").arg(exp));
return true;
}
@@ -794,7 +794,7 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const
switch (error) {
case QProcess::FailedToStart:
return tr("The LLDB process failed to start. Either the "
"invoked program '%1' is missing, or you may have insufficient "
"invoked program \"%1\" is missing, or you may have insufficient "
"permissions to invoke the program.")
.arg(m_lldbCmd);
case QProcess::Crashed:
@@ -856,12 +856,12 @@ void LldbEngine::requestUpdateWatchers()
while (it.hasNext()) {
it.next();
QHash<QByteArray, QByteArray> hash;
hash["iname"] = "'watch." + QByteArray::number(it.value()) + '\'';
hash["exp"] = '\'' + it.key().toHex() + '\'';
hash["iname"] = "\"watch." + QByteArray::number(it.value()) + '"';
hash["exp"] = '"' + it.key().toHex() + '"';
watcherData.append(Command::toData(hash));
}
Command cmd("setWatchers");
cmd.args.append("'watchers':" + Command::toData(watcherData) + ',');
cmd.args.append("\"watchers\":" + Command::toData(watcherData) + ',');
runCommand(cmd);
}
@@ -1117,9 +1117,9 @@ DebuggerEngine *createLldbEngine(const DebuggerStartParameters &startParameters)
const LldbEngine::Command &LldbEngine::Command::argHelper(const char *name, const QByteArray &data) const
{
args.append('\'');
args.append('"');
args.append(name);
args.append("':");
args.append("\":");
args.append(data);
args.append(",");
return *this;
@@ -1144,7 +1144,7 @@ QByteArray LldbEngine::Command::toData(const QHash<QByteArray, QByteArray> &valu
it.next();
if (!res.isEmpty())
res.append(',');
res += '\'' + it.key() + "':" + it.value();
res += '"' + it.key() + "\":" + it.value();
}
return '{' + res + '}';
}
@@ -1176,20 +1176,20 @@ const LldbEngine::Command &LldbEngine::Command::arg(const char *name, const QByt
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, const char *value) const
{
args.append('\'');
args.append('"');
args.append(name);
args.append("':'");
args.append("\":\"");
args.append(value);
args.append("',");
args.append("\",");
return *this;
}
const LldbEngine::Command &LldbEngine::Command::beginList(const char *name) const
{
if (name) {
args += '\'';
args += '"';
args += name;
args += "':";
args += "\":";
}
args += '[';
return *this;
@@ -1205,9 +1205,9 @@ void LldbEngine::Command::endList() const
const LldbEngine::Command &LldbEngine::Command::beginGroup(const char *name) const
{
if (name) {
args += '\'';
args += '"';
args += name;
args += "':";
args += "\":";
}
args += '{';
return *this;