Skip to content

Commit 95f4b5f

Browse files
committed
Fix the cmpcodesize script
It didn't survive the python3 upgrade well.
1 parent fb01667 commit 95f4b5f

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

utils/cmpcodesize/cmpcodesize/compare.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
7566
def 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,23 @@ 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 + ["-v", "-s", "__TEXT", "__textcoal_nt",
95+
file_name]).decode('utf-8').split("\n")
10896
else:
10997
content = subprocess.check_output(
110-
flatten(["otool", arch_params, "-l", file_name])).split("\n")
98+
cmd + ["-l", file_name]).decode('utf-8').split("\n")
11199

112100
seg_name = None
113101
sect_name = None

0 commit comments

Comments
 (0)