Add Rust Formatters to Debugger (Vector, Map etc.) (#2219)

This PR adds LLDB formatters so that variables are human-readable when debugging
Rust code in VS Code. This includes Tuple, Slice, String, Vector, Map, Enum etc.

It also distributes a standalone Python version with LLDB. This solution enables high
portability, so Ubuntu 20.04 and 22.04 can for example still be supported with the
same build since glibc is statically linked in the Python build, also making it easier to
support more operating systems in the future.

Known Issues: Enum types are not displayed correctly. 

For more details, refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2219
This commit is contained in:
Ben Riegel
2023-06-14 12:53:51 +01:00
committed by GitHub
parent 1456512754
commit fca81fcd98
5 changed files with 827 additions and 22 deletions

View File

@ -6,23 +6,47 @@
import * as vscode from 'vscode';
import * as os from 'os';
/* see https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode#attaching-settings */
export interface WasmDebugConfig {
type: string,
name: string,
request: string,
program? : string,
pid?: string,
stopOnEntry?: boolean,
waitFor?: boolean,
initCommands?: string[],
preRunCommands?: string[],
stopCommands?: string[],
exitCommands?: string[],
terminateCommands?: string[],
attachCommands?: string[]
}
export class WasmDebugConfigurationProvider
implements vscode.DebugConfigurationProvider {
private wasmDebugConfig = {
private wasmDebugConfig: 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',
]
};
constructor(extensionPath: string) {
this.wasmDebugConfig.initCommands = [
/* Add rust formatters -> https://lldb.llvm.org/use/variable.html */
`command script import ${extensionPath}/formatters/rust.py`
];
if (os.platform() === 'win32' || os.platform() === 'darwin') {
this.wasmDebugConfig.initCommands.push('platform select remote-linux');
}
}
public resolveDebugConfiguration(
_: vscode.WorkspaceFolder | undefined,
debugConfiguration: vscode.DebugConfiguration,