From fab458daa24c486f16fc18390db26442b0c7da87 Mon Sep 17 00:00:00 2001 From: atrah22 Date: Tue, 22 Aug 2023 01:06:50 -0700 Subject: [PATCH 1/2] util: Update & fix bug in m5stats2streamline.py 1) writeBinary function binary_list can have either string or ints and it needs to be properly converted to bytes 2) packed32(x) function can have x as int or float. Incase of float it needs to be converted to int Change-Id: I6a52aa59e1582dd6bb06b2d1c49ddaf8fe61c997 --- util/streamline/m5stats2streamline.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/streamline/m5stats2streamline.py b/util/streamline/m5stats2streamline.py index 8dc72bf0f9..85b263f304 100755 --- a/util/streamline/m5stats2streamline.py +++ b/util/streamline/m5stats2streamline.py @@ -221,6 +221,7 @@ def packed32(x): ret = [] more = True while more: + x = int(x) b = x & 0x7F x = x >> 7 if ((x == 0) and ((b & 0x40) == 0)) or ( @@ -383,7 +384,13 @@ def timestampList(x): def writeBinary(outfile, binary_list): for i in binary_list: - outfile.write(f"{i:c}") + if isinstance(i, str): + byteVal = bytes(i, "utf-8") + elif isinstance(i, int): + byteVal = bytes([i]) + else: + byteVal = i + outfile.write(byteVal) ############################################################ @@ -661,7 +668,7 @@ def parseProcessInfo(task_file): task_name_failure_warned = False for line in process_file: - match = re.match(process_re, line) + match = re.match(process_re, line.decode("ISO-8859-1")) if match: tick = int(match.group(1)) if start_tick < 0: From 99fc5de3fb33c1e67849db8dc9bd7555b5129665 Mon Sep 17 00:00:00 2001 From: atrah22 Date: Tue, 22 Aug 2023 03:48:51 -0700 Subject: [PATCH 2/2] util: Update & fix bug in m5stats2streamline.py 1) writeBinary function binary_list can have either string or ints and it needs to be properly converted to bytes 2) packed32(x) function can have x as int or float. Incase of float it needs to be converted to int 3) encode lines to string using .decode() or else TypeError will be invoked during run Change-Id: I678169f191901f02a80187418a17adbc1240c7d3 --- util/streamline/m5stats2streamline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/streamline/m5stats2streamline.py b/util/streamline/m5stats2streamline.py index 85b263f304..7e82744d0b 100755 --- a/util/streamline/m5stats2streamline.py +++ b/util/streamline/m5stats2streamline.py @@ -668,7 +668,7 @@ def parseProcessInfo(task_file): task_name_failure_warned = False for line in process_file: - match = re.match(process_re, line.decode("ISO-8859-1")) + match = re.match(process_re, line.decode()) if match: tick = int(match.group(1)) if start_tick < 0: