Description
I am looking into how to do a similar task to #16343 with -fwasm-exceptions
. If there is an uncaught C++ exception with -fwasm-exceptions
, a WasmException
object is thrown which contains a single i32 which is the same pointer that is thrown as a number when using -fexceptions
. The WasmException
API has a getArg
API which can be used to get the pointer like exception.getArg(tag, 0)
. The problem is that the tag isn't exported and without the tag the WasmException
is completely opaque.
Once I have this tag, we can get access to the pointer from the WasmException
and then handle it similarly to as in the -fexceptions
case. I have checked that this works by using wasm2wat
then adding (export "cpp_exception_tag" (tag 0))
to the wat, then using wat2wasm
. (Though there is still the remaining issue that __cxa_can_catch
doesn't exist in this case.)