@@ -63,21 +63,12 @@ def add_function(sizes, function, start_addr, end_addr, group_by_prefix):
6363 sizes [function ] += size
6464
6565
66- def flatten (* args ):
67- for x in args :
68- if hasattr (x , '__iter__' ):
69- for y in flatten (* x ):
70- yield y
71- else :
72- yield x
73-
74-
7566def read_sizes (sect_sizes , seg_sizes , file_name , function_details ,
7667 group_by_prefix ):
7768 # Check if multiple architectures are supported by the object file.
7869 # Prefer arm64 if available.
7970 architectures = subprocess .check_output (
80- ["otool" , "-V" , "-f" , file_name ]).split ("\n " )
71+ ["otool" , "-V" , "-f" , file_name ]).decode ( 'utf-8' ). split ("\n " )
8172 arch = None
8273 arch_pattern = re .compile (r'architecture ([\S]+)' )
8374 for architecture in architectures :
@@ -88,26 +79,27 @@ def read_sizes(sect_sizes, seg_sizes, file_name, function_details,
8879 if "arm64" in arch :
8980 arch = "arm64"
9081 if arch is not None :
91- arch_params = ["-arch" , arch ]
82+ cmd = ["otool" , "-arch" , arch ]
9283 else :
93- arch_params = []
84+ cmd = ["otool" ]
9485
9586 if function_details :
9687 content = subprocess .check_output (
97- flatten ([
98- "otool" ,
99- arch_params ,
88+ cmd + [
10089 "-l" ,
10190 "-v" ,
10291 "-t" ,
103- file_name ]
104- )).split ("\n " )
105- content += subprocess .check_output (flatten (
106- ["otool" , arch_params , "-v" , "-s" , "__TEXT" , "__textcoal_nt" ,
107- file_name ])).split ("\n " )
92+ file_name ]).decode ('utf-8' ).split ("\n " )
93+ content += subprocess .check_output (
94+ cmd + [
95+ "-v" ,
96+ "-s" ,
97+ "__TEXT" ,
98+ "__textcoal_nt" ,
99+ file_name ]).decode ('utf-8' ).split ("\n " )
108100 else :
109101 content = subprocess .check_output (
110- flatten ([ "otool" , arch_params , "-l" , file_name ])).split ("\n " )
102+ cmd + [ "-l" , file_name ]). decode ( 'utf-8' ).split ("\n " )
111103
112104 seg_name = None
113105 sect_name = None
0 commit comments