Skip to content

Commit ff0752b

Browse files
authored
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 <[email protected]>
1 parent 28274be commit ff0752b

File tree

3 files changed

+25
-45
lines changed

3 files changed

+25
-45
lines changed

test-tools/wamr-ide/VSCode-Extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"displayName": "WAMR-IDE",
88
"description": "An Integrated Development Environment for WASM",
9-
"version": "1.1.2",
9+
"version": "1.2.1",
1010
"engines": {
1111
"vscode": "^1.59.0"
1212
},

test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,33 @@ import * as vscode from 'vscode';
77
import * as os from 'os';
88

99
export class WasmDebugConfigurationProvider
10-
implements vscode.DebugConfigurationProvider
11-
{
12-
/* default port set as 1234 */
13-
private port = 1234;
14-
private hostPath!: string;
15-
private providerPromise: Thenable<vscode.DebugConfiguration> | undefined =
16-
undefined;
10+
implements vscode.DebugConfigurationProvider {
11+
private wasmDebugConfig = {
12+
type: 'wamr-debug',
13+
name: 'Attach',
14+
request: 'attach',
15+
stopOnEntry: true,
16+
initCommands: os.platform() === 'win32' || os.platform() === 'darwin' ?
17+
/* linux and windows has different debug configuration */
18+
['platform select remote-linux'] :
19+
undefined,
20+
attachCommands: [
21+
/* default port 1234 */
22+
'process connect -p wasm connect://127.0.0.1:1234',
23+
]
24+
};
1725

18-
private wasmDebugConfig!: vscode.DebugConfiguration;
26+
public resolveDebugConfiguration(
27+
_: vscode.WorkspaceFolder | undefined,
28+
debugConfiguration: vscode.DebugConfiguration,
29+
): vscode.ProviderResult<vscode.DebugConfiguration> {
1930

20-
public resolveDebugConfiguration():
21-
| Thenable<vscode.DebugConfiguration>
22-
| undefined {
23-
if (!this.providerPromise) {
24-
this.providerPromise = Promise.resolve(this.wasmDebugConfig);
25-
return this.providerPromise;
26-
}
27-
return this.providerPromise;
28-
}
31+
this.wasmDebugConfig = {
32+
...this.wasmDebugConfig,
33+
...debugConfiguration
34+
};
2935

30-
public setDebugConfig(hostPath: string, port: number): void {
31-
this.port = port;
32-
this.hostPath = hostPath;
33-
/* linux and windows has different debug configuration */
34-
if (os.platform() === 'win32' || os.platform() === 'darwin') {
35-
this.wasmDebugConfig = {
36-
type: 'wamr-debug',
37-
name: 'Attach',
38-
request: 'attach',
39-
['stopOnEntry']: true,
40-
['initCommands']: ['platform select remote-linux'],
41-
['attachCommands']: [
42-
'process connect -p wasm connect://127.0.0.1:' + port + '',
43-
],
44-
};
45-
} else if (os.platform() === 'linux') {
46-
this.wasmDebugConfig = {
47-
type: 'wamr-debug',
48-
name: 'Attach',
49-
request: 'attach',
50-
['stopOnEntry']: true,
51-
['attachCommands']: [
52-
'process connect -p wasm connect://127.0.0.1:' + port + '',
53-
],
54-
};
55-
}
36+
return this.wasmDebugConfig;
5637
}
5738

5839
public getDebugConfig(): vscode.DebugConfiguration {

test-tools/wamr-ide/VSCode-Extension/src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export async function activate(context: vscode.ExtensionContext) {
171171

172172
/* register debug configuration */
173173
wasmDebugConfigProvider = new WasmDebugConfigurationProvider();
174-
wasmDebugConfigProvider.setDebugConfig(currentPrjDir, 1234);
175174

176175
vscode.debug.registerDebugConfigurationProvider(
177176
'wamr-debug',

0 commit comments

Comments
 (0)