mirror of https://github.com/buggins/dlangide.git
show stack trace in Stack window
This commit is contained in:
parent
366891879a
commit
87ca1f8ddd
|
@ -36,6 +36,24 @@ class LocationBase {
|
||||||
LocationBase clone() { return new LocationBase(this); }
|
LocationBase clone() { return new LocationBase(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Breakpoint : LocationBase {
|
||||||
|
int id;
|
||||||
|
bool enabled = true;
|
||||||
|
string projectName;
|
||||||
|
this() {
|
||||||
|
id = _nextBreakpointId++;
|
||||||
|
}
|
||||||
|
this(Breakpoint v) {
|
||||||
|
super(v);
|
||||||
|
id = v.id;
|
||||||
|
enabled = v.enabled;
|
||||||
|
projectName = v.projectName;
|
||||||
|
}
|
||||||
|
override Breakpoint clone() {
|
||||||
|
return new Breakpoint(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DebugFrame : LocationBase {
|
class DebugFrame : LocationBase {
|
||||||
ulong address;
|
ulong address;
|
||||||
string func;
|
string func;
|
||||||
|
@ -65,24 +83,6 @@ class DebugFrame : LocationBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Breakpoint : LocationBase {
|
|
||||||
int id;
|
|
||||||
bool enabled = true;
|
|
||||||
string projectName;
|
|
||||||
this() {
|
|
||||||
id = _nextBreakpointId++;
|
|
||||||
}
|
|
||||||
this(Breakpoint v) {
|
|
||||||
super(v);
|
|
||||||
id = v.id;
|
|
||||||
enabled = v.enabled;
|
|
||||||
projectName = v.projectName;
|
|
||||||
}
|
|
||||||
override Breakpoint clone() {
|
|
||||||
return new Breakpoint(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DebugThread {
|
class DebugThread {
|
||||||
ulong id;
|
ulong id;
|
||||||
string name;
|
string name;
|
||||||
|
@ -103,8 +103,22 @@ class DebugThread {
|
||||||
}
|
}
|
||||||
DebugThread clone() { return new DebugThread(this); }
|
DebugThread clone() { return new DebugThread(this); }
|
||||||
|
|
||||||
@property int length() { return stack ? stack.length : 0; }
|
@property int length() {
|
||||||
DebugFrame opIndex(int index) { return stack ? stack[index] : null; }
|
if (stack && stack.length > 0)
|
||||||
|
return stack.length;
|
||||||
|
if (frame)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DebugFrame opIndex(int index) {
|
||||||
|
if (index < 0 || index > length)
|
||||||
|
return null;
|
||||||
|
if (stack && stack.length > 0)
|
||||||
|
return stack[index];
|
||||||
|
if (frame && index == 0)
|
||||||
|
return frame;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DebugThreadList {
|
class DebugThreadList {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import std.utf;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.array : empty;
|
import std.array : empty;
|
||||||
import std.algorithm : startsWith, equal;
|
import std.algorithm : startsWith, equal;
|
||||||
|
import std.string : format;
|
||||||
import ddebug.common.debugger;
|
import ddebug.common.debugger;
|
||||||
|
|
||||||
/// result class
|
/// result class
|
||||||
|
@ -123,6 +124,8 @@ DebugThread parseThread(MIValue params) {
|
||||||
DebugThread res = new DebugThread();
|
DebugThread res = new DebugThread();
|
||||||
res.id = params.getUlong("id");
|
res.id = params.getUlong("id");
|
||||||
res.name = params.getString("target-id");
|
res.name = params.getString("target-id");
|
||||||
|
if (res.name.empty)
|
||||||
|
res.name = "Thread%d".format(res.id);
|
||||||
string stateName = params.getString("state");
|
string stateName = params.getString("state");
|
||||||
if (stateName == "stopped")
|
if (stateName == "stopped")
|
||||||
res.state = DebuggingState.paused;
|
res.state = DebuggingState.paused;
|
||||||
|
|
|
@ -14,10 +14,13 @@ import ddebug.common.execution;
|
||||||
import ddebug.common.debugger;
|
import ddebug.common.debugger;
|
||||||
|
|
||||||
class DebuggerUIHandler : DebuggerCallback {
|
class DebuggerUIHandler : DebuggerCallback {
|
||||||
IDEFrame _ide;
|
|
||||||
Debugger _debugger;
|
private IDEFrame _ide;
|
||||||
DebuggingState _state = DebuggingState.loaded;
|
private Debugger _debugger;
|
||||||
DebugFrame _location;
|
private DebuggingState _state = DebuggingState.loaded;
|
||||||
|
private DebugFrame _location;
|
||||||
|
private WatchPanel _watchPanel;
|
||||||
|
private StackPanel _stackPanel;
|
||||||
|
|
||||||
this(IDEFrame ide, Debugger debugger) {
|
this(IDEFrame ide, Debugger debugger) {
|
||||||
_ide = ide;
|
_ide = ide;
|
||||||
|
@ -37,6 +40,8 @@ class DebuggerUIHandler : DebuggerCallback {
|
||||||
/// send debug context (threads, stack frames, local vars...)
|
/// send debug context (threads, stack frames, local vars...)
|
||||||
void onDebugContextInfo(DebugThreadList info) {
|
void onDebugContextInfo(DebugThreadList info) {
|
||||||
Log.d("Debugger context received");
|
Log.d("Debugger context received");
|
||||||
|
_stackPanel.updateDebugInfo(info, info.currentThreadId, 0);
|
||||||
|
_watchPanel.updateDebugInfo(info, info.currentThreadId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResponse(ResponseCode code, string msg) {
|
void onResponse(ResponseCode code, string msg) {
|
||||||
|
@ -172,8 +177,6 @@ class DebuggerUIHandler : DebuggerCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private WatchPanel _watchPanel;
|
|
||||||
private StackPanel _stackPanel;
|
|
||||||
|
|
||||||
void switchToDebugPerspective() {
|
void switchToDebugPerspective() {
|
||||||
_ide.dockHost.layoutPriority = [DockAlignment.Bottom, DockAlignment.Top, DockAlignment.Left, DockAlignment.Right];
|
_ide.dockHost.layoutPriority = [DockAlignment.Bottom, DockAlignment.Top, DockAlignment.Left, DockAlignment.Right];
|
||||||
|
|
|
@ -2,6 +2,9 @@ module dlangide.ui.stackpanel;
|
||||||
|
|
||||||
import dlangui;
|
import dlangui;
|
||||||
|
|
||||||
|
import std.string : format;
|
||||||
|
import ddebug.common.debugger;
|
||||||
|
|
||||||
class StackPanel : DockWindow {
|
class StackPanel : DockWindow {
|
||||||
|
|
||||||
this(string id) {
|
this(string id) {
|
||||||
|
@ -10,26 +13,75 @@ class StackPanel : DockWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected Widget createBodyWidget() {
|
override protected Widget createBodyWidget() {
|
||||||
|
layoutWidth = FILL_PARENT;
|
||||||
|
layoutHeight = FILL_PARENT;
|
||||||
VerticalLayout root = new VerticalLayout();
|
VerticalLayout root = new VerticalLayout();
|
||||||
root.layoutWeight = FILL_PARENT;
|
root.layoutWidth = FILL_PARENT;
|
||||||
root.layoutHeight = FILL_PARENT;
|
root.layoutHeight = FILL_PARENT;
|
||||||
ComboBox comboBox = new ComboBox("threadComboBox", ["Thread1"d]);
|
_comboBox = new ComboBox("threadComboBox", ["Thread1"d]);
|
||||||
comboBox.layoutWidth = FILL_PARENT;
|
_comboBox.layoutWidth = FILL_PARENT;
|
||||||
comboBox.selectedItemIndex = 0;
|
_comboBox.selectedItemIndex = 0;
|
||||||
StringGridWidget grid = new StringGridWidget("stackGrid");
|
_grid = new StringGridWidget("stackGrid");
|
||||||
grid.resize(2, 20);
|
_grid.resize(2, 20);
|
||||||
grid.showColHeaders = true;
|
_grid.showColHeaders = true;
|
||||||
grid.showRowHeaders = false;
|
_grid.showRowHeaders = false;
|
||||||
grid.layoutHeight = FILL_PARENT;
|
_grid.layoutHeight = FILL_PARENT;
|
||||||
grid.layoutWidth = FILL_PARENT;
|
_grid.layoutWidth = FILL_PARENT;
|
||||||
grid.setColTitle(0, "Function"d);
|
_grid.setColTitle(0, "Function"d);
|
||||||
grid.setColTitle(1, "Address"d);
|
_grid.setColTitle(1, "Address"d);
|
||||||
grid.setCellText(0, 0, "main()"d);
|
_grid.setCellText(0, 0, "main()"d);
|
||||||
root.addChild(comboBox);
|
_grid.layoutWidth = FILL_PARENT;
|
||||||
root.addChild(grid);
|
_grid.layoutHeight = FILL_PARENT;
|
||||||
|
root.addChild(_comboBox);
|
||||||
|
root.addChild(_grid);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringGridWidget _grid;
|
||||||
|
ComboBox _comboBox;
|
||||||
|
DebugThreadList _debugInfo;
|
||||||
|
DebugThread _selectedThread;
|
||||||
|
ulong _currentThreadId;
|
||||||
|
int _currentThreadIndex;
|
||||||
|
int _currentFrame;
|
||||||
|
void updateDebugInfo(DebugThreadList data, ulong currentThreadId, int currentFrame) {
|
||||||
|
_debugInfo = data;
|
||||||
|
if (currentThreadId == 0)
|
||||||
|
currentThreadId = data.currentThreadId;
|
||||||
|
_currentThreadId = currentThreadId;
|
||||||
|
_currentThreadIndex = -1;
|
||||||
|
_currentFrame = 0;
|
||||||
|
_selectedThread = null;
|
||||||
|
if (_debugInfo) {
|
||||||
|
_comboBox.enabled = true;
|
||||||
|
dstring[] threadNames;
|
||||||
|
for (int i = 0; i < _debugInfo.length; i++) {
|
||||||
|
threadNames ~= _debugInfo[i].name.toUTF32;
|
||||||
|
if (_debugInfo[i].id == _currentThreadId) {
|
||||||
|
_currentThreadIndex = i;
|
||||||
|
_selectedThread = _debugInfo[i];
|
||||||
|
if (currentFrame <= _selectedThread.length)
|
||||||
|
_currentFrame = currentFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_comboBox.items = threadNames;
|
||||||
|
if (_currentThreadIndex >= 0 && _selectedThread.length > 0) {
|
||||||
|
_comboBox.selectedItemIndex = _currentThreadIndex;
|
||||||
|
_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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_grid.resize(2, 1);
|
||||||
|
_grid.setCellText(0, 0, "No info"d);
|
||||||
|
_grid.setCellText(1, 0, ""d);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_comboBox.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void onPopupMenuItem(MenuItem item) {
|
protected void onPopupMenuItem(MenuItem item) {
|
||||||
if (item.action)
|
if (item.action)
|
||||||
handleAction(item.action);
|
handleAction(item.action);
|
||||||
|
|
|
@ -2,6 +2,9 @@ module dlangide.ui.watchpanel;
|
||||||
|
|
||||||
import dlangui;
|
import dlangui;
|
||||||
|
|
||||||
|
import std.string : format;
|
||||||
|
import ddebug.common.debugger;
|
||||||
|
|
||||||
class VariablesWindow : StringGridWidget {
|
class VariablesWindow : StringGridWidget {
|
||||||
this(string ID = null) {
|
this(string ID = null) {
|
||||||
super(ID);
|
super(ID);
|
||||||
|
@ -67,5 +70,36 @@ class WatchPanel : DockWindow {
|
||||||
override bool handleAction(const Action a) {
|
override bool handleAction(const Action a) {
|
||||||
return super.handleAction(a);
|
return super.handleAction(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugThreadList _debugInfo;
|
||||||
|
DebugThread _selectedThread;
|
||||||
|
DebugFrame _frame;
|
||||||
|
ulong _currentThreadId;
|
||||||
|
int _currentThreadIndex;
|
||||||
|
int _currentFrame;
|
||||||
|
void updateDebugInfo(DebugThreadList data, ulong currentThreadId, int currentFrame) {
|
||||||
|
_debugInfo = data;
|
||||||
|
if (currentThreadId == 0)
|
||||||
|
currentThreadId = data.currentThreadId;
|
||||||
|
_currentThreadId = currentThreadId;
|
||||||
|
_currentThreadIndex = -1;
|
||||||
|
_currentFrame = 0;
|
||||||
|
_selectedThread = null;
|
||||||
|
_frame = null;
|
||||||
|
|
||||||
|
if (_debugInfo) {
|
||||||
|
for (int i = 0; i < _debugInfo.length; i++) {
|
||||||
|
if (_debugInfo[i].id == _currentThreadId) {
|
||||||
|
_currentThreadIndex = i;
|
||||||
|
_selectedThread = _debugInfo[i];
|
||||||
|
if (currentFrame <= _selectedThread.length) {
|
||||||
|
_currentFrame = currentFrame;
|
||||||
|
_frame = _selectedThread[_currentFrame];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue