Merge branch 'master' of github.com:buggins/dlangide

This commit is contained in:
Vadim Lopatin 2016-06-28 14:35:41 +03:00
commit 25506648cf
2 changed files with 29 additions and 11 deletions

View File

@ -227,7 +227,8 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
debuggerArgs ~= externalTerminalTty; debuggerArgs ~= externalTerminalTty;
} }
} }
debuggerArgs ~= "--interpreter=mi"; debuggerArgs ~= "--interpreter";
debuggerArgs ~= "mi2";
debuggerArgs ~= "--silent"; debuggerArgs ~= "--silent";
if (!USE_INIT_SEQUENCE) { if (!USE_INIT_SEQUENCE) {
debuggerArgs ~= "--args"; debuggerArgs ~= "--args";
@ -503,6 +504,8 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
Log.d("GDB internal debug message: ", s); Log.d("GDB internal debug message: ", s);
} }
long _stoppedThreadId = 0;
// *stopped,reason="exited-normally" // *stopped,reason="exited-normally"
// *running,thread-id="all" // *running,thread-id="all"
// *asyncclass,result // *asyncclass,result
@ -524,12 +527,14 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
StateChangeReason reasonId = StateChangeReason.unknown; StateChangeReason reasonId = StateChangeReason.unknown;
DebugFrame location = parseFrame(params["frame"]); DebugFrame location = parseFrame(params["frame"]);
string threadId = params.getString("thread-id"); string threadId = params.getString("thread-id");
_stoppedThreadId = params.getUlong("thread-id", 0);
string stoppedThreads = params.getString("all"); string stoppedThreads = params.getString("all");
Breakpoint bp = null; Breakpoint bp = null;
if (reason.equal("end-stepping-range")) { if (reason.equal("end-stepping-range")) {
updateState(); updateState();
_callback.onDebugState(DebuggingState.paused, StateChangeReason.endSteppingRange, location, bp); _callback.onDebugState(DebuggingState.paused, StateChangeReason.endSteppingRange, location, bp);
} else if (reason.equal("breakpoint-hit")) { } else if (reason.equal("breakpoint-hit")) {
Log.v("handling breakpoint-hit");
if (GDBBreakpoint gdbbp = findBreakpointByNumber(params.getString("bkptno"))) { if (GDBBreakpoint gdbbp = findBreakpointByNumber(params.getString("bkptno"))) {
bp = gdbbp.bp; bp = gdbbp.bp;
if (!location && bp) { if (!location && bp) {
@ -537,9 +542,11 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
location.fillMissingFields(bp); location.fillMissingFields(bp);
} }
} }
//_requests.targetIsReady();
updateState(); updateState();
_callback.onDebugState(DebuggingState.paused, StateChangeReason.breakpointHit, location, bp); _callback.onDebugState(DebuggingState.paused, StateChangeReason.breakpointHit, location, bp);
} else if (reason.equal("signal-received")) { } else if (reason.equal("signal-received")) {
//_requests.targetIsReady();
updateState(); updateState();
_callback.onDebugState(DebuggingState.paused, StateChangeReason.exception, location, bp); _callback.onDebugState(DebuggingState.paused, StateChangeReason.exception, location, bp);
} else if (reason.equal("exited-normally")) { } else if (reason.equal("exited-normally")) {
@ -560,6 +567,8 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
_exitCode = -1; _exitCode = -1;
_callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null); _callback.onDebugState(DebuggingState.stopped, StateChangeReason.exited, null, null);
} }
} else {
Log.e("unknown async type `", msgType, "`");
} }
} }
@ -692,7 +701,7 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
submitRequest(new GDBInitRequest("-inferior-tty-set " ~ quotePathIfNeeded(externalTerminalTty), true)); submitRequest(new GDBInitRequest("-inferior-tty-set " ~ quotePathIfNeeded(externalTerminalTty), true));
submitRequest(new GDBInitRequest("-gdb-set breakpoint pending on", false)); submitRequest(new GDBInitRequest("-gdb-set breakpoint pending on", false));
submitRequest(new GDBInitRequest("-enable-pretty-printing", false)); //submitRequest(new GDBInitRequest("-enable-pretty-printing", false));
submitRequest(new GDBInitRequest("-gdb-set print object on", false)); submitRequest(new GDBInitRequest("-gdb-set print object on", false));
submitRequest(new GDBInitRequest("-gdb-set print sevenbit-strings on", false)); submitRequest(new GDBInitRequest("-gdb-set print sevenbit-strings on", false));
submitRequest(new GDBInitRequest("-gdb-set host-charset UTF-8", false)); submitRequest(new GDBInitRequest("-gdb-set host-charset UTF-8", false));
@ -728,9 +737,11 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
this() { command = "-thread-info"; } this() { command = "-thread-info"; }
override void onResult() { override void onResult() {
_currentState = parseThreadList(params); _currentState = parseThreadList(params);
if (_currentState) { if (_currentState) {
// TODO // TODO
Log.d("Thread list is parsed"); Log.d("Thread list is parsed");
if (!_currentState.currentThreadId)
_currentState.currentThreadId = _stoppedThreadId;
submitRequest(new StackListFramesRequest(_currentState.currentThreadId, 0)); submitRequest(new StackListFramesRequest(_currentState.currentThreadId, 0));
} }
} }
@ -768,7 +779,8 @@ class GDBInterface : ConsoleDebuggerInterface, TextCommandTarget {
this(ulong threadId, int frameId) { this(ulong threadId, int frameId) {
_threadId = threadId; _threadId = threadId;
_frameId = frameId; _frameId = frameId;
command = "-stack-list-variables --thread " ~ to!string(_threadId) ~ " --frame " ~ to!string(_frameId) ~ " --simple-values"; //command = "-stack-list-variables --thread " ~ to!string(_threadId) ~ " --frame " ~ to!string(_frameId) ~ " --simple-values";
command = "-stack-list-locals --thread " ~ to!string(_threadId) ~ " --frame " ~ to!string(_frameId) ~ " 1";
} }
override void onResult() { override void onResult() {
DebugVariableList variables = parseVariableList(params); DebugVariableList variables = parseVariableList(params);

View File

@ -54,16 +54,22 @@ MIValue parseMI(string s) {
} }
} }
string demangleFunctionName(string fn) { string demangleFunctionName(string mangledName) {
if (!fn) import std.ascii;
return fn; if (!mangledName)
if (!fn.startsWith("_D")) return mangledName;
return fn; string fn = mangledName;
if (!fn.startsWith("_D")) {
// trying to fix strange corrupted mangling under OSX/dmd/lldb
if (fn.length < 3 || fn[0]!='D' || !isDigit(fn[1]))
return mangledName;
fn = "_" ~ mangledName;
}
import std.demangle; import std.demangle;
import std.ascii; import std.ascii;
//import core.demangle : Demangle; //import core.demangle : Demangle;
uint i = 0; uint i = 0;
for(; fn[i] == '_' || isAlphaNum(fn[i]); i++) { for(; i < fn.length && (fn[i] == '_' || isAlphaNum(fn[i])); i++) {
// next // next
} }
string rest = i < fn.length ? fn[i .. $] : null; string rest = i < fn.length ? fn[i .. $] : null;
@ -72,7 +78,7 @@ string demangleFunctionName(string fn) {
} catch (Exception e) { } catch (Exception e) {
// cannot demangle // cannot demangle
Log.v("Failed to demangle " ~ fn[0..i]); Log.v("Failed to demangle " ~ fn[0..i]);
return fn; return mangledName;
} }
} }