@@ -101,29 +101,29 @@ var LibraryStackTrace = {
101
101
$convertFrameToPC__docs : '/** @returns {number} */' ,
102
102
$convertFrameToPC__internal : true ,
103
103
$convertFrameToPC : ( frame ) => {
104
- #if ! USE_OFFSET_CONVERTER
105
- abort ( 'Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER' ) ;
106
- #else
107
- #if ASSERTIONS
108
- assert ( wasmOffsetConverter , 'wasmOffsetConverter global not found' ) ;
109
- #endif
110
104
var match ;
111
105
112
106
if ( match = / \b w a s m - f u n c t i o n \[ \d + \] : ( 0 x [ 0 - 9 a - f ] + ) / . exec ( frame ) ) {
113
107
// some engines give the binary offset directly, so we use that as return address
114
108
return + match [ 1 ] ;
115
109
} else if ( match = / \b w a s m - f u n c t i o n \[ ( \d + ) \] : ( \d + ) / . exec ( frame ) ) {
116
- // other engines only give function index and offset in the function,
110
+ // Older versions of v8 give function index and offset in the function,
117
111
// so we try using the offset converter. If that doesn't work,
118
112
// we pack index and offset into a "return address"
113
+ #if ! USE_OFFSET_CONVERTER
114
+ abort ( 'Legacy backtrace format detected but -sUSE_OFFSET_CONVERTER not present.' )
115
+ #else
116
+ #if ASSERTIONS
117
+ assert ( wasmOffsetConverter , 'wasmOffsetConverter global not found' ) ;
118
+ #endif
119
119
return wasmOffsetConverter . convert ( + match [ 1 ] , + match [ 2 ] ) ;
120
+ #endif
120
121
} else if ( match = / : ( \d + ) : \d + (?: \) | $ ) / . exec ( frame ) ) {
121
122
// If we are in js, we can use the js line number as the "return address".
122
123
// This should work for wasm2js. We tag the high bit to distinguish this
123
124
// from wasm addresses.
124
125
return 0x80000000 | + match [ 1 ] ;
125
126
}
126
- #endif
127
127
// return 0 if we can't find any
128
128
return 0 ;
129
129
} ,
@@ -242,16 +242,10 @@ var LibraryStackTrace = {
242
242
} ,
243
243
244
244
// Look up the function name from our stack frame cache with our PC representation.
245
- #if USE_OFFSET_CONVERTER
246
245
emscripten_pc_get_function__deps : [ '$UNWIND_CACHE' , 'free' , '$stringToNewUTF8' ] ,
247
246
// Don't treat allocation of _emscripten_pc_get_function.ret as a leak
248
247
emscripten_pc_get_function__noleakcheck : true ,
249
- #endif
250
248
emscripten_pc_get_function : ( pc ) => {
251
- #if ! USE_OFFSET_CONVERTER
252
- abort ( 'Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER' ) ;
253
- return 0 ;
254
- #else
255
249
var name ;
256
250
if ( pc & 0x80000000 ) {
257
251
// If this is a JavaScript function, try looking it up in the unwind cache.
@@ -267,12 +261,16 @@ var LibraryStackTrace = {
267
261
return 0 ;
268
262
}
269
263
} else {
264
+ #if ! USE_OFFSET_CONVERTER
265
+ abort ( 'Cannot use emscripten_pc_get_function on native functions without -sUSE_OFFSET_CONVERTER' ) ;
266
+ return 0 ;
267
+ #else
270
268
name = wasmOffsetConverter . getName ( pc ) ;
269
+ #endif
271
270
}
272
271
_free ( _emscripten_pc_get_function . ret ?? 0 ) ;
273
272
_emscripten_pc_get_function . ret = stringToNewUTF8 ( name ) ;
274
273
return _emscripten_pc_get_function . ret ;
275
- #endif
276
274
} ,
277
275
278
276
$convertPCtoSourceLocation__deps : [ '$UNWIND_CACHE' ] ,
0 commit comments