Mark indirect links dashed
This commit is contained in:
+14
-7
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
"""graphdeps V0.05
|
"""graphdeps V0.06
|
||||||
Copyright (c) 2011 Michael P. Hayes, UC ECE, NZ
|
Copyright (c) 2011 Michael P. Hayes, UC ECE, NZ
|
||||||
|
|
||||||
Usage: graphdeps Makefile
|
Usage: graphdeps Makefile
|
||||||
@@ -74,10 +74,13 @@ def op_output (dotfile, op, name):
|
|||||||
dotfile.write ('\t"' + op + '"\t[shape=rectangle,label="' + name + '"];\n')
|
dotfile.write ('\t"' + op + '"\t[shape=rectangle,label="' + name + '"];\n')
|
||||||
|
|
||||||
|
|
||||||
def edge_output (dotfile, target, dep):
|
def edge_output (dotfile, target, dep, indirect):
|
||||||
|
|
||||||
# dotfile.write ('\t"' + target + '" ->\t"' + dep + '"\t[dir=back];\n')
|
# dotfile.write ('\t"' + target + '" ->\t"' + dep + '"\t[dir=back];\n')
|
||||||
dotfile.write ('\t"' + target + '" ->\t"' + dep + '";\n')
|
if indirect:
|
||||||
|
dotfile.write ('\t"' + target + '" ->\t"' + dep + '"\t[style="dashed"];\n')
|
||||||
|
else:
|
||||||
|
dotfile.write ('\t"' + target + '" ->\t"' + dep + '";\n')
|
||||||
|
|
||||||
|
|
||||||
def dep_output (dotfile, target, dep, modules, options):
|
def dep_output (dotfile, target, dep, modules, options):
|
||||||
@@ -91,12 +94,16 @@ def dep_output (dotfile, target, dep, modules, options):
|
|||||||
if dep == '':
|
if dep == '':
|
||||||
return
|
return
|
||||||
|
|
||||||
|
indirect = (dep[0] == '@')
|
||||||
|
if indirect:
|
||||||
|
dep = dep[1:]
|
||||||
|
|
||||||
dep = node_output (dotfile, dep, options)
|
dep = node_output (dotfile, dep, options)
|
||||||
|
|
||||||
(file, ext) = os.path.splitext (target)
|
(file, ext) = os.path.splitext (target)
|
||||||
|
|
||||||
if not options.showops:
|
if not options.showops:
|
||||||
edge_output (dotfile, target, dep)
|
edge_output (dotfile, target, dep, indirect)
|
||||||
else:
|
else:
|
||||||
if ext == '.o':
|
if ext == '.o':
|
||||||
op = 'Compiler'
|
op = 'Compiler'
|
||||||
@@ -108,11 +115,11 @@ def dep_output (dotfile, target, dep, modules, options):
|
|||||||
op = ''
|
op = ''
|
||||||
|
|
||||||
if op == '':
|
if op == '':
|
||||||
edge_output (dotfile, target, dep)
|
edge_output (dotfile, target, dep, indirect)
|
||||||
else:
|
else:
|
||||||
op_output (dotfile, op + target, op)
|
op_output (dotfile, op + target, op)
|
||||||
edge_output (dotfile, target, op + target)
|
edge_output (dotfile, target, op + target, indirect)
|
||||||
edge_output (dotfile, op + target, dep)
|
edge_output (dotfile, op + target, dep, indirect)
|
||||||
|
|
||||||
|
|
||||||
def target_output (dotfile, target, targets, modules, options, seen = {}):
|
def target_output (dotfile, target, targets, modules, options, seen = {}):
|
||||||
|
|||||||
+31
-4
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""makemake V0.05
|
"""makemake V0.06
|
||||||
Copyright (c) 2010 Michael P. Hayes, UC ECE, NZ
|
Copyright (c) 2010 Michael P. Hayes, UC ECE, NZ
|
||||||
|
|
||||||
This program tries to make a Makefile from a template. Given a C file
|
This program tries to make a Makefile from a template. Given a C file
|
||||||
@@ -267,7 +267,7 @@ def functions_find (gcc, filepath, functiondeps = {}):
|
|||||||
matches = re.findall (r'.*gimple_assign <addr_expr, [\w\[\].]*, ([\w]*)', line)
|
matches = re.findall (r'.*gimple_assign <addr_expr, [\w\[\].]*, ([\w]*)', line)
|
||||||
if matches and functiondeps.has_key (matches[0]):
|
if matches and functiondeps.has_key (matches[0]):
|
||||||
# This is an indirect link
|
# This is an indirect link
|
||||||
functiondeps[function].append (matches[0])
|
functiondeps[function].append ('@' + matches[0])
|
||||||
|
|
||||||
command = 'rm ' + rtlfilename
|
command = 'rm ' + rtlfilename
|
||||||
# print >> sys.stderr, command
|
# print >> sys.stderr, command
|
||||||
@@ -344,7 +344,7 @@ def deps_print (target, depsdir, options, record = {}):
|
|||||||
|
|
||||||
deps = depsdir[target]
|
deps = depsdir[target]
|
||||||
|
|
||||||
print >> sys.stderr, target + ': ', deps
|
# print >> sys.stderr, target + ': ', deps
|
||||||
|
|
||||||
deps = [dep for dep in deps if os.path.basename (dep) not in options.exclude]
|
deps = [dep for dep in deps if os.path.basename (dep) not in options.exclude]
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
@@ -362,6 +362,33 @@ def deps_print (target, depsdir, options, record = {}):
|
|||||||
print os.path.relpath (target) + ': ' + ' '.join (deps) + '\n'
|
print os.path.relpath (target) + ': ' + ' '.join (deps) + '\n'
|
||||||
|
|
||||||
|
|
||||||
|
def callgraph_print (target, depsdir, options, record = {}):
|
||||||
|
|
||||||
|
if record.has_key (target):
|
||||||
|
return
|
||||||
|
if not depsdir.has_key (target):
|
||||||
|
return
|
||||||
|
|
||||||
|
deps = depsdir[target]
|
||||||
|
|
||||||
|
# print >> sys.stderr, target + ': ', deps
|
||||||
|
|
||||||
|
deps = [dep for dep in deps if dep not in options.exclude]
|
||||||
|
for dep in deps:
|
||||||
|
# Have recursion
|
||||||
|
if target == dep:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if dep[0] == '@':
|
||||||
|
dep = dep[1:]
|
||||||
|
|
||||||
|
deps_print (dep, depsdir, options, record)
|
||||||
|
|
||||||
|
record[target] = True
|
||||||
|
|
||||||
|
print os.path.relpath (target) + ': ' + ' '.join (deps) + '\n'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Usage (Exception):
|
class Usage (Exception):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
@@ -499,7 +526,7 @@ def main(argv = None):
|
|||||||
if options.calls:
|
if options.calls:
|
||||||
for cfile in cfilelist:
|
for cfile in cfilelist:
|
||||||
functions_find (gcc, cfile, functiondeps)
|
functions_find (gcc, cfile, functiondeps)
|
||||||
deps_print ('main', functiondeps, options)
|
callgraph_print ('main', functiondeps, options)
|
||||||
|
|
||||||
if options.files:
|
if options.files:
|
||||||
deps_print (outfile, filedeps, options)
|
deps_print (outfile, filedeps, options)
|
||||||
|
|||||||
Reference in New Issue
Block a user