6
6
import sys
7
7
8
8
9
+ useCSV = False
10
+
11
+
9
12
def main (arguments ):
10
13
parser = argparse .ArgumentParser (
11
14
description = 'Analyze the code size in a binary' )
@@ -16,13 +19,20 @@ def main(arguments):
16
19
default = False )
17
20
parser .add_argument ('-list-category' , type = str ,
18
21
help = 'list symbols in category' )
22
+ parser .add_argument ('-csv' , dest = 'use_csv' , action = 'store_true' ,
23
+ help = 'print results as csv' )
19
24
parser .add_argument ('-uncategorized' , action = 'store_true' ,
20
25
help = 'show all uncategorized symbols' ,
21
26
dest = 'show_uncategorized' ,
22
27
default = False )
23
28
parser .add_argument ('bin' , help = 'the binary' )
29
+ parser .set_defaults (use_csv = False )
24
30
25
31
args = parser .parse_args (arguments )
32
+ if args .use_csv :
33
+ global useCSV
34
+ useCSV = True
35
+ print ("Using csv" )
26
36
27
37
segments = parse_segments (args .bin , args .arch )
28
38
@@ -216,11 +226,15 @@ def print_summary(self, section_size):
216
226
total_size += size
217
227
if size > 0 :
218
228
sorted_categories .append (
219
- (name , size , (float (size ) * 100 ) / section_size ))
220
- sorted_categories .sort (key = lambda entry : entry [1 ], reverse = True )
229
+ (name , size , (float (size ) * 100 ) / section_size ))
230
+ sorted_categories .sort (key = lambda entry : entry [1 ], reverse = True )
221
231
for category in sorted_categories :
222
- print ("%60s: %8d (%6.2f%%)" %
223
- (category [0 ], category [1 ], category [2 ]))
232
+ if useCSV :
233
+ print ("%s;%d;%.2f%%" %
234
+ (category [0 ], category [1 ], category [2 ]))
235
+ else :
236
+ print ("%60s: %8d (%6.2f%%)" %
237
+ (category [0 ], category [1 ], category [2 ]))
224
238
print ("%60s: %8d (%6.2f%%)" % ('TOTAL' , total_size , float (100 )))
225
239
226
240
def uncatorizedSymbols (self ):
0 commit comments