Add helper function for C++ exception formatting#16343
Conversation
|
@sbc100 I can't figure out how to force this function to be included from if settings.FORMAT_EXCEPTION_SUPPORT:
settings.REQUIRED_EXPORTS += ['formatException']to force the library manager to put this in but I don't understand how. |
REQUIRED_EXPORTS only applies to native wasm function. I think want |
sbc100
left a comment
There was a problem hiding this comment.
lgtm % some last comments
| create_file('main.cpp', 'int main() { throw; }') | ||
| self.do_runf('main.cpp', None, assert_returncode=NON_ZERO) | ||
|
|
||
| def test_format_exception(self): |
There was a problem hiding this comment.
Add @with_both_eh_sjlj to this test?
There was a problem hiding this comment.
Then you can also remove DISABLE_EXCEPTION_CATCHING below.
There was a problem hiding this comment.
It doesn't work with wasm-exceptions. I am not sure how to make it work with wasm-exceptions, if you like I can look into it. It would probably be entertaining. But I think it should be a separate PR.
There was a problem hiding this comment.
I see, can you open a bug about that so that we remember to get it fixed. I imagine @aheejin will want it to work for sure.
There was a problem hiding this comment.
I opened #16380 which is where I got stuck in the wasm-exceptions case.
sbc100
left a comment
There was a problem hiding this comment.
lgtm with one final change
|
It would be good to add docs for this, perhaps around here: https://emscripten.org/docs/porting/Debugging.html#handling-c-exceptions-from-javascript |
Resolves #16326
This adds a function that converts a C++ exception pointer into a message like:
CppException myexception: My exception happenedor:
CppException int: An object of type 'int' at address 15738976 was thrown as a C++ exceptionYou would use as follows:
TODO:
-sFORMAT_EXCEPTION_SUPPORTactually export this function