aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/preamble.js16
-rw-r--r--third_party/demangler.py42
2 files changed, 50 insertions, 8 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 79a1b5b1..d0ffd974 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -121,14 +121,14 @@ if (!this._malloc) {
_free = function() { }; // leak!
}
-// Mangled "new"s... need a heuristic for autogeneration...
-__Znwj = _malloc; // llvm-gcc
-__Znaj = _malloc; // llvm-gcc
-__Znam = _malloc; // clang
-__Znwm = _malloc; // clang
-// Mangled "delete"s... need a heuristic for autogeneration...
-__ZdlPv = _free; // llvm-gcc
-__ZdaPv = _free; // llvm-gcc
+// Mangled "new"
+__Znwj = _malloc; // new(uint)
+__Znaj = _malloc; // new[](uint)
+__Znam = _malloc; // new(ulong)
+__Znwm = _malloc; // new[](ulong)
+// Mangled "delete"
+__ZdlPv = _free; // delete(..)
+__ZdaPv = _free; // delete[](..)
function __initializeRuntime__() {
HEAP = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)'
diff --git a/third_party/demangler.py b/third_party/demangler.py
new file mode 100644
index 00000000..da8dc665
--- /dev/null
+++ b/third_party/demangler.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+'''
+Simple tool to run the demangler.
+
+Usage: demangler.py FILENAME SPLITTER
+
+Make sure you define ~/.emscripten, and fill it with something like
+
+JS_ENGINE=[os.path.expanduser('~/Dev/v8/d8')]
+JS_ENGINE_PARAMS=['--']
+
+or
+
+JS_ENGINE=[os.path.expanduser('~/Dev/tracemonkey/js/src/js')]
+JS_ENGINE_PARAMS=[]
+
+'''
+
+import os, sys, subprocess
+
+CONFIG_FILE = os.path.expanduser('~/.emscripten')
+exec(open(CONFIG_FILE, 'r').read())
+
+data = open(sys.argv[1], 'r').readlines()
+splitter = sys.argv[2]
+
+SEEN = {}
+for line in data:
+ if line[0] == ' ': continue
+ if line[0] != '_': continue
+ func = line.split(splitter)[0][1:]
+ if func in SEEN: continue
+ SEEN[func] = True
+ args = JS_ENGINE + ['gcc_demangler.js'] + JS_ENGINE_PARAMS + [func]
+ cleaned = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+ if cleaned is None: continue
+ cleaned = cleaned[1:-2]
+ if cleaned == '(null)': continue
+ if ' throw ' in cleaned: continue
+ print func, '=', cleaned
+