(func)
| 1437 | |
| 1438 | |
| 1439 | function demangle(func) { |
| 1440 | var hasLibcxxabi = !!Module['___cxa_demangle']; |
| 1441 | if (hasLibcxxabi) { |
| 1442 | try { |
| 1443 | var s = func.substr(1); |
| 1444 | var len = lengthBytesUTF8(s)+1; |
| 1445 | var buf = _malloc(len); |
| 1446 | stringToUTF8(s, buf, len); |
| 1447 | var status = _malloc(4); |
| 1448 | var ret = Module['___cxa_demangle'](buf, 0, 0, status); |
| 1449 | if (getValue(status, 'i32') === 0 && ret) { |
| 1450 | return Pointer_stringify(ret); |
| 1451 | } |
| 1452 | // otherwise, libcxxabi failed |
| 1453 | } catch(e) { |
| 1454 | // ignore problems here |
| 1455 | } finally { |
| 1456 | if (buf) _free(buf); |
| 1457 | if (status) _free(status); |
| 1458 | if (ret) _free(ret); |
| 1459 | } |
| 1460 | // failure when using libcxxabi, don't demangle |
| 1461 | return func; |
| 1462 | } |
| 1463 | Runtime.warnOnce('warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling'); |
| 1464 | return func; |
| 1465 | } |
| 1466 | |
| 1467 | function demangleAll(text) { |
| 1468 | return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') }); |
no test coverage detected