From 10159a897c404ec52d63faeb54a052c48cb1a6c9 Mon Sep 17 00:00:00 2001 From: Alon Zakai <alonzakai@gmail.com> Date: Wed, 23 Mar 2016 14:45:13 -0700 Subject: add function stack printing in interpreter --- src/wasm-js.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/wasm-js.cpp') 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. -- cgit v1.2.3