GIF89a; EcchiShell v1.0
//lib64/lib64/lib64/lib64/python2.7/Tools/= 8: tabs = '\t' else: tabs = '\t\t' if not def2file.has_key(ext): print '\t' + ext + tabs + ' *undefined' else: print '\t' + ext + tabs + flat(def2file[ext]) # Print for each module the names of the other modules that use it. # def printcaller(): files = file2def.keys() files.sort() for filename in files: callers = [] for label in file2def[filename]: if undef2file.has_key(label): callers = callers + undef2file[label] if callers: callers.sort() print filename + ':' lastfn = '' for fn in callers: if fn <> lastfn: print '\t' + fn lastfn = fn else: print filename + ': unused' # Print undefined names and where they are used. # def printundef(): undefs = {} for filename in file2undef.keys(): for ext in file2undef[filename]: if not def2file.has_key(ext): store(undefs, ext, filename) elist = undefs.keys() elist.sort() for ext in elist: print ext + ':' flist = undefs[ext] flist.sort() for filename in flist: print '\t' + filename # Print warning messages about names defined in more than one file. # def warndups(): savestdout = sys.stdout sys.stdout = sys.stderr names = def2file.keys() names.sort() for name in names: if len(def2file[name]) > 1: print 'warning:', name, 'multiply defined:', print flat(def2file[name]) sys.stdout = savestdout # Main program # def main(): try: optlist, args = getopt.getopt(sys.argv[1:], 'cdu') except getopt.error: sys.stdout = sys.stderr print 'Usage:', os.path.basename(sys.argv[0]), print '[-cdu] [file] ...' print '-c: print callers per objectfile' print '-d: print callees per objectfile' print '-u: print usage of undefined symbols' print 'If none of -cdu is specified, all are assumed.' print 'Use "nm -o" to generate the input (on IRIX: "nm -Bo"),' print 'e.g.: nm -o /lib/libc.a | objgraph' return 1 optu = optc = optd = 0 for opt, void in optlist: if opt == '-u': optu = 1 elif opt == '-c': optc = 1 elif opt == '-d': optd = 1 if optu == optc == optd == 0: optu = optc = optd = 1 if not args: args = ['-'] for filename in args: if filename == '-': readinput(sys.stdin) else: readinput(open(filename, 'r')) # warndups() # more = (optu + optc + optd > 1) if optd: if more: print '---------------All callees------------------' printcallee() if optu: if more: print '---------------Undefined callees------------' printundef() if optc: if more: print '---------------All Callers------------------' printcaller() return 0 # Call the main program. # Use its return value as exit status. # Catch interrupts to avoid stack trace. # if __name__ == '__main__': try: sys.exit(main()) except KeyboardInterrupt: sys.exit(1)