检查gdb调试工具

Signed-off-by: Haoyang Chen <chenhaoyang@kylinos.cn>
This commit is contained in:
Haoyang Chen 2022-11-11 09:18:17 +08:00
parent 65a2acc2c7
commit 0e04620791
1 changed files with 13 additions and 0 deletions

View File

@ -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();