Skip to content

Commit

Permalink
avs_pc: add wasm source map so avs debugging in chrome is possible (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoSchw authored Jul 1, 2024
1 parent b1fd422 commit 2c782f1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Binary file added docs/assets/chrome_develop_tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions docs/debug_wasm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AVS WASM Debugging

## Develop

When working with the web app it is sometimes helpful to debug the AVS.
To do this you need to create the WASM file with debug information.

### Build WASM with source map

This creates wasm file with debug information

```bash
$ make dist_wasm WASM_DEBUG=1
```

### Link avs project ro wire_webapp

After you have built the wasm, link your local build of `@wireapp/avs` to your local `wire-webapp` like:

```bash
$ cd cd build/dist/wasm/
$ yarn link
```
Use `yarn link @wireapp/avs` in the root directory of your local `wire-webapp`.

If that doesn't work, there is still the hard way ;)

Add `@wireapp/avs` directly in the `package.json` of `wire-webapp` like

```json
{
"dependencies": {
"@wireapp/avs": "file:../wire-avs/build/dist/wasm/"
}
}
```

### Debugging WebAssembly in Chrome

To get the debug information you need a Chrome extension:
Install the [C/C++ DevTools Support (DWARF) Chrome extension](https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb)

![DevTools](./assets/chrome_develop_tool.png "DevTools")

Have fun!

7 changes: 6 additions & 1 deletion mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,16 @@ else
EMCC := $(WASM_PATH)/emcc
endif

ifeq ($(WASM_DEBUG),1)
DIST_WASM_WITH_SOURCE_MAP := -gsource-map -g
else
DIST_WASM_WITH_SOURCE_MAP :=
endif

$(DIST_WASM_JS_TARGET):
$(MAKE) AVS_OS=wasm AVS_ARCH=generic avs
@mkdir -p $(BUILD_DIST_WASM)/src
$(EMCC) -o $(DIST_WASM_JS_TARGET) \
$(EMCC) $(DIST_WASM_WITH_SOURCE_MAP) -o $(DIST_WASM_JS_TARGET) \
$(BUILD_BASE)/wasm-generic/lib/libavscore.a \
$(BUILD_BASE)/wasm-generic/lib/libre.a \
$(BUILD_BASE)/wasm-generic/lib/libsodium.a \
Expand Down

0 comments on commit 2c782f1

Please sign in to comment.