Skip to content

Commit d1bdfcb

Browse files
authored
Add pre-fuzzingcheckpoint to Simics 6 snapshot path (#90)
1 parent 75d5758 commit d1bdfcb

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ version = "0.2.1"
2121

2222
[package.metadata.simics]
2323
package-number = 31337
24-
version = "6.1.2"
24+
version = "6.1.3"
2525

2626
[lib]
2727
crate-type = ["cdylib", "rlib"]

src/lib.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ use serde_json::to_writer;
4747
use simics::{
4848
break_simulation, class, debug, error, free_attribute, get_class, get_interface,
4949
get_processor_number, info, lookup_file, object_clock, run_command, run_python, simics_init,
50-
trace, version_base, warn, AsConfObject, BreakpointId, ClassCreate, ClassObjectsFinalize,
51-
ConfObject, CoreBreakpointMemopHap, CoreExceptionHap, CoreMagicInstructionHap,
52-
CoreSimulationStoppedHap, CpuInstrumentationSubscribeInterface, Event, EventClassFlag,
53-
FromConfObject, HapHandle, Interface, IntoAttrValueDict,
50+
sys::save_flags_t, trace, version_base, warn, write_configuration_to_file, AsConfObject,
51+
BreakpointId, ClassCreate, ClassObjectsFinalize, ConfObject, CoreBreakpointMemopHap,
52+
CoreExceptionHap, CoreMagicInstructionHap, CoreSimulationStoppedHap,
53+
CpuInstrumentationSubscribeInterface, Event, EventClassFlag, FromConfObject, HapHandle,
54+
Interface, IntoAttrValueDict,
5455
};
5556
#[cfg(simics_version_6)]
5657
use simics::{
@@ -60,15 +61,13 @@ use simics::{
6061
// NOTE: save_snapshot used because it is a stable alias for both save_snapshot and take_snapshot
6162
// which is necessary because this module is compatible with base versions which cross the
6263
// deprecation boundary
63-
use simics::{restore_snapshot, save_snapshot, sys::save_flags_t, write_configuration_to_file};
64+
use simics::{restore_snapshot, save_snapshot};
6465
use state::StopReason;
65-
#[cfg(simics_version_7)]
66-
use std::fs::remove_dir_all;
6766
use std::{
6867
alloc::{alloc_zeroed, Layout},
6968
cell::OnceCell,
7069
collections::{hash_map::Entry, BTreeSet, HashMap, HashSet},
71-
fs::{create_dir_all, File},
70+
fs::{create_dir_all, remove_dir_all, File},
7271
hash::{DefaultHasher, Hash, Hasher},
7372
path::PathBuf,
7473
ptr::null_mut,
@@ -735,17 +734,17 @@ impl Tsffs {
735734

736735
#[cfg(simics_version_7)]
737736
{
738-
if self.checkpoint_path.exists() {
739-
remove_dir_all(&self.checkpoint_path)?;
740-
}
737+
if self.pre_snapshot_checkpoint {
738+
debug!(
739+
self.as_conf_object(),
740+
"Saving checkpoint to {}",
741+
self.checkpoint_path.display()
742+
);
741743

742-
debug!(
743-
self.as_conf_object(),
744-
"Saving checkpoint to {}",
745-
self.checkpoint_path.display()
746-
);
744+
if self.checkpoint_path.exists() {
745+
remove_dir_all(&self.checkpoint_path)?;
746+
}
747747

748-
if self.pre_snapshot_checkpoint {
749748
write_configuration_to_file(&self.checkpoint_path, save_flags_t(0))?;
750749
}
751750

@@ -759,6 +758,20 @@ impl Tsffs {
759758

760759
#[cfg(simics_version_6)]
761760
{
761+
if self.pre_snapshot_checkpoint {
762+
debug!(
763+
self.as_conf_object(),
764+
"Saving checkpoint to {}",
765+
self.checkpoint_path.display()
766+
);
767+
768+
if self.checkpoint_path.exists() {
769+
remove_dir_all(&self.checkpoint_path)?;
770+
}
771+
772+
write_configuration_to_file(&self.checkpoint_path, save_flags_t(0))?;
773+
}
774+
762775
debug!(self.as_conf_object(), "Saving initial micro checkpoint");
763776

764777
save_micro_checkpoint(

0 commit comments

Comments
 (0)