Skip to content

Instantly share code, notes, and snippets.

@yurydelendik
Created August 29, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurydelendik/10f3c99879e9459259a6aaf79f39215c to your computer and use it in GitHub Desktop.
Save yurydelendik/10f3c99879e9459259a6aaf79f39215c to your computer and use it in GitHub Desktop.
sourceURLPrefixes WebAssembly custom section

sourceURLPrefixes WebAssembly custom section

This custom section is created to provide mapping of the local (or remote) file paths to network resources. Currently we can have DWARF sections inside the binary WebAssembly file, however debugger, in most of the cases, cannot retrive local files -- this file paths needs to be mapped to some networks server location.

Format

The custom section has the following format:

Field Type Description
Custom Section ID varuint32 0
Custom Section Size varuint32 size of the section (including name)
Section Name Len varuint32 len("sourceURLPrefixes")
Section Name bytes "sourceURLPrefixes"
JSON Len varuint32 len(JSON)
JSON bytes utf-8 encoded JSON

The JSON is an array of pairs (array). The first item of the pair is the prefix to be replaced, and the second is the prefix that will be used as the replacement, e.g.

[
  ["/Users/yury/example_com/", "http://example.com/"],
  ["/usr/lib/libx/", "http://example.org/libx/"],
]

If the consumer find the file path that starts with "/Users/yury/example_com/", this path needs to the changed to start with "http://example.com/".

@justinclift
Copy link

justinclift commented Sep 1, 2018

however debugger, in most of the cases, cannot retrive local files

Hmmm, is this from the point of view of an online IDE/debugger?

Curious, as I'm following along with this stuff from a Go perspective (cheering you on mostly 😉), and the use case I'm thinking of is for debuggers in desktop IDE's (eg GoLand in my case, but there are several others).

They'd have access to local files wouldn't they?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment