summaryrefslogtreecommitdiff
path: root/tools/unnamed.py
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-10-04 21:03:31 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-10-04 21:03:31 -0400
commitd634097c586e4ca3513a7afd34f645be9c8022d2 (patch)
treeeac57610f45c86b4292d18607223e1364fee7c7d /tools/unnamed.py
parente128fbeadb6e9e6575581b7e5da03c9fee1ce2f6 (diff)
tools/unnamed.py -r . -l N prints up to N unnamed symbols next to their filenames
Diffstat (limited to 'tools/unnamed.py')
-rwxr-xr-xtools/unnamed.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/unnamed.py b/tools/unnamed.py
index 43e539c6..a178f385 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 ''))