-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add helper function for C++ exception formatting #16343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @with_both_eh_sjlj to this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can also remove DISABLE_EXCEPTION_CATCHING below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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