javascript - Webkit WASM 堆栈跟踪调试

标签 javascript webassembly

当前,当发生 webassembly 运行时错误时,堆栈跟踪如下所示(我正在尝试将 Csound 作为 webassembly 运行)

"RuntimeError: integer result unrepresentable
at  (<WASM>[5336]+20)
at  (<WASM>[1557]+246)
at  (<WASM>[408]+1475)
at  (<WASM>[6101]+14)
at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9614:89)
at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8882:32)
at  (<WASM>[424]+732)
at  (<WASM>[278]+45)
at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9606:128)
at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:272:19)"

([number1]+number2) 是什么意思,尤其是那些数字?

最佳答案

经过一些研究我发现格式是

(<WASM>[function_index]+offset)

要找到函数索引的相应名称,您可以使用 binaryen 的 wasm-as -s 选项生成函数索引

wasm-as libcsound.wast -s libcsound.sym -o libcsound.wasm

这是libcs​​ound.sym的内容

0:Math_pow
1:enlargeMemory
2:getTotalMemory
3:abortOnCannotGrowMemory
...

使用 libcs​​ound.sym 我们可以使用 WASM 函数名来增强示例

RuntimeError: integer result unrepresentable
    at  (<WASM>[5336]+20) _lrintf
    at  (<WASM>[1557]+246) _osckk
    at  (<WASM>[408]+1475) _kperf_nodebug
    at  (<WASM>[6101]+14) dynCall_ii
    at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9614:89)
    at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8882:32)
    at  (<WASM>[424]+732) _csoundPerformKsmps
    at  (<WASM>[278]+45) jsCall_vi
    at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9606:128)
    at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:272:19)

有趣的部分是对 lrintf 的最后一个 C 函数调用.当要转换的 float 位于长整数范围之外时,此函数可能会导致“整数结果无法表示”陷阱。我编辑了 C 代码以先检查边界,然后调用 lrint 解决了问题。

更新

当使用 -g4 并使用 Google Chrome 版本 60.0.3103.0(官方构建)金丝雀(64 位)函数名称出现在堆栈跟踪中时:

Uncaught RuntimeError: integer result unrepresentable
    at _lrintf (<WASM>[4176]+6)
    at _osckk (<WASM>[1291]+138)
    at _kperf_nodebug (<WASM>[257]+768)
    at dynCall_ii (<WASM>[4351]+13)
    at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9153:89)
    at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8714:32)
    at _csoundPerformKsmps (<WASM>[271]+558)
    at _CsoundObj_performKsmps (<WASM>[131]+33)
    at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9145:128)
    at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:269:19)

关于javascript - Webkit WASM 堆栈跟踪调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44047603/

相关文章:

javascript - 将本地 glTF 文件加载到 Javascript 内存中

javascript - 如何检索函数中变量的内容?

javascript - 监听 Web Worker 的创建?

internet-explorer - Internet Explorer 中的 Blazor

javascript - Mootools getElements ("input[type=radio]")返回对象而不是数组

javascript - 如何在自定义 Shiny 输入的 update* 函数中添加 HTML 依赖项

webassembly - 如何将库编译为可从 JavaScript 代码调用的 WebAssembly?

canvas - 如何在emscripten中使用 Canvas

javascript - 在 javascript 和 WebGL 中创建纹理并在 WebAssembly 中识别它们

javascript - 用于匹配模式中前一组的正则表达式?