aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-03-11 13:25:36 +0200
committerJukka Jylänki <jujjyl@gmail.com>2014-03-11 13:25:36 +0200
commitd4ef9376223f3f7f861ec7f9086a0a5a3e190ab9 (patch)
tree7765097e56b5804b0779cb05d77de5fd3ff65e10
parent5c692fd82fcfafc0685f1c73328f66f905b52305 (diff)
Implement a IE10+ specific path to emscripten_get_callstack to get the call stack information. In IE, callstacks are populated only when an exception object is thrown. Closes #2212.
-rw-r--r--src/library.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/library.js b/src/library.js
index 2c3d5e03..f7155e9d 100644
--- a/src/library.js
+++ b/src/library.js
@@ -8915,10 +8915,19 @@ LibraryManager.library = {
emscripten_get_callstack_js: function(flags) {
var err = new Error();
if (!err.stack) {
- Runtime.warnOnce('emscripten_get_callstack_js is not supported on this browser!');
- return '';
+ // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
+ // so try that as a special-case.
+ try {
+ throw new Error(0);
+ } catch(e) {
+ err = e;
+ }
+ if (!err.stack) {
+ Runtime.warnOnce('emscripten_get_callstack_js is not supported on this browser!');
+ return '';
+ }
}
- var callstack = new Error().stack.toString();
+ var callstack = err.stack.toString();
// Find the symbols in the callstack that corresponds to the functions that report callstack information, and remove everyhing up to these from the output.
var iThisFunc = callstack.lastIndexOf('_emscripten_log');