Tweak debug

main
Michael Hayes 15 years ago
parent 3c9984fac2
commit 40fc9822b8

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
"""makemake V0.07 """makemake V0.08
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
@ -224,14 +224,14 @@ def maincfilename_find (dirname):
return filelist[0] return filelist[0]
def functions_find (gcc, filepath, functiondeps = {}, functions = {}): def functions_find (filepath, functiondeps, functions, options):
command = gcc + ' -c ' + filepath + ' -fdump-tree-cfg-raw -fno-inline > /dev/null' command = options.compile + ' -c ' + filepath + ' -fdump-tree-cfg-raw -fno-inline > /dev/null'
#print >> sys.stderr, command if options.debug:
print >> sys.stderr, command
os.system (command) os.system (command)
rtlfilename = os.path.abspath (os.path.basename (filepath)) + '.012t.cfg' rtlfilename = os.path.abspath (os.path.basename (filepath)) + '.012t.cfg'
# print >> sys.stderr, rtlfilename
if not os.path.exists (rtlfilename): if not os.path.exists (rtlfilename):
return return
@ -242,17 +242,17 @@ def functions_find (gcc, filepath, functiondeps = {}, functions = {}):
function = None function = None
for line in text: for line in text:
#print >> sys.stderr, line
#matches = re.findall (r'^(.*)\s[(][)]', line)
matches = re.findall (r'^;; Function (.*)\s[(]', line) matches = re.findall (r'^;; Function (.*)\s[(]', line)
if matches: if matches:
function = matches[0] function = matches[0]
functiondeps[function] = [] functiondeps[function] = []
functions[function] = filepath functions[function] = filepath
# print >> sys.stderr, 'DEF', function if options.debug:
print >> sys.stderr, 'DEF', function
matches = re.findall (r'.*gimple_call <([\w]*),', line) matches = re.findall (r'.*gimple_call <([\w]*),', line)
if matches: if matches:
# print >> sys.stderr, 'USE', matches[0] if options.debug:
print >> sys.stderr, 'USE', matches[0]
if function: if function:
functiondeps[function].append (matches[0]) functiondeps[function].append (matches[0])
else: else:
@ -271,8 +271,9 @@ def functions_find (gcc, filepath, functiondeps = {}, functions = {}):
functiondeps[function].append ('@' + matches[0]) functiondeps[function].append ('@' + matches[0])
command = 'rm ' + rtlfilename command = 'rm ' + rtlfilename
# print >> sys.stderr, command if options.debug:
# os.system (command) print >> sys.stderr, command
os.system (command)
def files_find (filepath, search_path, filedeps, moduledeps, indent, debug): def files_find (filepath, search_path, filedeps, moduledeps, indent, debug):
@ -345,8 +346,6 @@ def deps_print (target, depsdir, options, record = {}):
deps = depsdir[target] deps = depsdir[target]
# 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:
# Have recursion # Have recursion
@ -372,8 +371,6 @@ def callgraph_print (target, functiondeps, functions, options, record = {}):
deps = functiondeps[target] deps = functiondeps[target]
# print >> sys.stderr, target + ': ', deps
deps = [dep for dep in deps if dep not in options.exclude] deps = [dep for dep in deps if dep not in options.exclude]
for dep in deps: for dep in deps:
# Have recursion # Have recursion
@ -481,14 +478,18 @@ def main(argv = None):
if len (args) > 1: if len (args) > 1:
search_list.extend (args[1:len (args)]) search_list.extend (args[1:len (args)])
if options.debug:
print >> sys.stderr, search_list
search_path = pathsep.join (search_list) search_path = pathsep.join (search_list)
includes = '-I' + ' -I'.join (search_list)
options.compile = options.cc + ' ' + options.cflags + ' ' + includes
if options.debug: if options.debug:
print >> sys.stderr, search_list
print >> sys.stderr, 'template', options.template print >> sys.stderr, 'template', options.template
print >> sys.stderr, 'cfile', maincfilename print >> sys.stderr, 'cfile', maincfilename
print >> sys.stderr, 'search_path', search_path print >> sys.stderr, 'search_path', search_path
print >> sys.stderr, 'CWD = ', os.getcwd() print >> sys.stderr, 'CWD = ', os.getcwd()
print >> sys.stderr, options.compile
if os.path.isdir (maincfilename): if os.path.isdir (maincfilename):
if options.debug: if options.debug:
@ -500,11 +501,6 @@ def main(argv = None):
if options.debug: if options.debug:
print >> sys.stderr, 'Found C file ' + maincfilename print >> sys.stderr, 'Found C file ' + maincfilename
includes = '-I' + ' -I'.join (search_list)
gcc = options.cc + ' ' + options.cflags + ' ' + includes
if options.debug:
print >> sys.stderr, gcc
# Search main c file looking for header files included with #include # Search main c file looking for header files included with #include
# and any header files included by the header files # and any header files included by the header files
@ -526,7 +522,7 @@ def main(argv = None):
functiondeps = {} functiondeps = {}
functions = {} functions = {}
for cfile in cfilelist: for cfile in cfilelist:
functions_find (gcc, cfile, functiondeps, functions) functions_find (cfile, functiondeps, functions, options)
callgraph_print ('main', functiondeps, functions, options) callgraph_print ('main', functiondeps, functions, options)
if options.files: if options.files:

Loading…
Cancel
Save