From 49c057dba8533ae72998155afb877c5d4acb631e Mon Sep 17 00:00:00 2001 From: Nicolas Berthier Date: Tue, 19 Dec 2023 13:57:27 +0100 Subject: [PATCH] Minor adaptations for integration into SuperBOL --- src/debugger.ts | 2 +- src/extension.ts | 17 +++++++++-------- src/gdb.ts | 21 ++++++++++++--------- src/mi2.ts | 2 +- src/settings.ts | 42 ++++++++---------------------------------- 5 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/debugger.ts b/src/debugger.ts index b62db68..5721bc1 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -1,5 +1,5 @@ import {MINode} from "./parser.mi2"; -import {DebugProtocol} from "vscode-debugprotocol/lib/debugProtocol"; +import {DebugProtocol} from "@vscode/debugprotocol"; import {removeLeadingZeroes} from "./functions"; import {SourceMap} from "./parser.c"; diff --git a/src/extension.ts b/src/extension.ts index c7f7dd9..6b1ff27 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -37,7 +37,7 @@ class GdbConfigurationProvider implements vscode.DebugConfigurationProvider { config.arguments = ""; } if (config.cwd === undefined) { - config.cwd = "${workspaceRoot}"; + config.cwd = "${workspaceFolder}"; } if (config.group === undefined) { config.group = []; @@ -65,37 +65,38 @@ class GdbConfigurationProvider implements vscode.DebugConfigurationProvider { _token?: vscode.CancellationToken): vscode.ProviderResult { const launchConfigDefault: vscode.DebugConfiguration = { - name: "SuperBOL: debug launch", + name: "SuperBOL: debug (launch)", type: "gdb", request: "launch", + preLaunchTask: "Superbol: build (debug)", target: "${file}", arguments: "", - cwd: "${workspaceRoot}", + cwd: "${workspaceFolder}", group: [], coverage: true, verbose: false }; const attachLocalConfiguration: vscode.DebugConfiguration = { - name: "SuperBOL: debug attach local", + name: "SuperBOL: debug (attach local)", type: "gdb", request: "attach", pid: "${input:pid}", target: "${file}", arguments: "", - cwd: "${workspaceRoot}", + cwd: "${workspaceFolder}", group: [], verbose: false }; const attachRemoteConfiguration: vscode.DebugConfiguration = { - name: "SuperBOL: debug attach remote", + name: "SuperBOL: debug (attach remote)", type: "gdb", request: "attach", - remoteDebugger: "${input:remoteDebugger}", + remoteDebugger: "${input:remote-debugger}", target: "${file}", arguments: "", - cwd: "${workspaceRoot}", + cwd: "${workspaceFolder}", group: [], verbose: false } diff --git a/src/gdb.ts b/src/gdb.ts index 52fe4e9..8c4376c 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -12,7 +12,7 @@ import { Thread, ThreadEvent } from '@vscode/debugadapter'; -import { DebugProtocol } from 'vscode-debugprotocol'; +import { DebugProtocol } from '@vscode/debugprotocol'; import { Breakpoint, VariableObject } from './debugger'; import { MINode } from './parser.mi2'; import { MI2 } from './mi2'; @@ -125,11 +125,13 @@ export class GDBDebugSession extends DebugSession { this.handlePause(undefined); }, (err: Error) => { - this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`); + this.sendErrorResponse(response, 100, + `Failed to start MI Debugger: ${err.toString()}`); }); }, /*onrejected:*/ (err: Error) => { - this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`); + this.sendErrorResponse(response, 103, + `Failed to load MI Debugger: ${err.toString()}`); }); } @@ -139,10 +141,9 @@ export class GDBDebugSession extends DebugSession { void { if (!args.pid && !args.remoteDebugger) { - this.sendErrorResponse( - response, - 100, - `Failed to start MI Debugger: pid or remoteDebugger is mandatory`); + this.sendErrorResponse (response, 100, + `Failed to start MI Debugger: PID or remote-debugger argument + required`); return; } @@ -186,11 +187,13 @@ export class GDBDebugSession extends DebugSession { this.handlePause(undefined); }, (err: Error) => { - this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`); + this.sendErrorResponse(response, 100, + `Failed to start MI Debugger: ${err.toString()}`); }); }, (err: Error) => { - this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`); + this.sendErrorResponse(response, 103, + `Failed to load MI Debugger: ${err.toString()}`); }); } diff --git a/src/mi2.ts b/src/mi2.ts index ab812ae..b2fae46 100644 --- a/src/mi2.ts +++ b/src/mi2.ts @@ -163,7 +163,7 @@ export class MI2 extends EventEmitter implements IDebugger { } const cmds = [ - this.sendCommand("gdb-set target-async on", false), + this.sendCommand("gdb-set mi-async on", false), this.sendCommand("gdb-set print repeats 1000", false), this.sendCommand("gdb-set args " + targetargs, false), this.sendCommand("environment-directory \"" + escape(cwd) + "\"", false), diff --git a/src/settings.ts b/src/settings.ts index d73217e..7aaeb84 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,50 +1,24 @@ import * as vscode from 'vscode'; -type InspectResult = { - key: string; - defaultValue?: T; - globalValue?: T; - workspaceValue?: T; - workspaceFolderValue?: T; - defaultLanguageValue?: T; - globalLanguageValue?: T; - workspaceLanguageValue?: T; - workspaceFolderLanguageValue?: T; - languageIds?: string[]; -} | undefined - export class DebuggerSettings { - private readonly extensionSettings: vscode.WorkspaceConfiguration; - private readonly superbolExtensionSettings: vscode.WorkspaceConfiguration; + private readonly debugSettings: vscode.WorkspaceConfiguration; constructor() { - this.extensionSettings = vscode.workspace.getConfiguration("superbol-vscode-debug"); -// Get SuperBOL base extension settings (for instance to get LibCob path) -// Though shouls should be obtained by querying the extension instead ? - this.superbolExtensionSettings = vscode.workspace.getConfiguration("superbol"); - } - - private getWithFallback(settings: vscode.WorkspaceConfiguration, section: string): T { - const info: InspectResult = settings.inspect(section); - if (info.workspaceFolderValue !== undefined) { - return info.workspaceFolderValue; - } else if (info.workspaceValue !== undefined) { - return info.workspaceValue; - } else if (info.globalValue !== undefined) { - return info.globalValue; - } - return info.defaultValue; + this.debugSettings = + vscode.workspace.getConfiguration("superbol.debugger"); + //this.globalSettings = + // vscode.workspace.getConfiguration("superbol"); } public get displayVariableAttributes(): boolean { - return this.getWithFallback(this.extensionSettings, "displayVariableAttributes"); + return this.debugSettings.get ("display-variable-attributes"); } public get gdbpath(): string { - return this.getWithFallback(this.extensionSettings, "pathToGDB"); + return this.debugSettings.get ("gdb-path"); } public get libcobpath(): string { - return this.getWithFallback(this.extensionSettings, "pathToLibCob"); + return this.debugSettings.get ("libcob-path"); } }