经过一番研究,我发现格式是
(<WASM>[function_index]+offset)
要查找函数索引的相应名称,您可以使用 binaryen 的wasm-as
-s
选项生成函数索引
wasm-as libcsound.wast -s libcsound.sym -o libcsound.wasm
这是 libcsound.sym 的内容
0:Math_pow
1:enlargeMemory
2:getTotalMemory
3:abortOnCannotGrowMemory
...
使用 libcsound.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 函数调用。当要转换的浮点数超出长整数范围时,此函数会导致“整数结果不可表示”陷阱。在调用修复问题的 lrint 之前,我先编辑了 C 代码以检查边界。
更新
使用-g4
和使用 Google Chrome 版本 60.0.3103.0 (Official Build) canary (64-bit) 函数名称出现在堆栈跟踪中:
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)