Commit fc4a953b authored by hjk's avatar hjk
Browse files

Debugger: Simplify LLDB communication protocol



Produce proper JSON directly.

Change-Id: I61aaba021fd4893fb521251c9b4b9572c2beef44
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 46c1769e
......@@ -1699,32 +1699,7 @@ def doit():
for reader in readable:
if reader == sys.stdin:
line = sys.stdin.readline()
#warn("READING LINE '%s'" % line)
if line.startswith("db "):
line = line.replace("'", '"')[3:]
db.execute(convertHash(json.loads(line)))
def testit1():
db = Dumper()
db.setupInferior({'cmd':'setupInferior','executable':sys.argv[2],'token':1})
db.handleBreakpoints({'cmd':'handleBreakpoints','bkpts':[{'operation':'add',
'modelid':'1','type':2,'ignorecount':0,'condition':'','function':'main',
'oneshot':0,'enabled':1,'file':'','line':0}]})
db.runEngine({'cmd':'runEngine','token':4})
while True:
readable, _, _ = select.select([sys.stdin], [], [])
for reader in readable:
if reader == sys.stdin:
line = sys.stdin.readline().strip()
#warn("READING LINE '%s'" % line)
if line.startswith("db "):
db.execute(eval(line[3:]))
else:
db.executeDebuggerCommand({'command':line})
db.execute(convertHash(json.loads(line)))
# Used in dumper auto test.
......
......@@ -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;
......
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