Skip to content

Commit cfd62cb

Browse files
Add Chrome DevTools section (#17)
1 parent 58fff1c commit cfd62cb

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Creating a browser app](getting-started/browser-app.md)
1010
- [JavaScript interoperation](getting-started/javascript-interop.md)
1111
- [Testing your app](getting-started/testing.md)
12+
- [Debugging](getting-started/debugging.md)
1213
- [Examples](examples/index.md)
1314
- [Importing function](examples/importing-function.md)
1415
- [Exporting function](examples/exporting-function.md)

src/contribution-guide/tips.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,3 @@ Compilation time of LLVM and the Swift toolchain is very long, so we recommend t
2424

2525
- [mozilla/sccache](https://github.com/mozilla/sccache)
2626
- [Use sccache to cache build artifacts](https://github.com/apple/swift/blob/master/docs/DevelopmentTips.md#use-sccache-to-cache-build-artifacts)
27-
28-
## Debugging
29-
30-
When you want to debug a WebAssembly binary, [wasminspect](https://github.com/kateinoigakukun/wasminspect)
31-
can help in the investigation if the debugged binary does not rely on integration with JavaScript.
32-
We recommend splitting your packages into separate executable targets, most of which shouldn't
33-
assume the availability of JavaScript to make debugging easier.
34-
35-
![demo](https://raw.githubusercontent.com/kateinoigakukun/wasminspect/master/assets/demo.gif)
903 KB
Loading

src/getting-started/debugging.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Debugging
2+
3+
Debugging is one of the most important parts of application development. This section describes debugging tools compatible with SwiftWasm.
4+
5+
These tools are DWARF-based, so you need to build your application with DWARF sections enabled.
6+
If you are using `carton bundle`, you can use the `--debug-info` flag to enable debugging with optimized application.
7+
If you are using `swift build`, it is enabled by default.
8+
9+
## Chrome DevTools
10+
11+
When you are debugging a web browser application, Chrome DevTools is a good tool to use. It allows you to
12+
put breakpoints, step through at Swift source code level.
13+
14+
Please follow the steps below to configure Chrome DevTools for SwiftWasm:
15+
16+
1. Install [`C/C++ DevTools Support (DWARF)`](https://goo.gle/wasm-debugging-extension) extension in your Chrome
17+
2. Enable `WebAssembly Debugging: Enable DWARF support` in `Experiments` pane of DevTools settings
18+
19+
See [the DevTools team's official introduction](https://developer.chrome.com/blog/wasm-debugging-2020) for more details about the extension.
20+
21+
![](./chrome-devtools.png)
22+
23+
Note that the function names in the stack trace are mangled. You can demangle them using `swift demangle` command.
24+
25+
Unfortunately, variable inspection is unavailable since Swift depends on its own mechanisms to do that instead of DWARF's structure type feature. (See [this thread](https://github.com/swiftwasm/swift/issues/593) for more details)
26+
27+
## [wasminspect](https://github.com/kateinoigakukun/wasminspect)
28+
29+
[wasminspect](https://github.com/kateinoigakukun/wasminspect)
30+
can help in the investigation if the debugged binary does not rely on integration with JavaScript.
31+
We recommend splitting your packages into separate executable targets, most of which shouldn't
32+
assume the availability of JavaScript to make debugging easier.
33+
34+
![demo](https://raw.githubusercontent.com/kateinoigakukun/wasminspect/master/assets/demo.gif)

0 commit comments

Comments
 (0)