@@ -791,36 +791,40 @@ function lengthBytesUTF32(str) {
791
791
{ { { maybeExport ( 'lengthBytesUTF32' ) } } }
792
792
793
793
function demangle ( func ) {
794
+ #if DEMANGLE_SUPPORT
794
795
var __cxa_demangle_func = Module [ '___cxa_demangle' ] || Module [ '__cxa_demangle' ] ;
795
- if ( __cxa_demangle_func ) {
796
- try {
797
- var s =
796
+ assert ( __cxa_demangle_func ) ;
797
+ try {
798
+ var s =
798
799
#if WASM_BACKEND
799
- func ;
800
+ func ;
800
801
#else
801
- func . substr ( 1 ) ;
802
- #endif
803
- var len = lengthBytesUTF8 ( s ) + 1 ;
804
- var buf = _malloc ( len ) ;
805
- stringToUTF8 ( s , buf , len ) ;
806
- var status = _malloc ( 4 ) ;
807
- var ret = __cxa_demangle_func ( buf , 0 , 0 , status ) ;
808
- if ( getValue ( status , 'i32' ) === 0 && ret ) {
809
- return Pointer_stringify ( ret ) ;
810
- }
811
- // otherwise, libcxxabi failed
812
- } catch ( e ) {
813
- // ignore problems here
814
- } finally {
815
- if ( buf ) _free ( buf ) ;
816
- if ( status ) _free ( status ) ;
817
- if ( ret ) _free ( ret ) ;
802
+ func . substr ( 1 ) ;
803
+ #endif
804
+ var len = lengthBytesUTF8 ( s ) + 1 ;
805
+ var buf = _malloc ( len ) ;
806
+ stringToUTF8 ( s , buf , len ) ;
807
+ var status = _malloc ( 4 ) ;
808
+ var ret = __cxa_demangle_func ( buf , 0 , 0 , status ) ;
809
+ if ( getValue ( status , 'i32' ) === 0 && ret ) {
810
+ return Pointer_stringify ( ret ) ;
818
811
}
819
- // failure when using libcxxabi, don't demangle
820
- return func ;
812
+ // otherwise, libcxxabi failed
813
+ } catch ( e ) {
814
+ // ignore problems here
815
+ } finally {
816
+ if ( buf ) _free ( buf ) ;
817
+ if ( status ) _free ( status ) ;
818
+ if ( ret ) _free ( ret ) ;
821
819
}
820
+ // failure when using libcxxabi, don't demangle
821
+ return func ;
822
+ #else // DEMANGLE_SUPPORT
823
+ #if ASSERTIONS
822
824
Runtime . warnOnce ( 'warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling' ) ;
825
+ #endif // ASSERTIONS
823
826
return func ;
827
+ #endif // DEMANGLE_SUPPORT
824
828
}
825
829
826
830
function demangleAll ( text ) {
0 commit comments