Skip to content

Commit

Permalink
Check fault count before using the backup
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayurun committed Oct 16, 2023
1 parent b3ebef9 commit d9b2741
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def read_backup(hdf5_file):
"tb_info": bool(hdf5_flags["tb_info"][0]),
"mem_info": bool(hdf5_flags["mem_info"][0]),
"max_instruction_count": int(hdf5_flags["max_instruction_count"][0]),
"fault_count": int(hdf5_flags["fault_count"][0]),
"start": {
"address": int(hdf5_start_address["address"][0]),
"counter": int(hdf5_start_address["counter"][0]),
Expand Down Expand Up @@ -436,7 +437,7 @@ def read_backup(hdf5_file):
rows = f_in.root.Goldenrun.armregisters.iterrows()
else:
raise tables.NoSuchNodeError(
"No supported register architecture could be found in the HDF5 file"
"No supported register architecture could be found in the HDF5 file, run with the overwrite flag to overwrite"
)

backup_goldenrun[register_backup_name] = []
Expand All @@ -455,6 +456,14 @@ def read_backup(hdf5_file):
backup_goldenrun[register_backup_name].append(registers)

# Process expanded faults
if (
f_in.root.Backup.expanded_faults._v_nchildren
!= backup_config["fault_count"]
):
raise tables.NoSuchNodeError(
f"Out of {backup_config['fault_count']} faults, only {f_in.root.Backup.expanded_faults._v_nchildren} are available in the backup. Run with the overwrite flag to overwrite"
)

backup_expanded_faults = []
exp_n = 0

Expand Down Expand Up @@ -597,10 +606,8 @@ def controller(
"Backup could not be found in the HDF5 file, run with the overwrite flag to overwrite!"
)
return config_qemu
except tables.NoSuchNodeError:
clogger.warning(
"Invalid/unsupported backup file, run with the overwrite flag to overwrite!"
)
except tables.NoSuchNodeError as e:
clogger.warning(e)
return config_qemu

clogger.info("Checking the backup")
Expand Down
4 changes: 4 additions & 0 deletions hdf5logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class config_table(tables.IsDescription):
mem_info = tables.BoolCol()
max_instruction_count = tables.UInt64Col()
memory_dump = tables.BoolCol()
fault_count = tables.UInt64Col()


class hash_table(tables.IsDescription):
Expand Down Expand Up @@ -397,6 +398,7 @@ def process_config(f, configgroup, exp, myfilter):
config_row["tb_info"] = exp["tb_info"]
config_row["mem_info"] = exp["mem_info"]
config_row["max_instruction_count"] = exp["max_instruction_count"]
config_row["fault_count"] = exp["fault_count"]

config_row.append()

Expand Down Expand Up @@ -442,6 +444,8 @@ def process_config(f, configgroup, exp, myfilter):


def process_backup(f, configgroup, exp, myfilter, stop_signal):
exp["config"]["fault_count"] = len(exp["expanded_faultlist"])

process_config(f, configgroup, exp["config"], myfilter)

fault_expanded_group = f.create_group(
Expand Down

0 comments on commit d9b2741

Please sign in to comment.