gdb support

This commit is contained in:
Vadim Lopatin 2015-11-16 16:54:32 +03:00
parent be7717e108
commit 26e805fe1d
2 changed files with 21 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import dlangui.core.logger;
import ddebug.common.queue;
import dlangide.builders.extprocess;
import std.utf;
import std.conv : to;
class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
protected ExternalProcess _debuggerProcess;
@ -51,6 +52,10 @@ class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
}
}
bool sendLine(string text) {
return _debuggerProcess.write(text ~ "\n");
}
/// log lines
override void writeText(dstring text) {
string text8 = toUTF8(text);
@ -63,6 +68,15 @@ class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
class GDBInterface : ConsoleDebuggerInterface {
protected int commandId;
int sendCommand(string text) {
commandId++;
sendLine(to!string(commandId) ~ text);
return commandId;
}
override void startDebugging(string debuggerExecutable, string executable, string[] args, string workingDir, DebuggerResponse response) {
string[] debuggerArgs;
debuggerArgs ~= "--interpreter=mi";
@ -75,6 +89,8 @@ class GDBInterface : ConsoleDebuggerInterface {
Log.i("Debugger process state:");
if (state == ExternalProcessState.Running) {
response(ResponseCode.Ok, "Started");
sendCommand("-break-insert main");
sendCommand("-exec-run");
} else {
response(ResponseCode.CannotRunDebugger, "Error while trying to run debugger process");
}

View File

@ -400,14 +400,16 @@ class ExternalProcess {
return _state;
}
void write(string data) {
bool write(string data) {
if(_state == ExternalProcessState.Error || _state == ExternalProcessState.None || _state == ExternalProcessState.Stopped) {
return;
return false;
}
else {
Log.d("writing ", data.length, " characters to stdin");
_pipes.stdin.write("", data);
_pipes.stdin.close();
_pipes.stdin.flush();
//_pipes.stdin.close();
return true;
}
}
}