From 0e046207914ba111e6e2f4b30571d677f55d6d46 Mon Sep 17 00:00:00 2001 From: Haoyang Chen Date: Fri, 11 Nov 2022 09:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5gdb=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Haoyang Chen --- src/gdb.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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();