From 3d381ebd09e1e5d3166a86c920407aef27e5eb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20=C3=9Cr=C3=BCn?= Date: Thu, 17 Aug 2023 10:01:49 +0200 Subject: [PATCH] Allocate strings for hdf5 dynamically --- hdf5logger.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/hdf5logger.py b/hdf5logger.py index 0ad6f18..ac0c425 100644 --- a/hdf5logger.py +++ b/hdf5logger.py @@ -26,19 +26,6 @@ # Tables for storing the elements from queue -class translation_block_table(tables.IsDescription): - identity = tables.UInt64Col() - size = tables.UInt64Col() - ins_count = tables.UInt64Col() - num_exec = tables.UInt64Col() - assembler = tables.StringCol(1000) - - -class translation_block_faulted_table(tables.IsDescription): - faultaddress = tables.UInt64Col() - assembler = tables.StringCol(1000) - - class translation_block_exec_table(tables.IsDescription): tb = tables.UInt64Col() pos = tables.UInt64Col() @@ -135,6 +122,14 @@ class riscv_registers_table(tables.IsDescription): def process_tb_faulted(f, group, tbfaulted_list, myfilter): + assembler_size = max( + (len(tbfaulted["assembly"]) for tbfaulted in tbfaulted_list), default=1 + ) + + class translation_block_faulted_table(tables.IsDescription): + faultaddress = tables.UInt64Col() + assembler = tables.StringCol(assembler_size) + tbfaultedtable = f.create_table( group, "tbfaulted", @@ -252,6 +247,15 @@ def process_faults(f, group, faultlist, endpoint, end_reason, myfilter): def process_tbinfo(f, group, tbinfolist, myfilter): + assembler_size = max((len(tbinfo["assembler"]) for tbinfo in tbinfolist), default=1) + + class translation_block_table(tables.IsDescription): + identity = tables.UInt64Col() + size = tables.UInt64Col() + ins_count = tables.UInt64Col() + num_exec = tables.UInt64Col() + assembler = tables.StringCol(assembler_size) + tbinfotable = f.create_table( group, "tbinfo",