wasm gc: make stack trace deobfuscator work in Firefox

This commit is contained in:
Alexey Andreev 2024-10-14 14:05:32 +02:00
parent d37ab2a276
commit 2f678ccb6c

View File

@ -17,7 +17,7 @@
let globalsCache = new Map(); let globalsCache = new Map();
let stackDeobfuscator = null; let stackDeobfuscator = null;
let chromeExceptionRegex = / *at .+\.wasm:wasm-function\[[0-9]+]:0x([0-9a-f]+).*/; let exceptionFrameRegex = /.+\.wasm:wasm-function\[[0-9]+]:0x([0-9a-f]+).*/;
let getGlobalName = function(name) { let getGlobalName = function(name) {
let result = globalsCache.get(name); let result = globalsCache.get(name);
if (typeof result === "undefined") { if (typeof result === "undefined") {
@ -150,7 +150,7 @@ function coreImports(imports, context) {
let stack = new Error().stack; let stack = new Error().stack;
let addresses = []; let addresses = [];
for (let line of stack.split("\n")) { for (let line of stack.split("\n")) {
let match = chromeExceptionRegex.exec(line); let match = exceptionFrameRegex.exec(line);
if (match !== null && match.length >= 2) { if (match !== null && match.length >= 2) {
let address = parseInt(match[1], 16); let address = parseInt(match[1], 16);
addresses.push(address); addresses.push(address);