mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Fix wamr-ide debugger ignoring launch config (#2155)
The `DebugConfigurationProvider` was overwriting configurations provided in `launch.json`. In particular, this for example prevented from specifying a custom port for the debugger. Example `launch.json` ``` { "configurations": [ { "type": "wamr-debug", "request": "attach", "name": "Attach Debugger", "stopOnEntry": true, "attachCommands": [ "process connect -p wasm connect://127.0.0.1:1237" ] } ] } ``` Co-authored-by: Ben Riegel <benjuri@amazon.com>
This commit is contained in:
parent
28274bed34
commit
ff0752b4ff
|
@ -6,7 +6,7 @@
|
||||||
},
|
},
|
||||||
"displayName": "WAMR-IDE",
|
"displayName": "WAMR-IDE",
|
||||||
"description": "An Integrated Development Environment for WASM",
|
"description": "An Integrated Development Environment for WASM",
|
||||||
"version": "1.1.2",
|
"version": "1.2.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.59.0"
|
"vscode": "^1.59.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,52 +7,33 @@ import * as vscode from 'vscode';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
|
||||||
export class WasmDebugConfigurationProvider
|
export class WasmDebugConfigurationProvider
|
||||||
implements vscode.DebugConfigurationProvider
|
implements vscode.DebugConfigurationProvider {
|
||||||
{
|
private wasmDebugConfig = {
|
||||||
/* default port set as 1234 */
|
type: 'wamr-debug',
|
||||||
private port = 1234;
|
name: 'Attach',
|
||||||
private hostPath!: string;
|
request: 'attach',
|
||||||
private providerPromise: Thenable<vscode.DebugConfiguration> | undefined =
|
stopOnEntry: true,
|
||||||
undefined;
|
initCommands: os.platform() === 'win32' || os.platform() === 'darwin' ?
|
||||||
|
/* linux and windows has different debug configuration */
|
||||||
|
['platform select remote-linux'] :
|
||||||
|
undefined,
|
||||||
|
attachCommands: [
|
||||||
|
/* default port 1234 */
|
||||||
|
'process connect -p wasm connect://127.0.0.1:1234',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
private wasmDebugConfig!: vscode.DebugConfiguration;
|
public resolveDebugConfiguration(
|
||||||
|
_: vscode.WorkspaceFolder | undefined,
|
||||||
|
debugConfiguration: vscode.DebugConfiguration,
|
||||||
|
): vscode.ProviderResult<vscode.DebugConfiguration> {
|
||||||
|
|
||||||
public resolveDebugConfiguration():
|
this.wasmDebugConfig = {
|
||||||
| Thenable<vscode.DebugConfiguration>
|
...this.wasmDebugConfig,
|
||||||
| undefined {
|
...debugConfiguration
|
||||||
if (!this.providerPromise) {
|
};
|
||||||
this.providerPromise = Promise.resolve(this.wasmDebugConfig);
|
|
||||||
return this.providerPromise;
|
|
||||||
}
|
|
||||||
return this.providerPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
public setDebugConfig(hostPath: string, port: number): void {
|
return this.wasmDebugConfig;
|
||||||
this.port = port;
|
|
||||||
this.hostPath = hostPath;
|
|
||||||
/* linux and windows has different debug configuration */
|
|
||||||
if (os.platform() === 'win32' || os.platform() === 'darwin') {
|
|
||||||
this.wasmDebugConfig = {
|
|
||||||
type: 'wamr-debug',
|
|
||||||
name: 'Attach',
|
|
||||||
request: 'attach',
|
|
||||||
['stopOnEntry']: true,
|
|
||||||
['initCommands']: ['platform select remote-linux'],
|
|
||||||
['attachCommands']: [
|
|
||||||
'process connect -p wasm connect://127.0.0.1:' + port + '',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
} else if (os.platform() === 'linux') {
|
|
||||||
this.wasmDebugConfig = {
|
|
||||||
type: 'wamr-debug',
|
|
||||||
name: 'Attach',
|
|
||||||
request: 'attach',
|
|
||||||
['stopOnEntry']: true,
|
|
||||||
['attachCommands']: [
|
|
||||||
'process connect -p wasm connect://127.0.0.1:' + port + '',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDebugConfig(): vscode.DebugConfiguration {
|
public getDebugConfig(): vscode.DebugConfiguration {
|
||||||
|
|
|
@ -171,7 +171,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
|
|
||||||
/* register debug configuration */
|
/* register debug configuration */
|
||||||
wasmDebugConfigProvider = new WasmDebugConfigurationProvider();
|
wasmDebugConfigProvider = new WasmDebugConfigurationProvider();
|
||||||
wasmDebugConfigProvider.setDebugConfig(currentPrjDir, 1234);
|
|
||||||
|
|
||||||
vscode.debug.registerDebugConfigurationProvider(
|
vscode.debug.registerDebugConfigurationProvider(
|
||||||
'wamr-debug',
|
'wamr-debug',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user