4
Simple tool to run the demangler.
6
(C) 2010 Alon Zakai, MIT licensed
8
Usage: demangler.py FILENAME SPLITTER
10
Make sure you define ~/.emscripten, and fill it with something like
12
JS_ENGINE=[os.path.expanduser('~/Dev/v8/d8')]
13
JS_ENGINE_PARAMS=['--']
17
JS_ENGINE=[os.path.expanduser('~/Dev/tracemonkey/js/src/js')]
22
import os, sys, subprocess, re
24
__rootpath__ = os.path.dirname(os.path.abspath(__file__))
25
def path_from_root(*pathelems):
26
return os.path.join(os.path.sep, *(__rootpath__.split(os.sep)[:-1] + list(pathelems)))
27
sys.path += [path_from_root('')]
28
from tools.shared import *
30
data = open(sys.argv[1], 'r').readlines()
34
if len(line) < 4: continue
35
m = re.match('^ function (?P<func>[^(]+)\(.*', line) # generated code
37
m = re.match('^ + _*\d+: (?P<func>[^ ]+) \(\d+.*', line) # profiling output
39
func = m.groups('func')[0]
40
if func in SEEN: continue
42
cleaned = run_js(JS_ENGINE, path_from_root('third_party', 'gcc_demangler.js'), [func[1:]])
43
if cleaned is None: continue
44
if 'Fatal exception' in cleaned: continue
45
cleaned = cleaned[1:-2]
46
if cleaned == '(null)': continue
47
if ' throw ' in cleaned: continue
48
print func, '=', cleaned