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 <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2018-08-02 22:07:26 +03:00
committed by Orgad Shaneh
parent 8353a6ed20
commit 787c4fc21e

View File

@@ -2603,10 +2603,14 @@ void GdbEngine::changeBreakpoint(Breakpoint bp)
cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakLineNumber(r, bp); }; cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakLineNumber(r, bp); };
} else if (data.command != response.command) { } else if (data.command != response.command) {
cmd.function = "-break-commands " + bpnr; cmd.function = "-break-commands " + bpnr;
foreach (const QString &command, data.command.split(QLatin1String("\n"))) { for (QString command : data.command.split('\n')) {
if (!command.isEmpty()) if (!command.isEmpty()) {
// escape backslashes and quotes
command.replace('\\', "\\\\");
command.replace('"', "\\\"");
cmd.function += " \"" + command + '"'; cmd.function += " \"" + command + '"';
} }
}
cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakIgnore(r, bp); }; cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakIgnore(r, bp); };
} else if (!data.conditionsMatch(response.condition)) { } else if (!data.conditionsMatch(response.condition)) {
cmd.function = "condition " + bpnr + ' ' + data.condition; cmd.function = "condition " + bpnr + ' ' + data.condition;