Example #1
0
    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)
Example #2
0
 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))
Example #3
0
 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)
Example #4
0
 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))
Example #5
0
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
Example #6
0
 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, ''
Example #7
0
 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, ''
Example #8
0
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
Example #9
0
 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
Example #10
0
 def __str__(self):
     return '%r inst at 0x%x' % (self._TYPE._name, uid(self))
Example #11
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s)" %
             (uid(self), self.TYPE, self.creation_method, self.escapes))
Example #12
0
 def __repr__(self):
     return '<FunctionGraph of %s at 0x%x>' % (self, uid(self))
Example #13
0
 def __repr__(self):
     try:
         return '<AddressAsInt %s>' % (self.adr.ptr,)
     except AttributeError:
         return '<AddressAsInt at 0x%x>' % (uid(self),)
Example #14
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r)" %
             (uid(self), self.TYPE))
Example #15
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s, cha=%s)" %
             (uid(self), self.lltype, self.creation_method, self.escapes, self.changes))
Example #16
0
 def addedge(o1, o2):
     key = (uid(o1), uid(o2))
     edges[key] = self.edgelabel(o1, o2)
Example #17
0
 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)
Example #18
0
 def __repr__(self):
     return "<node [%s] at 0x%x>" % (self.name, uid(self))
Example #19
0
 def __repr__(self):
     return '%s(0x%x)' % (self.__class__.__name__, uid(self))
Example #20
0
 def __repr__(self):
     return "<UnionDict at 0x%x>" % uid(self)
Example #21
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s)" %
             (uid(self), self.TYPE, self.creation_method, self.escapes))
Example #22
0
 def __repr__(self):
     return "<node [%s] at 0x%x>" % (self.name, uid(self))
Example #23
0
 def __repr__(self):
     return '%s(0x%x)' % (self.__class__.__name__, uid(self))
Example #24
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r)" % (uid(self), self.TYPE))
Example #25
0
 def __repr__(self):
     return '<FunctionGraph of %s at 0x%x>' % (self, uid(self))
Example #26
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s, cha=%s)" %
             (uid(self), self.lltype, self.creation_method, self.escapes, self.changes))