From 787c4fc21e43959a25ff63c120214c663e1fa96b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 2 Aug 2018 22:07:26 +0300 Subject: [PATCH] GDB: Escape quotes on breakpoint commands The commands are wrapped in quotes, and if they contain quotes it gets messed up. Change-Id: I41cebd8cf4a57a8ea671e5f43a3295af1c73fd02 Reviewed-by: hjk --- src/plugins/debugger/gdb/gdbengine.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 263211a5988..81af51a3cc6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2603,9 +2603,13 @@ void GdbEngine::changeBreakpoint(Breakpoint bp) cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakLineNumber(r, bp); }; } else if (data.command != response.command) { cmd.function = "-break-commands " + bpnr; - foreach (const QString &command, data.command.split(QLatin1String("\n"))) { - if (!command.isEmpty()) + for (QString command : data.command.split('\n')) { + if (!command.isEmpty()) { + // escape backslashes and quotes + command.replace('\\', "\\\\"); + command.replace('"', "\\\""); cmd.function += " \"" + command + '"'; + } } cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakIgnore(r, bp); }; } else if (!data.conditionsMatch(response.condition)) {