diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-23 14:45:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-23 14:55:50 -0700 |
commit | 10159a897c404ec52d63faeb54a052c48cb1a6c9 (patch) | |
tree | f3a843d544eba03bec536f61d65ba7bf8736c265 /src/wasm-js.cpp | |
parent | 4967e68bcb7f59134c35675a46f6020d2996eb99 (diff) | |
download | binaryen-10159a897c404ec52d63faeb54a052c48cb1a6c9.tar.gz binaryen-10159a897c404ec52d63faeb54a052c48cb1a6c9.tar.bz2 binaryen-10159a897c404ec52d63faeb54a052c48cb1a6c9.zip |
add function stack printing in interpreter
Diffstat (limited to 'src/wasm-js.cpp')
-rw-r--r-- | src/wasm-js.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index 03eddd031..d978e4a2a 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -382,6 +382,18 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { }; instance = new ModuleInstance(*module, new JSExternalInterface()); + + // stack trace hooks + EM_ASM({ + Module['outside']['extraStackTrace'] = function() { + return Pointer_stringify(Module['_interpreter_stack_trace']()); + }; + }); +} + +extern "C" int EMSCRIPTEN_KEEPALIVE interpreter_stack_trace() { + std::string stack = instance->printFunctionStack(); + return (int)strdup(stack.c_str()); // XXX leak } // Does a call from js into an export of the module. |