coverage: Update scripts
- Update coverage scripts to parse new tarmac format
- Update script command line arguments to take in specific binaries to
generate report for
- Make genhtml a separate step from this script
Change-Id: I9f39b1e4f305b3428189f858088f23c979c8b9a4
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/code_coverage/ingest_tarmac.py b/code_coverage/ingest_tarmac.py
index 64d9251..bc386e0 100755
--- a/code_coverage/ingest_tarmac.py
+++ b/code_coverage/ingest_tarmac.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
# -----------------------------------------------------------------------------
-# Copyright (c) 2024, Arm Limited. All rights reserved.
+# Copyright (c) 2024-2025, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -10,12 +10,28 @@
import logging
import re
import elftools
+from itertools import islice
-def parse_line(line: str) -> str:
+def parse_line_fvp(line: str) -> str:
split = line.split(" ")
- addr = split[5]
- size = len(split[6]) // 2
- logging.debug("Instruction at {} of size {}".format(addr, size))
+ try:
+ addr = split[5]
+ size = len(split[6]) // 2
+ logging.debug("Instruction at {} of size {}".format(addr, size))
+ except Exception as e:
+ print("Parse error {} for line {}".format(e,line))
+ raise Exception
+ return (addr, size)
+
+def parse_line_rtl(line: str) -> str:
+ try:
+ split = line.split(" ")[1].replace("(", "").replace(")", "").split(":")
+ addr = split[0]
+ size = len(split[1]) // 2
+ logging.debug("Instruction at {} of size {}".format(addr, size))
+ except Exception as e:
+ print("Parse error {} for line {}".format(e,line))
+ raise Exception
return (addr, size)
parser = argparse.ArgumentParser()
@@ -27,19 +43,26 @@
# logging setup
logging.basicConfig(level=args.log_level)
-with open(args.input_file, "rt") as input_file:
- trace = input_file.read()
-
-instructions = re.findall("[0-9]* [a-z]{2} [a-z\.]* IT .*", trace)
-
+instructions = []
+parse_function = parse_line_fvp
hit_counts = {}
-for i in instructions:
- addr = parse_line(i)
- if addr in hit_counts.keys():
- hit_counts[addr] += 1
- else:
- hit_counts[addr] = 1
+with open(args.input_file, "rt") as input_file:
+ while(lines := list(islice(input_file, 100000))):
+ lines = ''.join(lines)
+ chunk_instructions = re.findall(r'[0-9]* [a-z]{3} [a-z\.]* IT .*', lines)
+
+ if len(chunk_instructions) == 0:
+ chunk_instructions = re.findall(r'[0-9]* clk ES (.*:.*).*', lines)
+ if len(chunk_instructions) != 0:
+ parse_function = parse_line_rtl
+
+ for i in chunk_instructions:
+ addr = parse_function(i)
+ if addr in hit_counts.keys():
+ hit_counts[addr] += 1
+ else:
+ hit_counts[addr] = 1
with open(args.output_file, "w+") as output_file:
output_file.writelines(["{} {} {}\n".format(x[0], hit_counts[x], x[1]) for x in hit_counts.keys()])