From b99cb464fafa50518a5580cc16fe8d8495d4f70b Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 7 Dec 2016 13:31:10 +0100 Subject: [PATCH] Debugger: Add convenience function to pass lists of strings ... to *bridge.py and adjust surrounding code. Change-Id: I398ecf10a6b9c76ebf5683d2f3a6c28b57343663 Reviewed-by: hjk --- src/plugins/debugger/debuggerprotocol.cpp | 10 +++++++++- src/plugins/debugger/debuggerprotocol.h | 1 + src/plugins/debugger/lldb/lldbengine.cpp | 12 ++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 45288cb83cc..860e1868581 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -753,11 +753,19 @@ void DebuggerCommand::arg(const char *name, const char *value) void DebuggerCommand::arg(const char *name, const QList &list) { QJsonArray numbers; - foreach (int item, list) + for (int item : list) numbers.append(item); args = addToJsonObject(args, name, numbers); } +void DebuggerCommand::arg(const char *name, const QStringList &list) +{ + QJsonArray arr; + for (const QString &item : list) + arr.append(toHex(item)); + args = addToJsonObject(args, name, arr); +} + void DebuggerCommand::arg(const char *value) { QTC_ASSERT(args.isArray() || args.isNull(), return); diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index ad6f3ed822e..e72ffe36063 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -59,6 +59,7 @@ public: void arg(const char *name, const QString &value); void arg(const char *name, const char *value); void arg(const char *name, const QList &list); + void arg(const char *name, const QStringList &list); // Note: Hex-encodes. void arg(const char *name, const QJsonValue &value); QString argsToPython() const; diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 1a8593686bd..e24dea5d77f 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -339,16 +339,8 @@ void LldbEngine::setupInferior() cmd2.arg("startmode", rp.startMode); cmd2.arg("nativemixed", isNativeMixedActive()); cmd2.arg("workingdirectory", rp.inferior.workingDirectory); - - QJsonArray env; - foreach (const QString &item, rp.inferior.environment.toStringList()) - env.append(toHex(item)); - cmd2.arg("environment", env); - - QJsonArray processArgs; - foreach (const QString &arg, args.toUnixArgs()) - processArgs.append(QLatin1String(arg.toUtf8().toHex())); - cmd2.arg("processargs", processArgs); + cmd2.arg("environment", rp.inferior.environment.toStringList()); + cmd2.arg("processargs", args.toUnixArgs()); if (rp.useTerminal) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());