From f175145aed47eedfbe57880b7a05cc8f0886501c Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Sat, 21 Sep 2024 10:10:56 +0200 Subject: [PATCH] trace: Log line number on exception in DMA trace --- util/trace/gen_trace.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/trace/gen_trace.py b/util/trace/gen_trace.py index 9583a1758..0c1f4a898 100755 --- a/util/trace/gen_trace.py +++ b/util/trace/gen_trace.py @@ -585,8 +585,17 @@ def eval_dma_metrics(dma_trans, dma_trace): bursts_in_transfer = 0 rec_bursts = 0 # Iterate lines in DMA trace - for line in f.readlines(): - dma = ast.literal_eval(line) + for lineno, (line, nextl) in enumerate(current_and_next(f.readlines())): + try: + dma = ast.literal_eval(line) + except SyntaxError: + message = 'Exception occured while processing ' + if not nextl: + message += 'last line. Did the simulation terminate?' + else: + message += f'line {lineno}.' + print(traceback.format_exc(), file=sys.stderr) + print(message, file=sys.stderr) time = dma['meta']['time'] # When the first burst in a transfer is granted, we record a new transfer in # the outstanding transfers queue, with the information obtained from the core