Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WAMR IDE Debugger Ignoring Launch Config #2155

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-tools/wamr-ide/VSCode-Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"displayName": "WAMR-IDE",
"description": "An Integrated Development Environment for WASM",
"version": "1.1.2",
"version": "1.2.1",
"engines": {
"vscode": "^1.59.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,33 @@ import * as vscode from 'vscode';
import * as os from 'os';

export class WasmDebugConfigurationProvider
implements vscode.DebugConfigurationProvider
{
/* default port set as 1234 */
private port = 1234;
private hostPath!: string;
private providerPromise: Thenable<vscode.DebugConfiguration> | undefined =
undefined;
implements vscode.DebugConfigurationProvider {
private wasmDebugConfig = {
type: 'wamr-debug',
name: 'Attach',
request: 'attach',
stopOnEntry: true,
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():
| Thenable<vscode.DebugConfiguration>
| undefined {
if (!this.providerPromise) {
this.providerPromise = Promise.resolve(this.wasmDebugConfig);
return this.providerPromise;
}
return this.providerPromise;
}
this.wasmDebugConfig = {
...this.wasmDebugConfig,
...debugConfiguration
};

public setDebugConfig(hostPath: string, port: number): void {
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 + '',
],
};
}
return this.wasmDebugConfig;
}

public getDebugConfig(): vscode.DebugConfiguration {
Expand Down
1 change: 0 additions & 1 deletion test-tools/wamr-ide/VSCode-Extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export async function activate(context: vscode.ExtensionContext) {

/* register debug configuration */
wasmDebugConfigProvider = new WasmDebugConfigurationProvider();
wasmDebugConfigProvider.setDebugConfig(currentPrjDir, 1234);

vscode.debug.registerDebugConfigurationProvider(
'wamr-debug',
Expand Down