aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-12-19 23:32:26 +0200
committerJukka Jylänki <jujjyl@gmail.com>2013-12-20 11:49:34 +0200
commit55660c394d5f3db2d57984256dd6c3cce088e4c5 (patch)
tree20099712556194717acfdb9815bf5695f32c49a1 /src
parent184a425ce07a95e882f3f60b87c1c5037cbffec5 (diff)
Update emscripten_log to work with the handwritten JS demangler. Update tests.
Diffstat (limited to 'src')
-rw-r--r--src/library.js22
-rw-r--r--src/preamble.js4
2 files changed, 5 insertions, 21 deletions
diff --git a/src/library.js b/src/library.js
index 1a4d685a..3a56df06 100644
--- a/src/library.js
+++ b/src/library.js
@@ -8838,27 +8838,7 @@ LibraryManager.library = {
// Returns the given mangled C++ function name demangled to a readable form, or an empty string if the given string could not be demangled.
// E.g. "_Z3foov" -> "foo()".
emscripten_demangle: function(functionname) {
- if (typeof ___cxa_demangle === 'undefined') {
- Runtime.warnOnce('emscripten_demangle is not available in the current build. Please add the file $EMSCRIPTEN/system/lib/libcxxabi/src/cxa_demangle.cpp to your build to show demangled symbol names.');
- return '';
- }
- // The application entry point has a special name, so treat it manually.
- if (functionname == 'Object._main' || functionname == '_main') {
- return 'main()';
- }
- // If the compiled symbol starts with two underscores, there's one extra, which throws off cxa_demangle, so remove the first underscore.
- if (functionname.indexOf("__") == 0) {
- functionname = functionname.slice(1);
- }
- var sp = STACKTOP;
- var stat = allocate([0, 0, 0, 0], 'i32', ALLOC_STACK);
- var mangledname = allocate(512, 'i32*', ALLOC_STACK);
- writeStringToMemory(functionname, mangledname, false);
- var demangledname = allocate(512, 'i32*', ALLOC_STACK);
- ___cxa_demangle(mangledname, demangledname, 512, stat);
- var str = Pointer_stringify(demangledname);
- STACKTOP = sp;
- return str;
+ return demangle(functionname);
},
// Returns [parentFuncArguments, functionName, paramListName]
diff --git a/src/preamble.js b/src/preamble.js
index 710b7c52..832ec2c3 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -642,6 +642,10 @@ Module['stringToUTF32'] = stringToUTF32;
function demangle(func) {
try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
if (typeof func === 'number') func = Pointer_stringify(func);
if (func[0] !== '_') return func;
if (func[1] !== '_') return func; // C function