diff options
author | alon@honor <none@none> | 2010-10-21 15:22:42 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-21 15:22:42 -0700 |
commit | 9f7e6ddbd245ecac6321941684d6d4a337d67fa1 (patch) | |
tree | dab1d6b8656bae9b91d21362ec5d734509219f37 /third_party | |
parent | 29fc5282681891989ce18a915da5975310e78abe (diff) |
demangler python script
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/demangler.py | 42 |
1 files changed, 42 insertions, 0 deletions
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 + |