diff --git a/src/ddebug/common/debugger.d b/src/ddebug/common/debugger.d index ba45702..458372f 100644 --- a/src/ddebug/common/debugger.d +++ b/src/ddebug/common/debugger.d @@ -19,6 +19,7 @@ enum StateChangeReason { unknown, breakpointHit, endSteppingRange, + exception, exited, } @@ -26,6 +27,7 @@ class LocationBase { string file; string fullFilePath; string projectFilePath; + string from; int line; this() {} this(LocationBase v) { @@ -33,6 +35,7 @@ class LocationBase { fullFilePath = v.fullFilePath; projectFilePath = v.projectFilePath; line = v.line; + from = v.from; } LocationBase clone() { return new LocationBase(this); } } diff --git a/src/ddebug/gdb/gdbinterface.d b/src/ddebug/gdb/gdbinterface.d index f24f810..cf4ecf2 100644 --- a/src/ddebug/gdb/gdbinterface.d +++ b/src/ddebug/gdb/gdbinterface.d @@ -539,6 +539,9 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget { } updateState(); _callback.onDebugState(DebuggingState.paused, StateChangeReason.breakpointHit, location, bp); + } else if (reason.equal("signal-received")) { + updateState(); + _callback.onDebugState(DebuggingState.paused, StateChangeReason.exception, location, bp); } else if (reason.equal("exited-normally")) { _exitCode = 0; Log.i("Program exited. Exit code ", _exitCode); diff --git a/src/ddebug/gdb/gdbmiparser.d b/src/ddebug/gdb/gdbmiparser.d index 6663684..d77570c 100644 --- a/src/ddebug/gdb/gdbmiparser.d +++ b/src/ddebug/gdb/gdbmiparser.d @@ -54,6 +54,28 @@ MIValue parseMI(string s) { } } +string demangleFunctionName(string fn) { + if (!fn) + return fn; + if (!fn.startsWith("_D")) + return fn; + import std.demangle; + import std.ascii; + //import core.demangle : Demangle; + uint i = 0; + for(; fn[i] == '_' || isAlphaNum(fn[i]); i++) { + // next + } + string rest = i < fn.length ? fn[i .. $] : null; + try { + return demangle(fn[0..i]) ~ rest; + } catch (Exception e) { + // cannot demangle + Log.v("Failed to demangle " ~ fn[0..i]); + return fn; + } +} + /* frame = { addr = "0x00000000004015b2", @@ -73,8 +95,9 @@ DebugFrame parseFrame(MIValue frame) { location.projectFilePath = toNativeDelimiters(frame.getString("file")); location.fullFilePath = toNativeDelimiters(frame.getString("fullname")); location.line = frame.getInt("line"); - location.func = frame.getString("func"); + location.func = demangleFunctionName(frame.getString("func")); location.address = frame.getUlong("addr"); + location.from = toNativeDelimiters(frame.getString("from")); location.level = frame.getInt("level"); return location; } diff --git a/src/dlangide/ui/debuggerui.d b/src/dlangide/ui/debuggerui.d index 6124936..3978da7 100644 --- a/src/dlangide/ui/debuggerui.d +++ b/src/dlangide/ui/debuggerui.d @@ -71,6 +71,7 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler { /// debugger is started and loaded program, you can set breakpoints at this time void onProgramLoaded(bool successful, bool debugInfoLoaded) { _ide.logPanel.logLine("Program is loaded"); + _ide.statusLine.setStatusText("Loaded"d); switchToDebugPerspective(); // TODO: check succes status and debug info if (_breakpoints.length) { @@ -114,13 +115,16 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler { _ide.statusLine.setStatusText("Stopped"d); _debugger.stop(); } else if (state == DebuggingState.running) { - _ide.logPanel.logLine("Program is started"); + //_ide.logPanel.logLine("Program is started"); _ide.statusLine.setStatusText("Running"d); _ide.window.update(); } else if (state == DebuggingState.paused) { updateLocation(location); - _ide.logPanel.logLine("Program is paused."); - _ide.statusLine.setStatusText("Paused"d); + //_ide.logPanel.logLine("Program is paused."); + if (reason == StateChangeReason.exception) + _ide.statusLine.setStatusText("Signal received"d); + else + _ide.statusLine.setStatusText("Paused"d); _ide.window.update(); } } diff --git a/src/dlangide/ui/stackpanel.d b/src/dlangide/ui/stackpanel.d index 87af78d..c1550d1 100644 --- a/src/dlangide/ui/stackpanel.d +++ b/src/dlangide/ui/stackpanel.d @@ -52,6 +52,7 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler { int _currentThreadIndex; int _currentFrame; void updateDebugInfo(DebugThreadList data, ulong currentThreadId, int currentFrame) { + import std.path; _debugInfo = data; if (currentThreadId == 0) currentThreadId = data.currentThreadId; @@ -76,7 +77,12 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler { _comboBox.selectedItemIndex = _currentThreadIndex; _grid.resize(2, _selectedThread.length); for (int i = 0; i < _selectedThread.length; i++) { - _grid.setCellText(0, i, _selectedThread[i].func.toUTF32); + if (_selectedThread[i].func) + _grid.setCellText(0, i, _selectedThread[i].func.toUTF32); + else if (_selectedThread[i].from) + _grid.setCellText(0, i, baseName(_selectedThread[i].from.toUTF32)); + else + _grid.setCellText(0, i, _selectedThread[i].file.toUTF32); _grid.setCellText(1, i, _selectedThread[i].formattedAddress.toUTF32); } } else { diff --git a/src/dlangide/ui/terminal.d b/src/dlangide/ui/terminal.d index 43c4a69..5b367bf 100644 --- a/src/dlangide/ui/terminal.d +++ b/src/dlangide/ui/terminal.d @@ -886,7 +886,7 @@ class TerminalDevice : Thread { DWORD bytesInMessage = 0; // read data from client //Log.d("TerminalDevice reading from pipe"); - if (!PeekNamedPipe(hpipe, buf.ptr, cast(DWORD)buf.length, &bytesRead, &bytesAvail, &bytesInMessage)) { + if (!PeekNamedPipe(hpipe, buf.ptr, cast(DWORD)1 /*buf.length*/, &bytesRead, &bytesAvail, &bytesInMessage)) { break; } if (closed) @@ -1009,12 +1009,12 @@ class TerminalDevice : Thread { sa.nLength = sa.sizeof; sa.bInheritHandle = TRUE; hpipe = CreateNamedPipeA(cast(const(char)*)_name.toStringz, - PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, // dwOpenMode + PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_FIRST_PIPE_INSTANCE, // dwOpenMode //PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, // | PIPE_REJECT_REMOTE_CLIENTS, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // | PIPE_REJECT_REMOTE_CLIENTS, 1, - 16384, - 16384, + 1, //16384, + 1, //16384, 20, &sa); if (hpipe == INVALID_HANDLE_VALUE) {