Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Created January 18, 2013 19:55
Show Gist options
  • Save jimblandy/4567919 to your computer and use it in GitHub Desktop.
Save jimblandy/4567919 to your computer and use it in GitHub Desktop.
import gdb
import mozilla.prettyprinters as prettyprinters
from mozilla.prettyprinters import ptr_pretty_printer, pretty_printer
prettyprinters.clear_module_printers(__name__)
@pretty_printer('js::analyze::SSAValue')
class SSAValuePrinter(object):
def __init__(self, value, cache):
self.value = value
self.cache = cache
if not hasattr('cache', 'SSAValue_map'):
cache.SSAValue_map = prettyprinters.AggregateMap(value.type)
ev = prettyprinters.enum_value
enum = gdb.lookup_type('js::analyze::SSAValue::Kind')
cache.SSAValue_EMPTY = ev(enum, 'js::analyze::SSAValue::EMPTY')
cache.SSAValue_PUSHED = ev(enum, 'js::analyze::SSAValue::PUSHED')
cache.SSAValue_VAR = ev(enum, 'js::analyze::SSAValue::VAR')
cache.SSAValue_PHI = ev(enum, 'js::analyze::SSAValue::PHI')
self.liveset = set()
self.kind = self.value['u']['pushed']['kind']
if self.kind == cache.SSAValue_PUSHED:
cache.SSAValue_map.mark_live(self.liveset, ['u', 'pushed'])
elif self.kind == cache.SSAValue_VAR:
cache.SSAValue_map.mark_live(self.liveset, ['u', 'var'])
elif self.kind == cache.SSAValue_PHI:
cache.SSAValue_map.mark_live(self.liveset, ['u', 'phi'])
def to_string(self):
return None
def children(self):
if self.kind == self.cache.SSAValue_EMPTY:
yield 'kind', 'EMPTY'
else:
for c in self.cache.SSAValue_map.children(self.value, self.liveset):
yield c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment