diff --git a/src/gdb.ts b/src/gdb.ts index dddda76..d9e6752 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -4,6 +4,7 @@ import { DebugProtocol } from 'vscode-debugprotocol'; import { MI2, escape } from "./backend/mi2/mi2"; import { SSHArguments, ValuesFormattingMode } from './backend/backend'; import { GdbDisassembler } from './backend/disasm'; +import * as child_process from 'child_process'; export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments { cwd: string; @@ -70,6 +71,12 @@ export class GDBDebugSession extends MI2DebugSession { } protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void { + const check_gdb = child_process.exec(`which ${args.gdbpath || "gdb"}`, (e,x,stderr)=>{ + if (e || !x || x.length == 0) { + this.sendErrorResponse(response, 104, `No ${args.gdbpath || "gdb"} found, please install it.`); + return + } + }) this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env); this.args = args; this.disassember = new GdbDisassembler(this, args.showDevDebugOutput); @@ -121,6 +128,12 @@ export class GDBDebugSession extends MI2DebugSession { } protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void { + const check_gdb = child_process.exec(`which ${args.gdbpath || "gdb"}`, (e,x,stderr)=>{ + if (e || !x || x.length == 0) { + this.sendErrorResponse(response, 104, `No ${args.gdbpath || "gdb"} found, please install it.`); + return + } + }) this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env); this.setPathSubstitutions(args.pathSubstitutions); this.initDebugger();