lens-vm / lens

Mozilla Public License 2.0
298 stars 6 forks source link

Debugging wasm modules is really awful at the moment #8

Closed AndrewSisley closed 1 year ago

AndrewSisley commented 1 year ago

We need to improve this soon.

Handy links: https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md https://github.com/WebAssembly/exception-handling https://webassembly.org/roadmap/ (wasmtime and wasmer dont support the wasm proposal) https://emscripten.org/docs/porting/exceptions.html

AssemblyScript also has an abort func (currently set to no-op in the test module), it is called on panic

Note: Rust's catch_unwind does not seem to work either and probably gets ignored by either the wasm compiler (or wasmer runtime) - I tried in the lens code, and these guys had the same issue https://stackoverflow.com/questions/59426545/rust-paniccatch-unwind-no-use-in-webassembly - any error handling we do will probably not be able to handle these until the error handling proposal is implemented in our runtime

Discussed over discord - we'll change the message format to the following: [type-byte][len][message]

where type-byte is a single i8, negative values represent an error, positive values a json result, 0 is undefined. For now all that we will care about is whether it is positive, negative or 0, but in the future we may have further use for these.

AndrewSisley commented 1 year ago

Discussion on this topic in dev-db discord thread 'Lens errors' https://discord.com/channels/427944769851752448/1044377654683504831