Beispiel #1
0
def loadGraph(fname):
    sys.stderr.write('Parsing {0}. '.format(fname))
    sys.stderr.flush()
    (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
    g = convertGraph(g, ga)
    sys.stderr.write('Done loading graph.\n')
    return (g, ga)
Beispiel #2
0
def load_graph(fname):
  sys.stderr.write ('Parsing {0}. '.format(fname))
  sys.stderr.flush()
  (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
  sys.stderr.write ('Done loading graph.\n')

  return (g, ga)
def parseAndCheckResults(fname):
  print 'Checking ' + fname + '.',

  print 'Parsing.',
  sys.stdout.flush()
  pef = parse_cc_graph.parseCCEdgeFile(fname)
  g = pef[0]
  ga = pef[1]
  resFx = pef[2]

  print 'Checking graph.',
  sys.stdout.flush()
  checkGraph(g, ga)

  print 'Running PyCC.',
  sys.stdout.flush()
  resPy = cycleCollect(g, ga)

  print 'Comparing results.',
  sys.stdout.flush()
  ok = checkResults (g, ga, resFx, 'Firefox cycle collector', 
                            resPy, 'Python cycle collector')
  if ok:
    print 'Ok.'
  else:
    print 'Error.'
    exit(-1)

  return ok
def parseAndCheckResults(fname):
    print 'Checking ' + fname + '.',

    print 'Parsing.',
    sys.stdout.flush()
    pef = parse_cc_graph.parseCCEdgeFile(fname)
    g = pef[0]
    ga = pef[1]
    resFx = pef[2]

    print 'Checking graph.',
    sys.stdout.flush()
    checkGraph(g, ga)

    print 'Running PyCC.',
    sys.stdout.flush()
    resPy = cycleCollect(g, ga)

    print 'Comparing results.',
    sys.stdout.flush()
    ok = checkResults(g, ga, resFx, 'Firefox cycle collector', resPy,
                      'Python cycle collector')
    if ok:
        print 'Ok.'
    else:
        print 'Error.'
        exit(-1)

    return ok
Beispiel #5
0
def loadGraph(fname):
  sys.stderr.write ('Parsing {0}. '.format(fname))
  (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
  #sys.stdout.write ('Converting to single graph. ')
  #sys.stdout.flush()
  g = parse_cc_graph.toSinglegraph(g)
  sys.stderr.write('Done loading graph. ')
  return (g, ga, res)
Beispiel #6
0
def loadGraph(fname):
    sys.stderr.write('Parsing {0}. '.format(fname))
    (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
    #sys.stdout.write ('Converting to single graph. ')
    #sys.stdout.flush()
    g = parse_cc_graph.toSinglegraph(g)
    sys.stderr.write('Done loading graph. ')
    return (g, ga, res)
def loadGraph(fname):
  sys.stdout.write ('Parsing {0}. '.format(fname))
  sys.stdout.flush()
  (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
  g = parse_cc_graph.toSinglegraph(g)
  print 'Done loading graph.',

  return (g, ga, res)
Beispiel #8
0
def loadGraph(fname):
  sys.stdout.write ('Parsing {0}. '.format(fname))
  sys.stdout.flush()
  (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
  #sys.stdout.write ('Converting to single graph. ') 
  #sys.stdout.flush()
  g = parse_cc_graph.toSinglegraph(g)
  ga = make_draw_attribs (ga, res)
  print 'Done loading graph.'
  return (g, ga, res)
Beispiel #9
0
def load_graph(fname):
  sys.stderr.write ('Parsing {0}. '.format(fname))
  (g, ga, res) = parse_cc_graph.parseCCEdgeFile(fname)
  sys.stderr.write('Done loading graph.\n')

  return (g, ga)
Beispiel #10
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import argparse
import collections
import parse_cc_graph


parser = argparse.ArgumentParser(description='Find objects with more references than their refcount')

parser.add_argument('file_name',
                    help='cycle collector graph file name')

args = parser.parse_args()
(g, ga, res) = parse_cc_graph.parseCCEdgeFile(args.file_name)


knownReferences = collections.defaultdict(lambda: 0)
for x, edges in g.iteritems():
    if not x in ga.rcNodes:
        continue
    for y, count in edges.iteritems():
        knownReferences[y] += count


for x in g.keys():
    if not x in ga.rcNodes:
        continue
    if knownReferences[x] > ga.rcNodes[x]:
        print 'Bad node {0} found (rc={1}, known={2})'.format(x, ga.rcNodes[x], knownReferences[x])
Beispiel #11
0
    if olbl != None:
        t += " {" + olbl + "}"
    if lbl != None:
        t += " " + lbl
    return t


def print_reverse_graph(g, ga):
    for src, outs in g.iteritems():
        print node_string(src, ga)
        for dst, numEdges in outs.iteritems():
            if (dst, src) in ga.edgeLabels:
                for ll in ga.edgeLabels[(dst, src)]:
                    print edge_string(dst, ll[0], ll[1])
                numEdges -= len(ga.edgeLabels[(dst, src)])
            for x in range(numEdges):
                print edge_string(dst, None, None)


if len(sys.argv) < 2:
    print "Not enough arguments."
    exit()


x = parse_cc_graph.parseCCEdgeFile(sys.argv[1])

r = parse_cc_graph.reverseMultigraph(x[0])
# assert(x[0] == parse_cc_graph.reverseMultigraph(r)

print_reverse_graph(r, x[1])
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import argparse
import collections
import parse_cc_graph

parser = argparse.ArgumentParser(
    description='Find objects with more references than their refcount')

parser.add_argument('file_name', help='cycle collector graph file name')

args = parser.parse_args()
(g, ga, res) = parse_cc_graph.parseCCEdgeFile(args.file_name)

knownReferences = collections.defaultdict(lambda: 0)
for x, edges in g.iteritems():
    if not x in ga.rcNodes:
        continue
    for y, count in edges.iteritems():
        knownReferences[y] += count

for x in g.keys():
    if not x in ga.rcNodes:
        continue
    if knownReferences[x] > ga.rcNodes[x]:
        print 'Bad node {0} found (rc={1}, known={2})'.format(
            x, ga.rcNodes[x], knownReferences[x])
        exit(-1)
Beispiel #13
0
    t = '> ' + dst
    if olbl != None:
        t += ' {' + olbl + '}'
    if lbl != None:
        t += ' ' + lbl
    return t


def print_reverse_graph(g, ga):
    for src, outs in g.iteritems():
        print node_string(src, ga)
        for dst, numEdges in outs.iteritems():
            if (dst, src) in ga.edgeLabels:
                for ll in ga.edgeLabels[(dst, src)]:
                    print edge_string(dst, ll[0], ll[1])
                numEdges -= len(ga.edgeLabels[(dst, src)])
            for x in range(numEdges):
                print edge_string(dst, None, None)


if len(sys.argv) < 2:
    print 'Not enough arguments.'
    exit()

x = parse_cc_graph.parseCCEdgeFile(sys.argv[1])

r = parse_cc_graph.reverseMultigraph(x[0])
#assert(x[0] == parse_cc_graph.reverseMultigraph(r)

print_reverse_graph(r, x[1])