VeeR-ISS icon indicating copy to clipboard operation
VeeR-ISS copied to clipboard

Snapshot mechanism is not working expectedly as of version 1.689

Open crusader-yb opened this issue 2 years ago • 0 comments

Hi, I'd like to point out that starting in version 1.689, the snapshot mechanism is not working expectedly as given by the --snapshotperiod parameter.

Expected behavior

Dump memories each time after a given number of instructions are executed.

Actual behavior

As of version 1.689, the parameter acts very similar to --maxinst parameter. It would end the simulation when the number of instruction executed reaches the period, with no snapshots being saved.

How to reproduce

whisper --snapshotperiod 10 --verbose --target <riscv-elf-executable-file>

Diagnosis

The problem seems to appear after the following commit:

https://github.com/chipsalliance/SweRV-ISS/blob/c7b9660fa7249d06d4a845451a7cf723537dbd16/whisper.cpp#L1477

where a loop was inserted in the snapshotRun() function, causing the done flag being set before snapshot mechanism is triggered, as showing below:

while(hart.privilegeMode() != PrivilegeMode::User and not hart.hasTargetProgramFinished())
  hart.singleStep(traceFile);
if (hart.hasTargetProgramFinished())
  done = true;
if (not done)
  {
   // Save snapshot
  }

If changing the while loop to a if statement, the behavior seems to come back to normal. However I have not looked in further to make sure it is a proper fix for the issue.

Thank you.

crusader-yb avatar May 06 '22 04:05 crusader-yb