shithub: pokered

Download patch

ref: b49277f485a390f211c7cb5418d2bf7852250010
parent: fbbade2becdbbbaad787ec4ad957b8b5253498c0
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Oct 4 17:03:36 EDT 2020

tools/unnamed.py -r . -l N prints up to N unnamed symbols next to their filenames

--- a/tools/unnamed.py
+++ b/tools/unnamed.py
@@ -32,6 +32,7 @@
 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 @@
             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 ''))