fix mago-mi compatibility

This commit is contained in:
Vadim Lopatin 2016-05-20 14:17:40 +03:00
parent e59f9d1755
commit b941610b81
2 changed files with 36 additions and 2 deletions

View File

@ -344,6 +344,34 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
return null;
}
static string quotePathIfNeeded(string s) {
char[] buf;
buf.assumeSafeAppend();
bool hasSpaces = false;
for(uint i = 0; i < s.length; i++) {
if (s[i] == ' ')
hasSpaces = true;
}
if (hasSpaces)
buf ~= '\"';
for(uint i = 0; i < s.length; i++) {
char ch = s[i];
if (ch == '\t')
buf ~= "\\t";
else if (ch == '\n')
buf ~= "\\n";
else if (ch == '\r')
buf ~= "\\r";
else if (ch == '\\')
buf ~= "\\\\";
else
buf ~= ch;
}
if (hasSpaces)
buf ~= '\"';
return buf.dup;
}
class AddBreakpointRequest : GDBRequest {
GDBBreakpoint gdbbp;
this(Breakpoint bp) {
@ -353,7 +381,7 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
cmd ~= "-break-insert ";
if (!bp.enabled)
cmd ~= "-d "; // create disabled
cmd ~= bp.fullFilePath;
cmd ~= quotePathIfNeeded(bp.fullFilePath);
cmd ~= ":";
cmd ~= to!string(bp.line);
command = cmd.dup;

View File

@ -8,6 +8,7 @@ import std.utf;
import std.stdio;
import core.thread;
import core.sync.mutex;
import dlangui.core.files;
/// interface to forward process output to
interface TextWriter {
@ -293,7 +294,12 @@ class ExternalProcess {
ExternalProcessState run(char[] program, char[][]args, char[] dir, TextWriter stdoutTarget, TextWriter stderrTarget = null) {
Log.d("ExternalProcess.run ", program, " ", args);
_state = ExternalProcessState.None;
_program = program;
_program = findExecutablePath(cast(string)program).dup;
if (!_program) {
_state = ExternalProcessState.Error;
Log.e("Executable not found for ", program);
return _state;
}
_args = args;
_workDir = dir;
_stdout = stdoutTarget;