Commit 648a8e82 authored by hjk's avatar hjk

Debugger: Remove DebuggerCommand .arg chaining.

Less stylish options for more uniform user code.

Change-Id: Ie9a6558101383a844efa25ba3ab59b4b824ad89f
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 0da9178c
......@@ -739,14 +739,13 @@ QString decodeData(const QByteArray &ba, int encoding)
//
//////////////////////////////////////////////////////////////////////////////////
const DebuggerCommand &DebuggerCommand::argHelper(const char *name, const QByteArray &data) const
void DebuggerCommand::argHelper(const char *name, const QByteArray &data)
{
args.append('"');
args.append(name);
args.append("\":");
args.append(data);
args.append(",");
return *this;
}
QByteArray DebuggerCommand::toData(const QList<QByteArray> &value)
......@@ -773,50 +772,48 @@ QByteArray DebuggerCommand::toData(const QHash<QByteArray, QByteArray> &value)
return '{' + res + '}';
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, int value) const
void DebuggerCommand::arg(const char *name, int value)
{
return argHelper(name, QByteArray::number(value));
argHelper(name, QByteArray::number(value));
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, qlonglong value) const
void DebuggerCommand::arg(const char *name, qlonglong value)
{
return argHelper(name, QByteArray::number(value));
argHelper(name, QByteArray::number(value));
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, qulonglong value) const
void DebuggerCommand::arg(const char *name, qulonglong value)
{
return argHelper(name, QByteArray::number(value));
argHelper(name, QByteArray::number(value));
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, const QString &value) const
void DebuggerCommand::arg(const char *name, const QString &value)
{
return arg(name, value.toUtf8().data());
arg(name, value.toUtf8().data());
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, const QByteArray &value) const
void DebuggerCommand::arg(const char *name, const QByteArray &value)
{
return arg(name, value.data());
arg(name, value.data());
}
const DebuggerCommand &DebuggerCommand::arg(const char *name, const char *value) const
void DebuggerCommand::arg(const char *name, const char *value)
{
args.append('"');
args.append(name);
args.append("\":\"");
args.append(value);
args.append("\",");
return *this;
}
const DebuggerCommand &DebuggerCommand::arg(const char *value) const
void DebuggerCommand::arg(const char *value)
{
args.append("\"");
args.append(value);
args.append("\",");
return *this;
}
const DebuggerCommand &DebuggerCommand::beginList(const char *name) const
void DebuggerCommand::beginList(const char *name)
{
if (name) {
args += '"';
......@@ -824,17 +821,16 @@ const DebuggerCommand &DebuggerCommand::beginList(const char *name) const
args += "\":";
}
args += '[';
return *this;
}
void DebuggerCommand::endList() const
void DebuggerCommand::endList()
{
if (args.endsWith(','))
args.chop(1);
args += "],";
}
const DebuggerCommand &DebuggerCommand::beginGroup(const char *name) const
void DebuggerCommand::beginGroup(const char *name)
{
if (name) {
args += '"';
......@@ -842,10 +838,9 @@ const DebuggerCommand &DebuggerCommand::beginGroup(const char *name) const
args += "\":";
}
args += '{';
return *this;
}
void DebuggerCommand::endGroup() const
void DebuggerCommand::endGroup()
{
if (args.endsWith(','))
args.chop(1);
......
......@@ -43,25 +43,26 @@ public:
DebuggerCommand() {}
DebuggerCommand(const char *f) : function(f) {}
const DebuggerCommand &arg(const char *name) const;
const DebuggerCommand &arg(const char *name, int value) const;
const DebuggerCommand &arg(const char *name, qlonglong value) const;
const DebuggerCommand &arg(const char *name, qulonglong value) const;
const DebuggerCommand &arg(const char *name, const QString &value) const;
const DebuggerCommand &arg(const char *name, const QByteArray &value) const;
const DebuggerCommand &arg(const char *name, const char *value) const;
const DebuggerCommand &beginList(const char *name = 0) const;
void endList() const;
const DebuggerCommand &beginGroup(const char *name = 0) const;
void endGroup() const;
void arg(const char *name);
void arg(const char *name, int value);
void arg(const char *name, qlonglong value);
void arg(const char *name, qulonglong value);
void arg(const char *name, const QString &value);
void arg(const char *name, const QByteArray &value);
void arg(const char *name, const char *value);
void beginList(const char *name = 0);
void endList();
void beginGroup(const char *name = 0);
void endGroup();
static QByteArray toData(const QList<QByteArray> &value);
static QByteArray toData(const QHash<QByteArray, QByteArray> &value);
QByteArray function;
mutable QByteArray args;
QByteArray args;
private:
const DebuggerCommand &argHelper(const char *name, const QByteArray &value) const;
void argHelper(const char *name, const QByteArray &value);
};
/*
......
......@@ -121,7 +121,9 @@ LldbEngine::~LldbEngine()
void LldbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages)
{
runCommand(DebuggerCommand("executeDebuggerCommand").arg("command", command));
DebuggerCommand cmd("executeDebuggerCommand");
cmd.arg("command", command);
runCommand(cmd);
}
void LldbEngine::runCommand(const DebuggerCommand &command)
......@@ -492,7 +494,9 @@ void LldbEngine::executeRunToFunction(const QString &functionName)
{
resetLocation();
notifyInferiorRunRequested();
runCommand(DebuggerCommand("executeRunToFunction").arg("function", functionName));
DebuggerCommand cmd("executeRunToFunction");
cmd.arg("function", functionName);
runCommand(cmd);
}
void LldbEngine::executeJumpToLine(const ContextData &data)
......@@ -532,7 +536,9 @@ void LldbEngine::activateFrame(int frameIndex)
void LldbEngine::selectThread(ThreadId threadId)
{
runCommand(DebuggerCommand("selectThread").arg("id", threadId.raw()));
DebuggerCommand cmd("selectThread");
cmd.arg("id", threadId.raw());
runCommand(cmd);
}
bool LldbEngine::stateAcceptsBreakpointChanges() const
......@@ -739,7 +745,9 @@ void LldbEngine::refreshModules(const GdbMi &modules)
void LldbEngine::requestModuleSymbols(const QString &moduleName)
{
runCommand(DebuggerCommand("listSymbols").arg("module", moduleName));
DebuggerCommand cmd("listSymbols");
cmd.arg("module", moduleName);
runCommand(cmd);
}
void LldbEngine::refreshSymbols(const GdbMi &symbols)
......@@ -864,19 +872,19 @@ void LldbEngine::doUpdateLocals(UpdateParameters params)
QHashIterator<QByteArray, int> it(WatchHandler::watcherNames());
while (it.hasNext()) {
it.next();
cmd.beginGroup()
.arg("iname", "watch." + QByteArray::number(it.value()))
.arg("exp", it.key().toHex())
.endGroup();
cmd.beginGroup();
cmd.arg("iname", "watch." + QByteArray::number(it.value()));
cmd.arg("exp", it.key().toHex());
cmd.endGroup();
}
// Tooltips
DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(this);
foreach (const DebuggerToolTipContext &p, toolTips) {
cmd.beginGroup()
.arg("iname", p.iname)
.arg("exp", p.expression.toLatin1().toHex())
.endGroup();
cmd.beginGroup();
cmd.arg("iname", p.iname);
cmd.arg("exp", p.expression.toLatin1().toHex());
cmd.endGroup();
}
cmd.endList();
......@@ -1205,10 +1213,12 @@ void LldbEngine::changeMemory(MemoryAgent *agent, QObject *editorToken,
void LldbEngine::setRegisterValue(const QByteArray &name, const QString &value)
{
runCommand(DebuggerCommand("setRegister").arg("name", name).arg("value", value));
DebuggerCommand cmd("setRegister");
cmd.arg("name", name);
cmd.arg("value", value);
runCommand(cmd);
}
bool LldbEngine::hasCapability(unsigned cap) const
{
if (cap & (ReverseSteppingCapability
......
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