mirror of https://github.com/buggins/dlangide.git
debugger support fixes
This commit is contained in:
parent
0e390efd05
commit
18ea6395e0
|
@ -19,6 +19,7 @@ enum StateChangeReason {
|
||||||
unknown,
|
unknown,
|
||||||
breakpointHit,
|
breakpointHit,
|
||||||
endSteppingRange,
|
endSteppingRange,
|
||||||
|
exception,
|
||||||
exited,
|
exited,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ class LocationBase {
|
||||||
string file;
|
string file;
|
||||||
string fullFilePath;
|
string fullFilePath;
|
||||||
string projectFilePath;
|
string projectFilePath;
|
||||||
|
string from;
|
||||||
int line;
|
int line;
|
||||||
this() {}
|
this() {}
|
||||||
this(LocationBase v) {
|
this(LocationBase v) {
|
||||||
|
@ -33,6 +35,7 @@ class LocationBase {
|
||||||
fullFilePath = v.fullFilePath;
|
fullFilePath = v.fullFilePath;
|
||||||
projectFilePath = v.projectFilePath;
|
projectFilePath = v.projectFilePath;
|
||||||
line = v.line;
|
line = v.line;
|
||||||
|
from = v.from;
|
||||||
}
|
}
|
||||||
LocationBase clone() { return new LocationBase(this); }
|
LocationBase clone() { return new LocationBase(this); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,6 +539,9 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
|
||||||
}
|
}
|
||||||
updateState();
|
updateState();
|
||||||
_callback.onDebugState(DebuggingState.paused, StateChangeReason.breakpointHit, location, bp);
|
_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")) {
|
} else if (reason.equal("exited-normally")) {
|
||||||
_exitCode = 0;
|
_exitCode = 0;
|
||||||
Log.i("Program exited. Exit code ", _exitCode);
|
Log.i("Program exited. Exit code ", _exitCode);
|
||||||
|
|
|
@ -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 = {
|
frame = {
|
||||||
addr = "0x00000000004015b2",
|
addr = "0x00000000004015b2",
|
||||||
|
@ -73,8 +95,9 @@ DebugFrame parseFrame(MIValue frame) {
|
||||||
location.projectFilePath = toNativeDelimiters(frame.getString("file"));
|
location.projectFilePath = toNativeDelimiters(frame.getString("file"));
|
||||||
location.fullFilePath = toNativeDelimiters(frame.getString("fullname"));
|
location.fullFilePath = toNativeDelimiters(frame.getString("fullname"));
|
||||||
location.line = frame.getInt("line");
|
location.line = frame.getInt("line");
|
||||||
location.func = frame.getString("func");
|
location.func = demangleFunctionName(frame.getString("func"));
|
||||||
location.address = frame.getUlong("addr");
|
location.address = frame.getUlong("addr");
|
||||||
|
location.from = toNativeDelimiters(frame.getString("from"));
|
||||||
location.level = frame.getInt("level");
|
location.level = frame.getInt("level");
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler {
|
||||||
/// debugger is started and loaded program, you can set breakpoints at this time
|
/// debugger is started and loaded program, you can set breakpoints at this time
|
||||||
void onProgramLoaded(bool successful, bool debugInfoLoaded) {
|
void onProgramLoaded(bool successful, bool debugInfoLoaded) {
|
||||||
_ide.logPanel.logLine("Program is loaded");
|
_ide.logPanel.logLine("Program is loaded");
|
||||||
|
_ide.statusLine.setStatusText("Loaded"d);
|
||||||
switchToDebugPerspective();
|
switchToDebugPerspective();
|
||||||
// TODO: check succes status and debug info
|
// TODO: check succes status and debug info
|
||||||
if (_breakpoints.length) {
|
if (_breakpoints.length) {
|
||||||
|
@ -114,13 +115,16 @@ class DebuggerUIHandler : DebuggerCallback, StackFrameSelectedHandler {
|
||||||
_ide.statusLine.setStatusText("Stopped"d);
|
_ide.statusLine.setStatusText("Stopped"d);
|
||||||
_debugger.stop();
|
_debugger.stop();
|
||||||
} else if (state == DebuggingState.running) {
|
} else if (state == DebuggingState.running) {
|
||||||
_ide.logPanel.logLine("Program is started");
|
//_ide.logPanel.logLine("Program is started");
|
||||||
_ide.statusLine.setStatusText("Running"d);
|
_ide.statusLine.setStatusText("Running"d);
|
||||||
_ide.window.update();
|
_ide.window.update();
|
||||||
} else if (state == DebuggingState.paused) {
|
} else if (state == DebuggingState.paused) {
|
||||||
updateLocation(location);
|
updateLocation(location);
|
||||||
_ide.logPanel.logLine("Program is paused.");
|
//_ide.logPanel.logLine("Program is paused.");
|
||||||
_ide.statusLine.setStatusText("Paused"d);
|
if (reason == StateChangeReason.exception)
|
||||||
|
_ide.statusLine.setStatusText("Signal received"d);
|
||||||
|
else
|
||||||
|
_ide.statusLine.setStatusText("Paused"d);
|
||||||
_ide.window.update();
|
_ide.window.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler {
|
||||||
int _currentThreadIndex;
|
int _currentThreadIndex;
|
||||||
int _currentFrame;
|
int _currentFrame;
|
||||||
void updateDebugInfo(DebugThreadList data, ulong currentThreadId, int currentFrame) {
|
void updateDebugInfo(DebugThreadList data, ulong currentThreadId, int currentFrame) {
|
||||||
|
import std.path;
|
||||||
_debugInfo = data;
|
_debugInfo = data;
|
||||||
if (currentThreadId == 0)
|
if (currentThreadId == 0)
|
||||||
currentThreadId = data.currentThreadId;
|
currentThreadId = data.currentThreadId;
|
||||||
|
@ -76,7 +77,12 @@ class StackPanel : DockWindow, OnItemSelectedHandler, CellActivatedHandler {
|
||||||
_comboBox.selectedItemIndex = _currentThreadIndex;
|
_comboBox.selectedItemIndex = _currentThreadIndex;
|
||||||
_grid.resize(2, _selectedThread.length);
|
_grid.resize(2, _selectedThread.length);
|
||||||
for (int i = 0; i < _selectedThread.length; i++) {
|
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);
|
_grid.setCellText(1, i, _selectedThread[i].formattedAddress.toUTF32);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -886,7 +886,7 @@ class TerminalDevice : Thread {
|
||||||
DWORD bytesInMessage = 0;
|
DWORD bytesInMessage = 0;
|
||||||
// read data from client
|
// read data from client
|
||||||
//Log.d("TerminalDevice reading from pipe");
|
//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;
|
break;
|
||||||
}
|
}
|
||||||
if (closed)
|
if (closed)
|
||||||
|
@ -1009,12 +1009,12 @@ class TerminalDevice : Thread {
|
||||||
sa.nLength = sa.sizeof;
|
sa.nLength = sa.sizeof;
|
||||||
sa.bInheritHandle = TRUE;
|
sa.bInheritHandle = TRUE;
|
||||||
hpipe = CreateNamedPipeA(cast(const(char)*)_name.toStringz,
|
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_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, // | PIPE_REJECT_REMOTE_CLIENTS,
|
||||||
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // | PIPE_REJECT_REMOTE_CLIENTS,
|
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // | PIPE_REJECT_REMOTE_CLIENTS,
|
||||||
1,
|
1,
|
||||||
16384,
|
1, //16384,
|
||||||
16384,
|
1, //16384,
|
||||||
20,
|
20,
|
||||||
&sa);
|
&sa);
|
||||||
if (hpipe == INVALID_HANDLE_VALUE) {
|
if (hpipe == INVALID_HANDLE_VALUE) {
|
||||||
|
|
Loading…
Reference in New Issue