pass current state(threads, stack trace, vars) to UI

This commit is contained in:
Vadim Lopatin 2015-12-17 16:58:29 +03:00
parent 358eefa79c
commit 55301d641b
3 changed files with 25 additions and 4 deletions

View File

@ -33,6 +33,7 @@ class LocationBase {
projectFilePath = v.projectFilePath; projectFilePath = v.projectFilePath;
line = v.line; line = v.line;
} }
LocationBase clone() { return new LocationBase(this); }
} }
class DebugFrame : LocationBase { class DebugFrame : LocationBase {
@ -47,8 +48,10 @@ class DebugFrame : LocationBase {
address = v.address; address = v.address;
func = v.func; func = v.func;
level = v.level; level = v.level;
locals = new DebugVariableList(locals); if (v.locals)
locals = new DebugVariableList(v.locals);
} }
override DebugFrame clone() { return new DebugFrame(this); }
void fillMissingFields(LocationBase v) { void fillMissingFields(LocationBase v) {
if (file.empty) if (file.empty)
@ -75,7 +78,7 @@ class Breakpoint : LocationBase {
enabled = v.enabled; enabled = v.enabled;
projectName = v.projectName; projectName = v.projectName;
} }
Breakpoint clone() { override Breakpoint clone() {
return new Breakpoint(this); return new Breakpoint(this);
} }
} }
@ -92,10 +95,13 @@ class DebugThread {
this(DebugThread v) { this(DebugThread v) {
id = v.id; id = v.id;
name = v.name; name = v.name;
frame = new DebugFrame(v.frame); if (v.frame)
frame = new DebugFrame(v.frame);
state = v.state; state = v.state;
stack = new DebugStack(v.stack); if (v.stack)
stack = new DebugStack(v.stack);
} }
DebugThread clone() { return new DebugThread(this); }
@property int length() { return stack ? stack.length : 0; } @property int length() { return stack ? stack.length : 0; }
DebugFrame opIndex(int index) { return stack ? stack[index] : null; } DebugFrame opIndex(int index) { return stack ? stack[index] : null; }
@ -110,6 +116,7 @@ class DebugThreadList {
foreach(t; v.threads) foreach(t; v.threads)
threads ~= new DebugThread(t); threads ~= new DebugThread(t);
} }
DebugThreadList clone() { return new DebugThreadList(this); }
@property DebugThread currentThread() { @property DebugThread currentThread() {
return findThread(currentThreadId); return findThread(currentThreadId);
@ -196,6 +203,9 @@ interface DebuggerCallback : ProgramExecutionStatusListener {
void onDebugState(DebuggingState state, StateChangeReason reason, DebugFrame location, Breakpoint bp); void onDebugState(DebuggingState state, StateChangeReason reason, DebugFrame location, Breakpoint bp);
void onResponse(ResponseCode code, string msg); void onResponse(ResponseCode code, string msg);
/// send debug context (threads, stack frames, local vars...)
void onDebugContextInfo(DebugThreadList info);
} }
enum ResponseCode : int { enum ResponseCode : int {
@ -277,6 +287,11 @@ class DebuggerProxy : Debugger, DebuggerCallback {
_callbackDelegate( delegate() { _callback.onDebugState(state, reason, location, bp); } ); _callbackDelegate( delegate() { _callback.onDebugState(state, reason, location, bp); } );
} }
/// send debug context (threads, stack frames, local vars...)
void onDebugContextInfo(DebugThreadList info) {
_callbackDelegate( delegate() { _callback.onDebugContextInfo(info); } );
}
void onResponse(ResponseCode code, string msg) { void onResponse(ResponseCode code, string msg) {
_callbackDelegate( delegate() { _callback.onResponse(code, msg); } ); _callbackDelegate( delegate() { _callback.onResponse(code, msg); } );
} }

View File

@ -569,6 +569,7 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
if (currentThread.length > 0) { if (currentThread.length > 0) {
currentThread[0].locals = variables; currentThread[0].locals = variables;
Log.d("Setting variables for current thread top frame"); Log.d("Setting variables for current thread top frame");
_callback.onDebugContextInfo(_currentState.clone());
} }
} }
} }

View File

@ -34,6 +34,11 @@ class DebuggerUIHandler : DebuggerCallback {
//_callbackDelegate( delegate() { _callback.onProgramExecutionStatus(this, status, exitCode); } ); //_callbackDelegate( delegate() { _callback.onProgramExecutionStatus(this, status, exitCode); } );
} }
/// send debug context (threads, stack frames, local vars...)
void onDebugContextInfo(DebugThreadList info) {
Log.d("Debugger context received");
}
void onResponse(ResponseCode code, string msg) { void onResponse(ResponseCode code, string msg) {
Log.d("Debugger response: ", code, " ", msg); Log.d("Debugger response: ", code, " ", msg);
//_callbackDelegate( delegate() { _callback.onResponse(code, msg); } ); //_callbackDelegate( delegate() { _callback.onResponse(code, msg); } );