tor/scripts/maint/display_callgraph.py
Nick Mathewson bb46630513 Hack up the scripts/maint/*callgraph* scripts to do more, better
These scripts are now a little more bulletproof, cache data a little
better, and generate more information.  Notably, they search for the
vectors or edges to cut that would lower the size of the largest
SCC.
2015-08-15 22:37:32 -04:00

40 lines
952 B
Python
Executable File

#!/usr/bin/python
import cPickle
data = cPickle.load(open("callgraph.pkl"))
callgraph = data['callgraph']
closure = data['closure']
sccs = data['sccs']
fn_bottle, call_bottle = data['bottlenecks']
for n_reachable, fn in sorted(list((len(r), fn) for fn, r in closure.iteritems())):
print "%s can reach %s other functions." %(fn, n_reachable)
c = [ (len(component), component) for component in sccs ]
c.sort()
print "\n================================"
for n, component in c:
if n < 2:
continue
print "Strongly connected component of size %d:"%n
print component
print "\n================================"
print "====== Number of functions pulled into blob, by function in blob."
fn_bottle.sort()
for n, fn in fn_bottle[-30:]:
print "%3d: %s"%(n, fn)
print "====== Number of functions pulled into blob, by call in blob."
call_bottle.sort()
for n, fn1, _, fn2 in call_bottle[-30:]:
print "%3d: %s -> %s "%(n, fn2, fn1)