Skip to content

Commit

Permalink
Add a section on sourceMappingURL (#151)
Browse files Browse the repository at this point in the history
A follow-up to #149. See #148.
  • Loading branch information
RReverser authored Oct 30, 2020
1 parent c22209d commit 6f7b81c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ a Wasm container, which includes DWARF in Wasm custom sections, in the same
format as they would appear normally in a Wasm file. Note that the container may
also contain other sections, such as the code and data sections in the original
Wasm file.

# Source maps

Adoption of DWARF is a fairly recent addition to WebAssembly, and many toolchains still
support [Source Map](https://sourcemaps.info/spec.html) based debugging as well (or instead).

Source map is an external JSON file that specifies how to map a (zero-based) line and column
position in generated code to a file, line, and column location in the source. For
WebAssembly binary locations, the line number is always 1, and the column number
is interpreted as a byte offset into the WebAssembly binary content.
Source locations are interpreted as in the source map spec.

On the WebAssembly side, the URL of such Source Map file is stored in a custom section with the name
`sourceMappingURL`. That section contains:

| Field | Type | Description |
| ------------ | ----------- | --------------------------------- |
| url_name_len | `varuint32` | Length of `url_name_str` in bytes |
| url_name_str | `bytes` | URL to the Source Map file |

0 comments on commit 6f7b81c

Please sign in to comment.