Make error handling in the WebAssembly interpreter easier
Various improvements to ease error handling in the WebAssembly interpreter, which is required for itasks-sdk#466 (closed):
- Add
resolve_pie_symbol
which, given an address from the frontend, returns the symbol name the address is part of and the offset from that symbol to the address. This can be used in conjunction with the JavaScript API'sget_trace
to get a symbolic trace. - Add
error_handler
option to the JavaScriptinstantiate
function to set an error handler for the interpreter. This error handler is then applied to all functions run in the interpreter. This is better than requiring applications to encapsulateinterpret
intry .. catch
, because we may set callbacks from Clean and errors in these callbacks should be handled as well. Theerror_handler
function receives both the thrown JavaScript object (from which we can get the JavaScript stack trace) and the Clean stack trace (fromget_trace
) which can be given toresolve_pie_symbol
to get a symbolic Clean stack trace.
Note that it is not possible to get a symbolic Clean stack trace on the client alone, because the WebAssembly interpreter has no symbol table.
Edited by Camil Staps