From 656ef0d2c0c7d111215f20ac50336d8ea9349e80 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 14 Apr 2017 18:11:36 +0200 Subject: [PATCH] Fix #102 --- src/backend/mi2/mi2.ts | 3 +++ src/backend/mi2/mi2lldb.ts | 1 + src/mibase.ts | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index 5f340bb..a7f004a 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -41,6 +41,7 @@ export class MI2 extends EventEmitter implements IBackend { this.process.stdout.on("data", this.stdout.bind(this)); this.process.stderr.on("data", this.stderr.bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); + this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this)); let promises = this.initCommands(target, cwd); if (procArgs && procArgs.length) promises.push(this.sendCommand("exec-arguments " + procArgs)); @@ -196,6 +197,7 @@ export class MI2 extends EventEmitter implements IBackend { this.process.stdout.on("data", this.stdout.bind(this)); this.process.stderr.on("data", this.stderr.bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); + this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this)); var commands = [ this.sendCommand("gdb-set target-async on"), this.sendCommand("environment-directory \"" + escape(cwd) + "\"") @@ -224,6 +226,7 @@ export class MI2 extends EventEmitter implements IBackend { this.process.stdout.on("data", this.stdout.bind(this)); this.process.stderr.on("data", this.stderr.bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); + this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this)); Promise.all([ this.sendCommand("gdb-set target-async on"), this.sendCommand("environment-directory \"" + escape(cwd) + "\""), diff --git a/src/backend/mi2/mi2lldb.ts b/src/backend/mi2/mi2lldb.ts index 6cb5263..cb75269 100644 --- a/src/backend/mi2/mi2lldb.ts +++ b/src/backend/mi2/mi2lldb.ts @@ -29,6 +29,7 @@ export class MI2_LLDB extends MI2 { this.process.stdout.on("data", this.stdout.bind(this)); this.process.stderr.on("data", this.stderr.bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); + this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this)); Promise.all([ this.sendCommand("gdb-set target-async on"), this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""), diff --git a/src/mibase.ts b/src/mibase.ts index 5f53c9a..03819ea 100644 --- a/src/mibase.ts +++ b/src/mibase.ts @@ -39,6 +39,7 @@ export class MI2DebugSession extends DebugSession { } protected initDebugger() { + this.miDebugger.on("launcherror", this.launchError.bind(this)); this.miDebugger.on("quit", this.quitEvent.bind(this)); this.miDebugger.on("exited-normally", this.quitEvent.bind(this)); this.miDebugger.on("stopped", this.stopEvent.bind(this)); @@ -109,6 +110,12 @@ export class MI2DebugSession extends DebugSession { this.sendEvent(new TerminatedEvent()); } + protected launchError(err: any) { + this.handleMsg("stderr", "Could not start debugger process, does the program exist in filesystem?\n"); + this.handleMsg("stderr", err.toString() + "\n"); + this.quitEvent(); + } + protected disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments): void { if (this.attached) this.miDebugger.detach();