diff --git a/src/ddebug/common/debugger.d b/src/ddebug/common/debugger.d index 2de3bc3..1c85973 100644 --- a/src/ddebug/common/debugger.d +++ b/src/ddebug/common/debugger.d @@ -6,6 +6,7 @@ import ddebug.common.queue; import ddebug.common.execution; import std.array : empty; import std.algorithm : startsWith, endsWith, equal; +import std.string : format; enum DebuggingState { loaded, @@ -60,6 +61,14 @@ class DebugFrame : LocationBase { int level; DebugVariableList locals; + @property string formattedAddress() { + if (address < 0x100000000) { + return "%08x".format(address); + } else { + return "%016x".format(address); + } + } + this() {} this(DebugFrame v) { super(v); diff --git a/src/ddebug/gdb/gdbinterface.d b/src/ddebug/gdb/gdbinterface.d index 30cdeef..56a9275 100644 --- a/src/ddebug/gdb/gdbinterface.d +++ b/src/ddebug/gdb/gdbinterface.d @@ -274,6 +274,10 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget { _startRequestId = sendCommand("-exec-run"); } + void execAbort() { + _startRequestId = sendCommand("-exec-abort"); + } + /// start program execution, can be called after program is loaded int _continueRequestId; void execContinue() { @@ -471,7 +475,22 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget { } updateState(); _callback.onDebugState(DebuggingState.paused, StateChangeReason.breakpointHit, location, bp); + } else if (reason.equal("exited-normally")) { + _exitCode = 0; + Log.i("Program exited. Exit code ", _exitCode); + _callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null); + } else if (reason.equal("exited")) { + _exitCode = params.getInt("exit-code"); + Log.i("Program exited. Exit code ", _exitCode); + _callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null); + } else if (reason.equal("exited-signalled")) { + _exitCode = -2; //params.getInt("exit-code"); + string signalName = params.getString("signal-name"); + string signalMeaning = params.getString("signal-meaning"); + Log.i("Program exited by signal. Signal code: ", signalName, " Signal meaning: ", signalMeaning); + _callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null); } else { + _exitCode = -1; _callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null); } } @@ -576,7 +595,7 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget { this(ulong threadId, int frameId) { _threadId = threadId; _frameId = frameId; - command = "-stack-list-locals --thread " ~ to!string(threadId) ~ " --frame " ~ to!string(frameId) ~ " --simple-values"; + command = "-stack-list-variables --thread " ~ to!string(_threadId) ~ " --frame " ~ to!string(_frameId) ~ " --simple-values"; } override void onResult() { DebugVariableList variables = parseVariableList(params); @@ -584,9 +603,12 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget { // TODO Log.d("Variable list is parsed: " ~ to!string(variables)); if (_currentState) { - if (DebugThread currentThread = _currentState.currentThread) { + if (DebugThread currentThread = _currentState.findThread(_threadId)) { if (currentThread.length > 0) { - currentThread[0].locals = variables; + if (_frameId > currentThread.length) + _frameId = 0; + if (_frameId < currentThread.length) + currentThread[_frameId].locals = variables; Log.d("Setting variables for current thread top frame"); _callback.onDebugContextInfo(_currentState.clone(), _threadId, _frameId); } diff --git a/src/ddebug/gdb/gdbmiparser.d b/src/ddebug/gdb/gdbmiparser.d index 290be10..6663684 100644 --- a/src/ddebug/gdb/gdbmiparser.d +++ b/src/ddebug/gdb/gdbmiparser.d @@ -79,11 +79,11 @@ DebugFrame parseFrame(MIValue frame) { return location; } -DebugVariableList parseVariableList(MIValue params) { +DebugVariableList parseVariableList(MIValue params, string paramName = "variables") { if (!params) return null; DebugVariableList res = new DebugVariableList(); - MIValue list = params["locals"]; + MIValue list = params[paramName]; if (list && list.isList) { for(int i = 0; i < list.length; i++) { if (DebugVariable t = parseVariable(list[i])) diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index b880ac0..3846d00 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -141,6 +141,7 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener { if (lineIndex == _executionLine) { buf.fillRect(visibleRect, _executionLineHighlightColor); } + super.drawLineBackground(buf, lineIndex, lineRect, visibleRect); } void setSyntaxSupport() { diff --git a/src/dlangide/ui/stackpanel.d b/src/dlangide/ui/stackpanel.d index 23938ac..3549595 100644 --- a/src/dlangide/ui/stackpanel.d +++ b/src/dlangide/ui/stackpanel.d @@ -77,7 +77,7 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler { _grid.resize(2, _selectedThread.length); for (int i = 0; i < _selectedThread.length; i++) { _grid.setCellText(0, i, _selectedThread[i].func.toUTF32); - _grid.setCellText(1, i, ""d); + _grid.setCellText(1, i, _selectedThread[i].formattedAddress.toUTF32); } } else { _grid.resize(2, 1);