Skip to content

Commit 6548d3a

Browse files
committed
updating the readme to include debugging
1 parent 4602a13 commit 6548d3a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ $ npm install
5555
$ npm run build
5656
$ wasmtime serve -S common dist/sample-wasi-http-js.wasm
5757
```
58+
## Debugging in VSCode
59+
60+
You can debug by installing the [StarlingMonkey debugger extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger). [Componentize-js](https://github.com/bytecodealliance/componentize-js) is the compile tool that bundles the JavaScript application into a single .js file according to the `rollup.config.js` file, creates a WebAssembly module with the SpiderMonkey JavaScript engine, and then creates a component with both modules inside. For details, see the `build` and `build:debug` scripts in the `package.json` file in the root folder.
61+
62+
> NOTE: At this time, the debug extension requires both a StarlingMonkey component with debugging enabled, using `componentize-js` and the `--enable-script-debugging` runtime argument flag. In addition, to attach the debugger to the SpiderMonkey debugging API inside the StarlingMonkey WebAssembly component, the following additional interfaces need to be built into the debug version of the component:
63+
64+
```bash
65+
import wasi:cli/[email protected];
66+
import wasi:sockets/[email protected];
67+
import wasi:sockets/[email protected];
68+
import wasi:sockets/[email protected];
69+
import wasi:sockets/[email protected];
70+
```
71+
72+
At the moment, the extension does not add these interfaces for you; to add these interfaces, a replica of the WIT directory with a modified `server.wit` file is included in the `wit-debug` directory. When you start the StarlingMonkey debugger by selecting the `Run` menu and then `Start Debugging` (or press `F5`), the `tasks.json` file executes `npm run build:debug`, which compiles the modified WIT file to build the debug version of the component automatically.
73+
74+
Following a successful build, the StarlingMonkey debugger will launch `wasmtime` to serve the debug version of the component. Set a breakpoint on the JavaScript in the bundled version of your code, in dist/bundle.js, as that is the file that StarlingMonkey will be executing inside the component.
75+
5876

5977
## See Also
6078

0 commit comments

Comments
 (0)