diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-12 21:01:03 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-12 21:01:03 -0700 |
commit | 80c217ec6073e1d80fbe256e1bb88e8180d8602e (patch) | |
tree | c359450092029153209d85095d8a115391dfc5b2 /src | |
parent | 5e6b5e313cb2fa9c699934df72a7c975d1d02ad2 (diff) |
use stackTrace in various places
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | src/library_fs.js | 3 | ||||
-rw-r--r-- | src/preamble.js | 12 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/library.js b/src/library.js index aeebe8bb..875d8bab 100644 --- a/src/library.js +++ b/src/library.js @@ -4301,11 +4301,11 @@ LibraryManager.library = { __assert_fail: function(condition, filename, line, func) { ABORT = true; - throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + new Error().stack; + throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + stackTrace(); }, __assert_func: function(filename, line, func, condition) { - throw 'Assertion failed: ' + (condition ? Pointer_stringify(condition) : 'unknown condition') + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + new Error().stack; + throw 'Assertion failed: ' + (condition ? Pointer_stringify(condition) : 'unknown condition') + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + stackTrace(); }, __cxa_guard_acquire: function(variable) { @@ -4353,7 +4353,7 @@ LibraryManager.library = { ___cxa_throw.initialized = true; } #if EXCEPTION_DEBUG - Module.printErr('Compiled code throwing an exception, ' + [ptr,type,destructor] + ', at ' + new Error().stack); + Module.printErr('Compiled code throwing an exception, ' + [ptr,type,destructor] + ', at ' + stackTrace()); #endif {{{ makeSetValue('_llvm_eh_exception.buf', '0', 'ptr', 'void*') }}} {{{ makeSetValue('_llvm_eh_exception.buf', QUANTUM_SIZE, 'type', 'void*') }}} diff --git a/src/library_fs.js b/src/library_fs.js index dc5c20f8..8f68b395 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -37,6 +37,7 @@ mergeInto(LibraryManager.library, { } } this.message = ERRNO_MESSAGES[errno]; + this.stack = stackTrace(); }; ErrnoError.prototype = new Error(); ErrnoError.prototype.constructor = ErrnoError; @@ -44,7 +45,7 @@ mergeInto(LibraryManager.library, { }()), handleFSError: function(e) { - if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + new Error().stack; + if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace(); return ___setErrNo(e.errno); }, diff --git a/src/preamble.js b/src/preamble.js index a85cf2f5..33e80217 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -36,7 +36,7 @@ var SAFE_HEAP_ERRORS = 0; var ACCEPTABLE_SAFE_HEAP_ERRORS = 0; function SAFE_HEAP_ACCESS(dest, type, store, ignore, storeValue) { - //if (dest === A_NUMBER) Module.print ([dest, type, store, ignore, storeValue] + ' ' + new Error().stack); // Something like this may be useful, in debugging + //if (dest === A_NUMBER) Module.print ([dest, type, store, ignore, storeValue] + ' ' + stackTrace()); // Something like this may be useful, in debugging assert(dest > 0, 'segmentation fault'); @@ -63,7 +63,7 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore, storeValue) { try { if (HEAP[dest].toString() === 'NaN') error = false; // NaN is acceptable, as a double value } catch(e){} - if (error) throw('Warning: Reading an invalid value at ' + dest + ' :: ' + new Error().stack + '\n'); + if (error) throw('Warning: Reading an invalid value at ' + dest + ' :: ' + stackTrace() + '\n'); } #endif if (type === null) return; @@ -72,14 +72,14 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore, storeValue) { if (!ignore) assert(history, 'Must have a history for a safe heap load! ' + dest + ':' + type); // Warning - bit fields in C structs cause loads+stores for each store, so // they will show up here... -// assert((history && history[0]) /* || HEAP[dest] === 0 */, "Loading from where there was no store! " + dest + ',' + HEAP[dest] + ',' + type + ', \n\n' + new Error().stack + '\n'); +// assert((history && history[0]) /* || HEAP[dest] === 0 */, "Loading from where there was no store! " + dest + ',' + HEAP[dest] + ',' + type + ', \n\n' + stackTrace() + '\n'); // if (history[0].type !== type) { if (history !== type && !ignore) { Module.print('Load-store consistency assumption failure! ' + dest); Module.print('\n'); Module.print(JSON.stringify(history)); Module.print('\n'); - Module.print('LOAD: ' + type + ', ' + new Error().stack); + Module.print('LOAD: ' + type + ', ' + stackTrace()); Module.print('\n'); SAFE_HEAP_ERRORS++; assert(SAFE_HEAP_ERRORS <= ACCEPTABLE_SAFE_HEAP_ERRORS, 'Load-store consistency assumption failure!'); @@ -93,9 +93,9 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) { #endif if (!ignore && !value && (value === null || value === undefined)) { - throw('Warning: Writing an invalid value of ' + JSON.stringify(value) + ' at ' + dest + ' :: ' + new Error().stack + '\n'); + throw('Warning: Writing an invalid value of ' + JSON.stringify(value) + ' at ' + dest + ' :: ' + stackTrace() + '\n'); } - //if (!ignore && (value === Infinity || value === -Infinity || isNaN(value))) throw [value, typeof value, new Error().stack]; + //if (!ignore && (value === Infinity || value === -Infinity || isNaN(value))) throw [value, typeof value, stackTrace()]; SAFE_HEAP_ACCESS(dest, type, true, ignore, value); if (dest in HEAP_WATCHED) { |