Sha256: 6c6a37fefb31b4765934fb913ea59bdc391d86ea4b102ca56088facb83d9dafc

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

#!/usr/bin/python2

'''
Simple tool to run the demangler.

(C) 2010 Alon Zakai, MIT licensed

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, re

__rootpath__ = os.path.dirname(os.path.abspath(__file__))
def path_from_root(*pathelems):
  return os.path.join(os.path.sep, *(__rootpath__.split(os.sep)[:-1] + list(pathelems)))
sys.path += [path_from_root('')]
from tools.shared import *

data = open(sys.argv[1], 'r').readlines()

SEEN = {}
for line in data:
  if len(line) < 4: continue
  m = re.match('^  function (?P<func>[^(]+)\(.*', line) # generated code
  if not m:
    m = re.match('^ + _*\d+: (?P<func>[^ ]+) \(\d+.*', line) # profiling output
  if not m: continue
  func = m.groups('func')[0]
  if func in SEEN: continue
  SEEN[func] = True
  cleaned = run_js(JS_ENGINE, path_from_root('third_party', 'gcc_demangler.js'), [func[1:]])
  if cleaned is None: continue
  if 'Fatal exception' in cleaned: continue
  cleaned = cleaned[1:-2]
  if cleaned == '(null)': continue
  if ' throw ' in cleaned: continue
  print func, '=', cleaned

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
webruby-0.2.7 modules/emscripten/third_party/demangler.py
webruby-0.2.5 modules/emscripten/third_party/demangler.py
webruby-0.2.4 modules/emscripten/third_party/demangler.py
webruby-0.2.2 modules/emscripten/third_party/demangler.py
webruby-0.2.1 modules/emscripten/third_party/demangler.py
webruby-0.1.2 modules/emscripten/third_party/demangler.py
webruby-0.1.1 modules/emscripten/third_party/demangler.py
webruby-0.1.0 modules/emscripten/third_party/demangler.py