@@ -63,21 +63,12 @@ def add_function(sizes, function, start_addr, end_addr, group_by_prefix):
63
63
sizes [function ] += size
64
64
65
65
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
-
75
66
def read_sizes (sect_sizes , seg_sizes , file_name , function_details ,
76
67
group_by_prefix ):
77
68
# Check if multiple architectures are supported by the object file.
78
69
# Prefer arm64 if available.
79
70
architectures = subprocess .check_output (
80
- ["otool" , "-V" , "-f" , file_name ]).split ("\n " )
71
+ ["otool" , "-V" , "-f" , file_name ]).decode ( 'utf-8' ). split ("\n " )
81
72
arch = None
82
73
arch_pattern = re .compile (r'architecture ([\S]+)' )
83
74
for architecture in architectures :
@@ -88,26 +79,23 @@ def read_sizes(sect_sizes, seg_sizes, file_name, function_details,
88
79
if "arm64" in arch :
89
80
arch = "arm64"
90
81
if arch is not None :
91
- arch_params = ["-arch" , arch ]
82
+ cmd = ["otool" , "-arch" , arch ]
92
83
else :
93
- arch_params = []
84
+ cmd = ["otool" ]
94
85
95
86
if function_details :
96
87
content = subprocess .check_output (
97
- flatten ([
98
- "otool" ,
99
- arch_params ,
88
+ cmd + [
100
89
"-l" ,
101
90
"-v" ,
102
91
"-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 + ["-v" , "-s" , "__TEXT" , "__textcoal_nt" ,
95
+ file_name ]).decode ('utf-8' ).split ("\n " )
108
96
else :
109
97
content = subprocess .check_output (
110
- flatten ([ "otool" , arch_params , "-l" , file_name ])).split ("\n " )
98
+ cmd + [ "-l" , file_name ]). decode ( 'utf-8' ).split ("\n " )
111
99
112
100
seg_name = None
113
101
sect_name = None
0 commit comments