-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[EH] Support stack traces for Wasm exceptions #17979
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
Changes from 1 commit
35f61c9
1b16d80
0cfb81d
42e7991
a4fab86
842ef0f
79ae2e5
6449f7d
2c165e1
007130a
34e346d
eb8ad2a
16d4c00
f9654ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,6 +253,13 @@ handler, _Unwind_RaiseException may return. In that case, __cxa_throw | |
| will call terminate, assuming that there was no handler for the | ||
| exception. | ||
| */ | ||
|
|
||
| #if defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG) | ||
| extern "C" { | ||
| void __throwCppWebAssemblyException(_Unwind_Exception*, bool); | ||
| } // extern "C" | ||
| #endif | ||
|
|
||
| void | ||
| #ifdef __USING_WASM_EXCEPTIONS__ | ||
| // In wasm, destructors return their argument | ||
|
|
@@ -280,6 +287,14 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void (*dest)(void *)) { | |
|
|
||
| #ifdef __USING_SJLJ_EXCEPTIONS__ | ||
| _Unwind_SjLj_RaiseException(&exception_header->unwindHeader); | ||
| #elif __USING_WASM_EXCEPTIONS__ | ||
| #ifdef NDEBUG | ||
| _Unwind_RaiseException(&exception_header->unwindHeader); | ||
| #else | ||
| // In debug mode, call a JS library function to use WebAssembly.Exception JS | ||
| // API, which enables us to include stack traces | ||
| __throwCppWebAssemblyException(&exception_header->unwindHeader, true); | ||
|
||
| #endif | ||
| #else | ||
| _Unwind_RaiseException(&exception_header->unwindHeader); | ||
| #endif | ||
|
|
||
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.
Perhaps add something like. "In release builds this function is not needed and the native
_Unwind_RaiseExceptionis used instead"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.
To add to that, perhaps we can put the entire function within
#if ASSERTIONS? That would both further clarify it is for debug builds, and also we'd get a link error if we try to use it by mistake in the future.(Though from discussion below perhaps we want to allow this to be used optionally in release builds too. In that case ignore my comment here.)
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.
@sbc100 Added the comment.
@kripken Put the
#if ASSERTIONSguard around it.