mirror of https://github.com/buggins/dlangide.git
gdb support
This commit is contained in:
parent
be7717e108
commit
26e805fe1d
|
@ -5,6 +5,7 @@ import dlangui.core.logger;
|
||||||
import ddebug.common.queue;
|
import ddebug.common.queue;
|
||||||
import dlangide.builders.extprocess;
|
import dlangide.builders.extprocess;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
import std.conv : to;
|
||||||
|
|
||||||
class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
|
class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
|
||||||
protected ExternalProcess _debuggerProcess;
|
protected ExternalProcess _debuggerProcess;
|
||||||
|
@ -51,6 +52,10 @@ class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sendLine(string text) {
|
||||||
|
return _debuggerProcess.write(text ~ "\n");
|
||||||
|
}
|
||||||
|
|
||||||
/// log lines
|
/// log lines
|
||||||
override void writeText(dstring text) {
|
override void writeText(dstring text) {
|
||||||
string text8 = toUTF8(text);
|
string text8 = toUTF8(text);
|
||||||
|
@ -63,6 +68,15 @@ class ConsoleDebuggerInterface : DebuggerBase, TextWriter {
|
||||||
|
|
||||||
class GDBInterface : ConsoleDebuggerInterface {
|
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) {
|
override void startDebugging(string debuggerExecutable, string executable, string[] args, string workingDir, DebuggerResponse response) {
|
||||||
string[] debuggerArgs;
|
string[] debuggerArgs;
|
||||||
debuggerArgs ~= "--interpreter=mi";
|
debuggerArgs ~= "--interpreter=mi";
|
||||||
|
@ -75,6 +89,8 @@ class GDBInterface : ConsoleDebuggerInterface {
|
||||||
Log.i("Debugger process state:");
|
Log.i("Debugger process state:");
|
||||||
if (state == ExternalProcessState.Running) {
|
if (state == ExternalProcessState.Running) {
|
||||||
response(ResponseCode.Ok, "Started");
|
response(ResponseCode.Ok, "Started");
|
||||||
|
sendCommand("-break-insert main");
|
||||||
|
sendCommand("-exec-run");
|
||||||
} else {
|
} else {
|
||||||
response(ResponseCode.CannotRunDebugger, "Error while trying to run debugger process");
|
response(ResponseCode.CannotRunDebugger, "Error while trying to run debugger process");
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,14 +400,16 @@ class ExternalProcess {
|
||||||
return _state;
|
return _state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(string data) {
|
bool write(string data) {
|
||||||
if(_state == ExternalProcessState.Error || _state == ExternalProcessState.None || _state == ExternalProcessState.Stopped) {
|
if(_state == ExternalProcessState.Error || _state == ExternalProcessState.None || _state == ExternalProcessState.Stopped) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d("writing ", data.length, " characters to stdin");
|
Log.d("writing ", data.length, " characters to stdin");
|
||||||
_pipes.stdin.write("", data);
|
_pipes.stdin.write("", data);
|
||||||
_pipes.stdin.close();
|
_pipes.stdin.flush();
|
||||||
|
//_pipes.stdin.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue