diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index e81adac..dd480cb 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -46,7 +46,7 @@ export class MI2 extends EventEmitter implements IBackend { if (separateConsole !== undefined) promises.push(this.sendCommand("gdb-set new-console on")) Promise.all(promises).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); } @@ -55,14 +55,14 @@ export class MI2 extends EventEmitter implements IBackend { linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => { promises.push(this.sendCommand("inferior-tty-set " + tty)); Promise.all(promises).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); }); } else { Promise.all(promises).then(() => { - this.emit("debug-ready") + this.emit("debug-ready"); resolve(); }, reject); } @@ -75,8 +75,8 @@ export class MI2 extends EventEmitter implements IBackend { this.isSSH = true; this.sshReady = false; this.sshConn = new Client(); - - if(separateConsole !== undefined) + + if (separateConsole !== undefined) this.log("stderr", "WARNING: Output to terminal emulators are not supported over SSH"); if (args.forwardX11) { @@ -286,13 +286,15 @@ export class MI2 extends EventEmitter implements IBackend { start(): Thenable { return new Promise((resolve, reject) => { - this.log("console", "Running executable"); - this.sendCommand("exec-run").then((info) => { - if (info.resultRecords.resultClass == "running") - resolve(); - else - reject(); - }, reject); + this.once("ui-break-done", () => { + this.log("console", "Running executable"); + this.sendCommand("exec-run").then((info) => { + if (info.resultRecords.resultClass == "running") + resolve(); + else + reject(); + }, reject); + }); }); } diff --git a/src/gdb.ts b/src/gdb.ts index 73bea32..b8ea735 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -181,9 +181,17 @@ class MI2DebugSession extends DebugSession { all.push(this.gdbDebugger.addBreakPoint({ file: path, line: brk.line, condition: brk.condition })); }); Promise.all(all).then(brkpoints => { + let finalBrks = []; + brkpoints.forEach(brkp => { + if (brkp[0]) + finalBrks.push({ line: brkp[1].line }); + }); response.body = { - breakpoints: brkpoints + breakpoints: finalBrks }; + setTimeout(() => { + this.gdbDebugger.emit("ui-break-done"); + }, 50); this.sendResponse(response); }); }); @@ -277,6 +285,12 @@ class MI2DebugSession extends DebugSession { variables: variables }; this.sendResponse(response); + }, err => { + this.handleMsg("stderr", "Could not expand variable\n"); + response.body = { + variables: [] + }; + this.sendResponse(response); }); } else { @@ -297,6 +311,12 @@ class MI2DebugSession extends DebugSession { variables: expanded }; this.sendResponse(response); + }, err => { + this.handleMsg("stderr", "Could not expand variable\n"); + response.body = { + variables: [] + }; + this.sendResponse(response); }); } }