mirror of https://github.com/buggins/dlangide.git
debugger - step / thread fixes
This commit is contained in:
parent
4aac13c19f
commit
ec3a1abac0
|
@ -112,6 +112,10 @@ class DebugThread {
|
|||
}
|
||||
DebugThread clone() { return new DebugThread(this); }
|
||||
|
||||
@property string displayName() {
|
||||
return "%u: %s".format(id, name);
|
||||
}
|
||||
|
||||
@property int length() {
|
||||
if (stack && stack.length > 0)
|
||||
return stack.length;
|
||||
|
@ -217,11 +221,11 @@ interface Debugger : ProgramExecution {
|
|||
/// interrupt execution
|
||||
void execPause();
|
||||
/// step over
|
||||
void execStepOver();
|
||||
void execStepOver(ulong threadId);
|
||||
/// step in
|
||||
void execStepIn();
|
||||
void execStepIn(ulong threadId);
|
||||
/// step out
|
||||
void execStepOut();
|
||||
void execStepOut(ulong threadId);
|
||||
/// restart
|
||||
void execRestart();
|
||||
|
||||
|
@ -370,16 +374,16 @@ class DebuggerProxy : Debugger, DebuggerCallback {
|
|||
_debugger.postRequest(delegate() { _debugger.execPause(); });
|
||||
}
|
||||
/// step over
|
||||
void execStepOver() {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepOver(); });
|
||||
void execStepOver(ulong threadId) {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepOver(threadId); });
|
||||
}
|
||||
/// step in
|
||||
void execStepIn() {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepIn(); });
|
||||
void execStepIn(ulong threadId) {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepIn(threadId); });
|
||||
}
|
||||
/// step out
|
||||
void execStepOut() {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepOut(); });
|
||||
void execStepOut(ulong threadId) {
|
||||
_debugger.postRequest(delegate() { _debugger.execStepOut(threadId); });
|
||||
}
|
||||
/// restart
|
||||
void execRestart() {
|
||||
|
|
|
@ -296,20 +296,21 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
|
|||
void execPause() {
|
||||
_pauseRequestId = sendCommand("-exec-interrupt");
|
||||
}
|
||||
|
||||
/// step over
|
||||
int _stepOverRequestId;
|
||||
void execStepOver() {
|
||||
_stepOverRequestId = sendCommand("-exec-next");
|
||||
void execStepOver(ulong threadId) {
|
||||
_stepOverRequestId = sendCommand("-exec-next".appendThreadParam(threadId));
|
||||
}
|
||||
/// step in
|
||||
int _stepInRequestId;
|
||||
void execStepIn() {
|
||||
_stepInRequestId = sendCommand("-exec-step");
|
||||
void execStepIn(ulong threadId) {
|
||||
_stepInRequestId = sendCommand("-exec-step".appendThreadParam(threadId));
|
||||
}
|
||||
/// step out
|
||||
int _stepOutRequestId;
|
||||
void execStepOut() {
|
||||
_stepOutRequestId = sendCommand("-exec-finish");
|
||||
void execStepOut(ulong threadId) {
|
||||
_stepOutRequestId = sendCommand("-exec-finish".appendThreadParam(threadId));
|
||||
}
|
||||
/// restart
|
||||
int _restartRequestId;
|
||||
|
@ -739,3 +740,10 @@ struct GDBRequestList {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// appends --thread parameter to command text if threadId != 0
|
||||
string appendThreadParam(string src, ulong threadId) {
|
||||
if (!threadId)
|
||||
return src;
|
||||
return src ~= " --thread " ~ to!string(threadId);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler {
|
|||
private WatchPanel _watchPanel;
|
||||
private StackPanel _stackPanel;
|
||||
private DebugThreadList _debugInfo;
|
||||
private ulong _currentThreadId;
|
||||
|
||||
this(IDEFrame ide, Debugger debugger) {
|
||||
_ide = ide;
|
||||
|
@ -42,6 +43,7 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler {
|
|||
void onDebugContextInfo(DebugThreadList info, ulong threadId, int frameId) {
|
||||
Log.d("Debugger context received threadId=", threadId, " frameId=", frameId);
|
||||
_debugInfo = info;
|
||||
_currentThreadId = threadId;
|
||||
_stackPanel.updateDebugInfo(info, threadId, frameId);
|
||||
_watchPanel.updateDebugInfo(info, threadId, frameId);
|
||||
}
|
||||
|
@ -132,34 +134,51 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler {
|
|||
_debugger.run();
|
||||
}
|
||||
|
||||
@property ulong currentThreadId() {
|
||||
if (_currentThreadId)
|
||||
return _currentThreadId;
|
||||
return _debugInfo ? _debugInfo.currentThreadId : 0;
|
||||
}
|
||||
bool handleAction(const Action a) {
|
||||
switch(a.id) {
|
||||
case IDEActions.DebugPause:
|
||||
if (_state == DebuggingState.running)
|
||||
if (_state == DebuggingState.running) {
|
||||
_currentThreadId = 0;
|
||||
_debugger.execPause();
|
||||
}
|
||||
return true;
|
||||
case IDEActions.DebugContinue:
|
||||
if (_state == DebuggingState.paused)
|
||||
if (_state == DebuggingState.paused) {
|
||||
_currentThreadId = 0;
|
||||
_debugger.execContinue();
|
||||
}
|
||||
return true;
|
||||
case IDEActions.DebugStop:
|
||||
//_debugger.execStop();
|
||||
Log.d("Trying to stop debugger");
|
||||
_currentThreadId = 0;
|
||||
_debugger.stop();
|
||||
return true;
|
||||
case IDEActions.DebugStepInto:
|
||||
if (_state == DebuggingState.paused)
|
||||
_debugger.execStepIn();
|
||||
if (_state == DebuggingState.paused) {
|
||||
Log.d("DebugStepInto threadId=", currentThreadId);
|
||||
_debugger.execStepIn(currentThreadId);
|
||||
}
|
||||
return true;
|
||||
case IDEActions.DebugStepOver:
|
||||
if (_state == DebuggingState.paused)
|
||||
_debugger.execStepOver();
|
||||
if (_state == DebuggingState.paused) {
|
||||
Log.d("DebugStepOver threadId=", currentThreadId);
|
||||
_debugger.execStepOver(currentThreadId);
|
||||
}
|
||||
return true;
|
||||
case IDEActions.DebugStepOut:
|
||||
if (_state == DebuggingState.paused)
|
||||
_debugger.execStepOut();
|
||||
if (_state == DebuggingState.paused) {
|
||||
Log.d("DebugStepOut threadId=", currentThreadId);
|
||||
_debugger.execStepOut(currentThreadId);
|
||||
}
|
||||
return true;
|
||||
case IDEActions.DebugRestart:
|
||||
_currentThreadId = 0;
|
||||
_debugger.execRestart();
|
||||
return true;
|
||||
default:
|
||||
|
|
|
@ -63,7 +63,7 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler {
|
|||
_comboBox.enabled = true;
|
||||
dstring[] threadNames;
|
||||
for (int i = 0; i < _debugInfo.length; i++) {
|
||||
threadNames ~= _debugInfo[i].name.toUTF32;
|
||||
threadNames ~= _debugInfo[i].displayName.toUTF32;
|
||||
if (_debugInfo[i].id == _currentThreadId) {
|
||||
_currentThreadIndex = i;
|
||||
_selectedThread = _debugInfo[i];
|
||||
|
|
Loading…
Reference in New Issue