diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-10-04 21:03:36 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-10-04 21:03:36 -0400 |
commit | b49277f485a390f211c7cb5418d2bf7852250010 (patch) | |
tree | 77ad846c91d7f06fb1011cd4d39ac5edea3a28a9 | |
parent | fbbade2becdbbbaad787ec4ad957b8b5253498c0 (diff) |
tools/unnamed.py -r . -l N prints up to N unnamed symbols next to their filenames
-rwxr-xr-x | tools/unnamed.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/unnamed.py b/tools/unnamed.py index 8235bdb8..803685df 100755 --- a/tools/unnamed.py +++ b/tools/unnamed.py @@ -32,6 +32,7 @@ import argparse parser = argparse.ArgumentParser(description="Parse the symfile to find unnamed symbols") parser.add_argument('symfile', type=argparse.FileType('r'), help="the list of symbols") parser.add_argument('-r', '--rootdir', type=str, help="scan the output files to obtain a list of files with unnamed symbols (NOTE: will rebuild objects as necessary)") +parser.add_argument('-l', '--list', type=int, default=0, help="output this many of each file's unnamed symbols (NOTE: requires -r)") args = parser.parse_args() # Get list of object files @@ -97,10 +98,12 @@ for objfile in objects: continue if sym_filename not in files: - files[sym_filename] = 0 - files[sym_filename] += 1 + files[sym_filename] = [] + files[sym_filename].append(sym_name) # Sort the files, the one with the most amount of symbols first -files = sorted([(fname, files[fname]) for fname in files], key=lambda x: x[1], reverse=True) +files = sorted(((f, files[f]) for f in files), key=lambda x: len(x[1]), reverse=True) for f in files: - print("%s: %d" % (f[0], f[1])) + filename, unnamed = f + sym_list = ', '.join(unnamed[:args.list]) + print("%s: %d%s" % (filename, len(unnamed), ': ' + sym_list if sym_list else '')) |