+cflow_dir

This commit is contained in:
Costa Shulyupin 2018-08-07 09:11:55 +03:00
parent e2f1e3aefb
commit 83e17d2ee2
1 changed files with 30 additions and 23 deletions

View File

@ -721,27 +721,7 @@ def remove_loops(dg):
return dg return dg
def cflow_linux(): def cflow_dir(a):
dirs = ('init kernel kernel/time '
'fs fs/ext4 block '
'ipc net '
'lib security security/keys '
'arch/x86/kernel drivers/char drivers/pci '
).split()
# dirs += ('mm net/ipv4 crypto').split()
dirs = ('init kernel arch/x86/kernel fs ').split()
# fs/notify/fanotify fs/notify/inotify
try:
print('loading all.dot')
all = read_dot2('all.dot')
# all = nx.DiGraph(read_dot('all.dot'))
except FileNotFoundError:
all = nx.DiGraph()
for a in dirs:
print(a)
index = nx.DiGraph() index = nx.DiGraph()
for c in glob.glob(os.path.join(a, "*.c")): for c in glob.glob(os.path.join(a, "*.c")):
g = None g = None
@ -763,12 +743,39 @@ def cflow_linux():
index.add_edges_from(g.edges()) index.add_edges_from(g.edges())
write_dot(index, str(os.path.join(a, 'index.dot'))) write_dot(index, str(os.path.join(a, 'index.dot')))
digraph_print(digraph_tree(index), [], os.path.join(a, 'index.tree')) digraph_print(digraph_tree(index), [], os.path.join(a, 'index.tree'))
return index
def cflow_linux():
dirs = ('init kernel kernel/time '
'fs fs/ext4 block '
'ipc net '
'lib security security/keys '
'arch/x86/kernel drivers/char drivers/pci '
).split()
# dirs += ('mm net/ipv4 crypto').split()
dirs = ('init kernel arch/x86/kernel fs ').split()
# fs/notify/fanotify fs/notify/inotify
try:
print('loading all.dot')
all = read_dot2('all.dot')
# all = nx.DiGraph(read_dot('all.dot'))
except FileNotFoundError:
all = nx.DiGraph()
for a in dirs:
print(a)
index = cflow_dir(a)
# all.add_nodes_from(index.nodes()) # all.add_nodes_from(index.nodes())
all.add_edges_from(index.edges()) all.add_edges_from(index.edges())
write_dot(all, 'all.dot') write_dot(all, 'all.dot')
# print('loops: ' + str( all.nodes_with_selfloops())) remove_loops(all)
print('loops: ' + str(list(all.nodes_with_selfloops())))
print('trees:') print('trees:')
digraph_print(all, ['x86_64_start_kernel', 'start_kernel', 'main', 'initcall', 'early_param', '__setup', 'sys_write', 'write'], digraph_print(all, ['x86_64_start_kernel', 'start_kernel', 'main', 'initcall', 'early_param',
'__setup', 'sys_write', 'write'],
'all.tree') 'all.tree')
start_kernel = digraph_tree(all, ['start_kernel']) start_kernel = digraph_tree(all, ['start_kernel'])
write_dot(start_kernel, 'start_kernel.dot') write_dot(start_kernel, 'start_kernel.dot')