def compute(self, objectlist): assert objectlist[0] is MARKER self.objectlist = objectlist dotgen = DotGen('reftracker') id2typename = {} nodes = {} edges = {} def addedge(o1, o2): key = (uid(o1), uid(o2)) edges[key] = self.edgelabel(o1, o2) for i in range(1, len(objectlist)): typename, s, linktext = self.formatobject(objectlist[i]) word = '0x%x' % uid(objectlist[i]) if linktext: self.links[word] = linktext s = '<%s> %s\\n%s' % (typename, word, s) nodename = 'node%d' % len(nodes) dotgen.emit_node(nodename, label=s, shape="box") nodes[uid(objectlist[i])] = nodename for o2 in self.get_referents(objectlist[i]): if o2 is None: continue addedge(objectlist[i], o2) id2typename[uid(o2)] = self.shortrepr(o2) del o2 for o2 in self.get_referrers(objectlist[i]): if o2 is None: continue if type(o2) is list and o2 and o2[0] is MARKER: continue addedge(o2, objectlist[i]) id2typename[uid(o2)] = self.shortrepr(o2) del o2 for ids, label in edges.items(): for id1 in ids: if id1 not in nodes: nodename = 'node%d' % len(nodes) word = '0x%x' % id1 s = '<%s> %s' % (id2typename[id1], word) dotgen.emit_node(nodename, label=s) nodes[id1] = nodename self.links[word] = s id1, id2 = ids dotgen.emit_edge(nodes[id1], nodes[id2], label=label) self.source = dotgen.generate(target=None)
def __repr__(self): """ representation for debugging purposes """ if self.w_value is None: content = "" else: content = repr(self.w_value) return "<%s(%s) at 0x%x>" % (self.__class__.__name__, content, uid(self))
def followlink(self, word): id1 = int(word, 16) found = None objectlist = self.objectlist for i in range(1, len(objectlist)): for o2 in self.get_referents(objectlist[i]): if uid(o2) == id1: found = o2 for o2 in self.get_referrers(objectlist[i]): if uid(o2) == id1: found = o2 if found is not None: objectlist = objectlist + [found] else: print '*** NOTE: object not found' return self.newpage(objectlist)
def nameof(obj, cache={}): # NB. the purpose of the cache is not performance, but to ensure that # two objects that compare equal get the same name try: return cache[obj] except KeyError: result = '%s__0x%x' % (getattr(obj, '__name__', ''), uid(obj)) cache[obj] = result return result
def formatobject(self, o): lines = [] for name, value in self.enum_content(o): if not isinstance(value, str): value = '0x%x' % uid(value) lines.append('%s = %s' % (name, value)) s = '\n'.join(lines) t = shorttypename(lltype.typeOf(o)) return t, s, ''
def getfunctionname(self,func): # NB. the purpose of the cache is not performance, but to ensure that # two methods that compare equal get the same name. if inspect.ismethod(func) and func.im_self is None: func = func.im_func # consider unbound methods as plain functions try: return self.namecache[func] except KeyError: assert inspect.isfunction(func) or inspect.ismethod(func) name = '%s__%x' % (func.__name__, uid(func))#self._hackname(func) self.namecache[func] = name return name
def __str__(self): return '%r inst at 0x%x' % (self._TYPE._name, uid(self))
def __repr__(self): return ("CreationPoint(<0x%x>, %r, %s, esc=%s)" % (uid(self), self.TYPE, self.creation_method, self.escapes))
def __repr__(self): return '<FunctionGraph of %s at 0x%x>' % (self, uid(self))
def __repr__(self): try: return '<AddressAsInt %s>' % (self.adr.ptr,) except AttributeError: return '<AddressAsInt at 0x%x>' % (uid(self),)
def __repr__(self): return ("CreationPoint(<0x%x>, %r)" % (uid(self), self.TYPE))
def __repr__(self): return ("CreationPoint(<0x%x>, %r, %s, esc=%s, cha=%s)" % (uid(self), self.lltype, self.creation_method, self.escapes, self.changes))
def addedge(o1, o2): key = (uid(o1), uid(o2)) edges[key] = self.edgelabel(o1, o2)
def getclassname(self,cls): assert isinstance(cls, ClassDef) name = cls.shortname if cls.issubclass(self.annotator.bookkeeper.getuniqueclassdef(Exception)): return name return '%s__%x' % (name, uid(cls))#self._hackname(cls)
def __repr__(self): return "<node [%s] at 0x%x>" % (self.name, uid(self))
def __repr__(self): return '%s(0x%x)' % (self.__class__.__name__, uid(self))
def __repr__(self): return "<UnionDict at 0x%x>" % uid(self)