mirror of https://github.com/buggins/dlangide.git
fix debugger stopping handling
This commit is contained in:
parent
4fa0173a7e
commit
94ae71b7e8
|
@ -298,7 +298,9 @@ abstract class DebuggerBase : Thread, Debugger {
|
|||
_queue.close();
|
||||
}
|
||||
|
||||
bool _threadStarted;
|
||||
protected void onDebuggerThreadStarted() {
|
||||
_threadStarted = true;
|
||||
}
|
||||
|
||||
protected void onDebuggerThreadFinished() {
|
||||
|
@ -317,7 +319,7 @@ abstract class DebuggerBase : Thread, Debugger {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("Exception in debugger thread");
|
||||
Log.e("Exception in debugger thread", e);
|
||||
}
|
||||
Log.i("Debugger thread finished");
|
||||
_finished = true;
|
||||
|
|
|
@ -82,6 +82,11 @@ class GDBInterface : ConsoleDebuggerInterface {
|
|||
protected int commandId;
|
||||
|
||||
int sendCommand(string text) {
|
||||
ExternalProcessState state = _debuggerProcess.poll();
|
||||
if (state != ExternalProcessState.Running) {
|
||||
_stopRequested = true;
|
||||
return 0;
|
||||
}
|
||||
commandId++;
|
||||
string cmd = to!string(commandId) ~ text;
|
||||
Log.d("GDB command[", commandId, "]> ", text);
|
||||
|
@ -228,19 +233,29 @@ class GDBInterface : ConsoleDebuggerInterface {
|
|||
|
||||
bool _threadJoined = false;
|
||||
override void stop() {
|
||||
if (_stopRequested)
|
||||
if (_stopRequested) {
|
||||
Log.w("GDBInterface.stop() - _stopRequested flag already set");
|
||||
return;
|
||||
}
|
||||
_stopRequested = true;
|
||||
Log.d("GDBInterface.stop()");
|
||||
postRequest(delegate() {
|
||||
Log.d("GDBInterface.stop() processing in queue");
|
||||
execStop();
|
||||
});
|
||||
_stopRequested = true;
|
||||
Thread.sleep(dur!"msecs"(200));
|
||||
postRequest(delegate() {
|
||||
});
|
||||
_queue.close();
|
||||
if (!_threadJoined) {
|
||||
_threadJoined = true;
|
||||
join();
|
||||
if (_threadStarted) {
|
||||
try {
|
||||
join();
|
||||
} catch (Exception e) {
|
||||
Log.e("Exception while trying to join debugger thread");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -380,6 +380,7 @@ class ExternalProcess {
|
|||
try {
|
||||
_result = std.process.wait(_pipes.pid);
|
||||
_state = ExternalProcessState.Stopped;
|
||||
Log.d("ExternalProcess.wait : waitForReadingCompletion");
|
||||
waitForReadingCompletion();
|
||||
} catch (Exception e) {
|
||||
Log.e("Exception while waiting for process ", _program);
|
||||
|
@ -401,11 +402,10 @@ class ExternalProcess {
|
|||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
else {
|
||||
Log.d("writing ", data.length, " characters to stdin");
|
||||
} else {
|
||||
//Log.d("writing ", data.length, " characters to stdin");
|
||||
_pipes.stdin.write("", data);
|
||||
_pipes.stdin.flush();
|
||||
//_pipes.stdin.close();
|
||||
|
|
|
@ -151,7 +151,8 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
|||
}
|
||||
|
||||
void debugFinished(ProgramExecution process, ExecutionStatus status, int exitCode) {
|
||||
_execution = null;
|
||||
_execution = null;
|
||||
_debugHandler = null;
|
||||
switch(status) {
|
||||
case ExecutionStatus.Error:
|
||||
_logPanel.logLine("Cannot run program " ~ process.executableFile);
|
||||
|
|
Loading…
Reference in New Issue