diff --git a/Cargo.toml b/Cargo.toml index 7b2b518f..cb1d6aff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ members = [ "modules/tsffs/src/util/command-ext", "modules/tsffs/src/util/ffi-macro", - "modules/tsffs/src/util/getters", "modules/tsffs/src/util/raw-cstr", "modules/tsffs/src/util/version-tools", ] @@ -50,7 +49,6 @@ default-members = [ "modules/tsffs/src/util/command-ext", "modules/tsffs/src/util/ffi-macro", - "modules/tsffs/src/util/getters", "modules/tsffs/src/util/raw-cstr", "modules/tsffs/src/util/version-tools", ] @@ -65,7 +63,6 @@ ispm-wrapper = { path = "modules/tsffs/src/simics/ispm-wrapper" } command-ext = { path = "modules/tsffs/src/util/command-ext" } ffi-macro = { path = "modules/tsffs/src/util/ffi-macro" } -getters = { path = "modules/tsffs/src/util/getters" } raw-cstr = { path = "modules/tsffs/src/util/raw-cstr" } version-tools = { path = "modules/tsffs/src/util/version-tools" } @@ -77,7 +74,7 @@ libafl_targets = { git = "https://github.com/AFLplusplus/LibAFL", default-featur ] } serde = { version = "1.0.188", features = ["derive"] } serde_json = { version = "1.0.107" } -versions = { version = "5.0.1", features = ["serde"] } +versions = { version = "6.0.0", features = ["serde"] } [profile.dev] diff --git a/modules/tsffs/src/simics/ispm-wrapper/Cargo.toml b/modules/tsffs/src/simics/ispm-wrapper/Cargo.toml index 83fca07f..208d68d4 100644 --- a/modules/tsffs/src/simics/ispm-wrapper/Cargo.toml +++ b/modules/tsffs/src/simics/ispm-wrapper/Cargo.toml @@ -17,9 +17,8 @@ version.workspace = true [dependencies] anyhow = { workspace = true } command-ext = { workspace = true } +getters2 = "0.1.2" serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } version-tools = { workspace = true } - -getters.workspace = true typed-builder = "0.18.0" diff --git a/modules/tsffs/src/simics/ispm-wrapper/src/data/mod.rs b/modules/tsffs/src/simics/ispm-wrapper/src/data/mod.rs index f6e9383c..3c76e835 100644 --- a/modules/tsffs/src/simics/ispm-wrapper/src/data/mod.rs +++ b/modules/tsffs/src/simics/ispm-wrapper/src/data/mod.rs @@ -4,7 +4,7 @@ //! Data deserializable from ISPM commands and configurations use anyhow::Result; -use getters::Getters; +use getters2::Getters; use serde::Deserialize; use serde_json::from_slice; use std::{fmt::Display, fs::read, path::PathBuf}; @@ -159,15 +159,19 @@ impl Settings { /// A package that is already installed pub struct InstalledPackage { #[serde(rename = "pkgNumber")] + #[getters(deref)] /// The package number package_number: isize, #[serde(deserialize_with = "version_constraint_from_string")] + #[getters(clone)] /// The package version version: VersionConstraint, #[builder(setter(into))] + #[getters(clone)] /// The package name name: String, #[builder(default, setter(into))] + #[getters(clone)] /// Paths to this installed package paths: Vec, } @@ -204,6 +208,7 @@ pub struct Packages { /// A package which is added to a project pub struct ProjectPackage { #[serde(rename = "pkgNumber")] + #[getters(deref)] /// The package number package_number: isize, #[serde(deserialize_with = "version_constraint_from_string")] diff --git a/modules/tsffs/src/simics/ispm-wrapper/src/lib.rs b/modules/tsffs/src/simics/ispm-wrapper/src/lib.rs index e690c0e8..011b39cb 100644 --- a/modules/tsffs/src/simics/ispm-wrapper/src/lib.rs +++ b/modules/tsffs/src/simics/ispm-wrapper/src/lib.rs @@ -71,7 +71,7 @@ pub trait ToArgs { pub mod ispm { use std::{iter::repeat, path::PathBuf}; - use getters::Getters; + use getters2::Getters; use typed_builder::TypedBuilder; use crate::{ToArgs, NON_INTERACTIVE_FLAG}; @@ -184,7 +184,7 @@ pub mod ispm { }; use anyhow::Result; use command_ext::CommandExtCheck; - use getters::Getters; + use getters2::Getters; use serde_json::from_slice; use std::{iter::repeat, path::PathBuf, process::Command}; use typed_builder::TypedBuilder; @@ -288,7 +288,7 @@ pub mod ispm { }; use anyhow::{anyhow, Result}; use command_ext::CommandExtCheck; - use getters::Getters; + use getters2::Getters; use serde_json::from_slice; use std::{collections::HashSet, iter::once, path::Path, process::Command}; use typed_builder::TypedBuilder; @@ -311,7 +311,7 @@ pub mod ispm { impl ToArgs for CreateOptions { fn to_args(&self) -> Vec { - self.packages() + self.packages_ref() .iter() .map(|p| Some(p.to_string())) .chain(once( diff --git a/modules/tsffs/src/simics/simics-macro/src/lib.rs b/modules/tsffs/src/simics/simics-macro/src/lib.rs index b50ec745..f3b4ca8d 100644 --- a/modules/tsffs/src/simics/simics-macro/src/lib.rs +++ b/modules/tsffs/src/simics/simics-macro/src/lib.rs @@ -1236,7 +1236,8 @@ impl TryIntoAttrValueTypeDictOpts { .filter_map(|f| { f.ident.clone().map(|i| { let ident_name = i.to_string(); - quote!((#ident_name.try_into()?, value.#i().clone().try_into()?)) + let accessor = format_ident!("{}_ref", i); + quote!((#ident_name.try_into()?, value.#accessor().clone().try_into()?)) }) }) .collect::>(); @@ -1302,9 +1303,10 @@ impl TryIntoAttrValueTypeListOpts { .iter() .filter(|f| !f.skip.is_present()) .filter_map(|f| { - f.ident - .clone() - .map(|i| quote!(value.#i().clone().try_into()?)) + f.ident.clone().map(|i| { + let accessor = format_ident!("{}_ref", i); + quote!(value.#accessor().clone().try_into()?) + }) }) .collect::>(); diff --git a/modules/tsffs/src/tsffs/Cargo.toml b/modules/tsffs/src/tsffs/Cargo.toml index b71ab018..961e2833 100644 --- a/modules/tsffs/src/tsffs/Cargo.toml +++ b/modules/tsffs/src/tsffs/Cargo.toml @@ -30,7 +30,7 @@ simics-macro = { workspace = true } yaxpeax-arch = "0.2.7" yaxpeax-x86 = "1.2.0" typed-builder = "0.18.0" -getters.workspace = true +getters2 = "0.1.2" serde_json.workspace = true goblin = "0.7.1" yaxpeax-riscv = { git = "https://github.com/novafacing/yaxpeax-riscv", version = "0.1.0", features = [ diff --git a/modules/tsffs/src/tsffs/src/arch/mod.rs b/modules/tsffs/src/tsffs/src/arch/mod.rs index 0731279c..849c7ebb 100644 --- a/modules/tsffs/src/tsffs/src/arch/mod.rs +++ b/modules/tsffs/src/tsffs/src/arch/mod.rs @@ -258,7 +258,7 @@ pub trait ArchitectureOperations { let addr_size = self.processor_info_v2().get_logical_address_width()? as usize / u8::BITS as usize; let initial_size = - size.initial_size() + size.initial_size_ref() .ok_or_else(|| anyhow!("Expected initial size for start"))? as usize; let physical_memory = self.processor_info_v2().get_physical_memory()?; diff --git a/modules/tsffs/src/tsffs/src/arch/x86.rs b/modules/tsffs/src/tsffs/src/arch/x86.rs index e9442d04..104124cd 100644 --- a/modules/tsffs/src/tsffs/src/arch/x86.rs +++ b/modules/tsffs/src/tsffs/src/arch/x86.rs @@ -428,7 +428,7 @@ impl ArchitectureOperations for X86ArchitectureOperations { let physical_memory = self.processor_info_v2().get_physical_memory()?; let initial_size = - size.initial_size() + size.initial_size_ref() .ok_or_else(|| anyhow!("Expected initial size for start"))? as usize; trace!( diff --git a/modules/tsffs/src/tsffs/src/configuration/mod.rs b/modules/tsffs/src/tsffs/src/configuration/mod.rs index a03372a3..0b7da5f5 100644 --- a/modules/tsffs/src/tsffs/src/configuration/mod.rs +++ b/modules/tsffs/src/tsffs/src/configuration/mod.rs @@ -3,7 +3,7 @@ use std::{ path::PathBuf, }; -use getters::Getters; +use getters2::Getters; use simics::api::{lookup_file, BreakpointId}; use simics_macro::TryIntoAttrValueTypeDict; use typed_builder::TypedBuilder; @@ -33,7 +33,7 @@ impl Configuration { } #[derive(TypedBuilder, Getters, Debug, Clone, TryIntoAttrValueTypeDict)] -#[getters(mutable)] +#[getters(deref, mutable)] pub struct Configuration { #[builder(default = false)] /// Whether any breakpoint that occurs during fuzzing is treated as a fault @@ -42,9 +42,11 @@ pub struct Configuration { /// Whether any CPU exception that occurs during fuzzing is treated as a solution all_exceptions_are_solutions: bool, #[builder(default)] + #[getters(skip_deref, clone)] /// The set of specific exception numbers that are treated as a solution exceptions: BTreeSet, #[builder(default)] + #[getters(skip_deref, clone)] /// The set of breakpoints to treat as solutions breakpoints: BTreeSet, #[builder(default = Configuration::DEFAULT_TIMEOUT_SECONDS)] @@ -66,14 +68,18 @@ pub struct Configuration { #[builder(default, setter(strip_option))] iterations: Option, #[builder(default)] + #[getters(skip_deref, clone)] tokens: Vec>, #[builder(default = lookup_file("%simics%").expect("No simics project root found").join(Configuration::DEFAULT_CORPUS_DIRECTORY_NAME))] + #[getters(skip_deref, clone)] corpus_directory: PathBuf, #[builder(default = lookup_file("%simics%").expect("No simics project root found").join(Configuration::DEFAULT_SOLUTIONS_DIRECTORY_NAME))] + #[getters(skip_deref, clone)] solutions_directory: PathBuf, #[builder(default = false)] generate_random_corpus: bool, #[builder(default)] + #[getters(skip_deref, clone)] token_files: Vec, #[builder(default = Configuration::DEFAULT_EXECUTOR_TIMEOUT)] /// The executor timeout in seconds @@ -83,6 +89,7 @@ pub struct Configuration { #[builder(default = true)] cmplog: bool, #[builder(default)] + #[getters(skip_deref, clone)] architecture_hints: HashMap, } diff --git a/modules/tsffs/src/tsffs/src/fuzzer/mod.rs b/modules/tsffs/src/tsffs/src/fuzzer/mod.rs index bff018b7..f16dd727 100644 --- a/modules/tsffs/src/tsffs/src/fuzzer/mod.rs +++ b/modules/tsffs/src/tsffs/src/fuzzer/mod.rs @@ -3,7 +3,7 @@ use crate::Tsffs; use anyhow::{anyhow, Result}; -use getters::Getters; +use getters2::Getters; use libafl::{ feedback_or, feedback_or_fast, prelude::{ @@ -41,7 +41,9 @@ pub mod tokenize; #[derive(Getters, Clone, PartialEq, Eq)] pub struct Testcase { + #[getters(clone)] testcase: Vec, + #[getters(deref)] cmplog: bool, } @@ -79,7 +81,7 @@ impl Tsffs { /// Start the fuzzing thread. pub fn start_fuzzer_thread(&mut self) -> Result<()> { - if self.fuzz_thread().is_some() { + if self.fuzz_thread_ref().is_some() { warn!(self.as_conf_object(), "Fuzz thread already started but start_fuzzer_thread called. Returning without error."); // We can only start the thread once return Ok(()); @@ -98,16 +100,16 @@ impl Tsffs { self.fuzzer_messages = Some(mrx); let client = RefCell::new((otx, orx)); - let configuration = self.configuration().clone(); + let configuration = self.configuration_clone(); let coverage_map = unsafe { from_raw_parts_mut( self.coverage_map_mut().as_mut_slice().as_mut_ptr(), Self::COVERAGE_MAP_SIZE, ) }; - let aflpp_cmp_map = Box::leak(unsafe { Box::from_raw(*self.aflpp_cmp_map_ptr()) }); - let aflpp_cmp_map_dup = Box::leak(unsafe { Box::from_raw(*self.aflpp_cmp_map_ptr()) }); - let cmplog_enabled = *self.configuration().cmplog(); + let aflpp_cmp_map = Box::leak(unsafe { Box::from_raw(*self.aflpp_cmp_map_ptr_ref()) }); + let aflpp_cmp_map_dup = Box::leak(unsafe { Box::from_raw(*self.aflpp_cmp_map_ptr_ref()) }); + let cmplog_enabled = *self.configuration_ref().cmplog_ref(); // NOTE: We do *not* use `run_in_thread` because it causes the fuzzer to block when HAPs arrive // which prevents forward progress. @@ -174,12 +176,12 @@ impl Tsffs { let timeout_feedback = TimeFeedback::new(Self::TIMEOUT_FEEDBACK_NAME); let solutions = OnDiskCorpus::with_meta_format( - configuration.solutions_directory(), + configuration.solutions_directory_ref(), OnDiskMetadataFormat::JsonPretty, )?; let corpus = CachedOnDiskCorpus::with_meta_format( - configuration.corpus_directory(), + configuration.corpus_directory_ref(), Self::CORPUS_CACHE_SIZE, Some(OnDiskMetadataFormat::Json), )?; @@ -203,10 +205,10 @@ impl Tsffs { let mut tokens = Tokens::default(); configuration - .token_files() + .token_files_ref() .iter() .try_for_each(|f| tokens.add_from_file(f).map(|_| ()))?; - tokens.add_tokens(configuration.tokens()); + tokens.add_tokens(configuration.tokens_ref()); state.add_metadata(tokens); let scheduler = @@ -270,11 +272,11 @@ impl Tsffs { ); let tracing_stage = TracingStage::new(tracing_executor); let synchronize_corpus_stage = - SyncFromDiskStage::with_from_file(configuration.corpus_directory().clone()); + SyncFromDiskStage::with_from_file(configuration.corpus_directory_clone()); let dump_corpus_stage = DumpToDiskStage::new( |input: &BytesInput, _state: &_| input.target_bytes().as_slice().to_vec(), - configuration.corpus_directory(), - configuration.solutions_directory(), + configuration.corpus_directory_ref(), + configuration.solutions_directory_ref(), )?; if state.must_load_initial_inputs() { @@ -282,17 +284,17 @@ impl Tsffs { &mut fuzzer, &mut executor, &mut manager, - &[configuration.corpus_directory().clone()], + &[configuration.corpus_directory_ref().clone()], )?; - if state.corpus().count() < 1 && *configuration.generate_random_corpus() { + if state.corpus().count() < 1 && *configuration.generate_random_corpus_ref() { let mut generator = RandBytesGenerator::new(64); state.generate_initial_inputs( &mut fuzzer, &mut executor, &mut generator, &mut manager, - *configuration.initial_random_corpus_size(), + configuration.initial_random_corpus_size_deref(), )?; } } @@ -366,7 +368,7 @@ impl Tsffs { } pub fn get_testcase(&mut self) -> Result { - let testcase = if let Some(testcase) = self.repro_testcase() { + let testcase = if let Some(testcase) = self.repro_testcase_ref() { debug!(self.as_conf_object(), "Using repro testcase"); Testcase { testcase: testcase.clone(), diff --git a/modules/tsffs/src/tsffs/src/haps/mod.rs b/modules/tsffs/src/tsffs/src/haps/mod.rs index be064ea2..8a39d82d 100644 --- a/modules/tsffs/src/tsffs/src/haps/mod.rs +++ b/modules/tsffs/src/tsffs/src/haps/mod.rs @@ -21,7 +21,7 @@ use simics::{ impl Tsffs { /// Called on core simulation stopped HAP pub fn on_simulation_stopped(&mut self) -> Result<()> { - if *self.stopped_for_repro() { + if self.stopped_for_repro_deref() { // If we are stopped for repro, we do nothing on this HAP! return Ok(()); } @@ -45,7 +45,7 @@ impl Tsffs { StopReason::MagicStart(magic_start) => { if !self.have_initial_snapshot() { self.start_fuzzer_thread()?; - self.add_processor(*magic_start.processor(), true)?; + self.add_processor(magic_start.processor_deref(), true)?; let (start_buffer, start_size) = { let start_processor = self @@ -86,27 +86,28 @@ impl Tsffs { StopReason::ManualStart(start) => { if !self.have_initial_snapshot() { self.start_fuzzer_thread()?; - self.add_processor(*start.processor(), true)?; + self.add_processor(start.processor_deref(), true)?; let (start_buffer, start_size) = { let start_processor = self .start_processor() .ok_or_else(|| anyhow!("No start processor"))?; ( - if let Some(buffer) = start.buffer() { + if let Some(buffer) = start.buffer_ref() { Some( start_processor - .get_manual_start_buffer(*buffer, *start.virt())?, + .get_manual_start_buffer(*buffer, start.virt_deref())?, ) } else { None }, - match start.size() { + match start.size_ref() { ManualStartSize::MaximumSize(s) => { Some(StartSize::builder().initial_size(*s).build()) } ManualStartSize::SizeAddress(a) => Some( - start_processor.get_manual_start_size(*a, *start.virt())?, + start_processor + .get_manual_start_size(*a, start.virt_deref())?, ), ManualStartSize::NoSize => None, }, @@ -123,9 +124,11 @@ impl Tsffs { *self.start_time_mut() = SystemTime::now(); *self.coverage_enabled_mut() = true; self.save_initial_snapshot()?; - if self.start_buffer().is_some() && self.start_size().is_some() { + + if self.start_buffer_ref().is_some() && self.start_size_ref().is_some() { self.get_and_write_testcase()?; } + self.post_timeout_event()?; } @@ -154,7 +157,7 @@ impl Tsffs { self.cmplog_hash() ); - if *self.repro_bookmark_set() { + if self.repro_bookmark_set_deref() { *self.stopped_for_repro_mut() = true; let current_log_level = log_level(self.as_conf_object_mut())?; @@ -174,11 +177,11 @@ impl Tsffs { *self.iterations_mut() += 1; if self - .configuration() - .iterations() - .is_some_and(|i| *self.iterations() >= i) + .configuration_ref() + .iterations_deref() + .is_some_and(|i| self.iterations_deref() >= i) { - let duration = SystemTime::now().duration_since(*self.start_time())?; + let duration = SystemTime::now().duration_since(self.start_time_deref())?; let current_log_level = log_level(self.as_conf_object_mut())?; // Set the log level so this message always prints @@ -189,9 +192,9 @@ impl Tsffs { info!( self.as_conf_object(), "Configured iteration count {} reached. Stopping after {} seconds ({} exec/s).", - self.iterations(), + self.iterations_ref(), duration.as_secs_f32(), - *self.iterations() as f32 / duration.as_secs_f32() + *self.iterations_ref() as f32 / duration.as_secs_f32() ); self.send_shutdown()?; @@ -208,7 +211,7 @@ impl Tsffs { self.restore_initial_snapshot()?; - if self.start_buffer().is_some() && self.start_size().is_some() { + if self.start_buffer_ref().is_some() && self.start_size_ref().is_some() { self.get_and_write_testcase()?; } else { debug!( @@ -232,7 +235,7 @@ impl Tsffs { self.cmplog_hash() ); - if *self.repro_bookmark_set() { + if self.repro_bookmark_set_deref() { *self.stopped_for_repro_mut() = true; let current_log_level = log_level(self.as_conf_object_mut())?; @@ -252,11 +255,11 @@ impl Tsffs { *self.iterations_mut() += 1; if self - .configuration() - .iterations() - .is_some_and(|i| *self.iterations() >= i) + .configuration_ref() + .iterations_deref() + .is_some_and(|i| self.iterations_deref() >= i) { - let duration = SystemTime::now().duration_since(*self.start_time())?; + let duration = SystemTime::now().duration_since(self.start_time_deref())?; // Set the log level so this message always prints set_log_level(self.as_conf_object_mut(), LogLevel::Info)?; @@ -264,9 +267,9 @@ impl Tsffs { info!( self.as_conf_object(), "Configured iteration count {} reached. Stopping after {} seconds ({} exec/s).", - self.iterations(), + self.iterations_ref(), duration.as_secs_f32(), - *self.iterations() as f32 / duration.as_secs_f32() + *self.iterations_ref() as f32 / duration.as_secs_f32() ); self.send_shutdown()?; @@ -279,7 +282,7 @@ impl Tsffs { .as_ref() .ok_or_else(|| anyhow!("No fuzzer tx channel"))?; - match solution.kind() { + match solution.kind_ref() { SolutionKind::Timeout => fuzzer_tx.send(ExitKind::Timeout)?, SolutionKind::Exception | SolutionKind::Breakpoint @@ -288,7 +291,7 @@ impl Tsffs { self.restore_initial_snapshot()?; - if self.start_buffer().is_some() && self.start_size().is_some() { + if self.start_buffer_ref().is_some() && self.start_size_ref().is_some() { self.get_and_write_testcase()?; } else { debug!( @@ -322,7 +325,7 @@ impl Tsffs { "Simulation stopped without reason, not resuming." ); - let duration = SystemTime::now().duration_since(*self.start_time())?; + let duration = SystemTime::now().duration_since(self.start_time_deref())?; // Set the log level so this message always prints set_log_level(self.as_conf_object_mut(), LogLevel::Info)?; @@ -330,9 +333,9 @@ impl Tsffs { info!( self.as_conf_object(), "Stopped after {} iterations in {} seconds ({} exec/s).", - self.iterations(), + self.iterations_ref(), duration.as_secs_f32(), - *self.iterations() as f32 / duration.as_secs_f32() + *self.iterations_ref() as f32 / duration.as_secs_f32() ); } @@ -342,8 +345,13 @@ impl Tsffs { /// Called on core exception HAP. Check to see if this exception is configured as a solution /// or all exceptions are solutions and trigger a stop if so pub fn on_exception(&mut self, _obj: *mut ConfObject, exception: i64) -> Result<()> { - if *self.configuration().all_exceptions_are_solutions() - || self.configuration().exceptions().contains(&exception) + if self + .configuration_ref() + .all_exceptions_are_solutions_deref() + || self + .configuration_ref() + .exceptions_ref() + .contains(&exception) { self.stop_simulation(StopReason::Solution( Solution::builder().kind(SolutionKind::Exception).build(), @@ -360,10 +368,12 @@ impl Tsffs { breakpoint: i64, transaction: *mut GenericTransaction, ) -> Result<()> { - if *self.configuration().all_breakpoints_are_solutions() + if self + .configuration_ref() + .all_breakpoints_are_solutions_deref() || self - .configuration() - .breakpoints() + .configuration_ref() + .breakpoints_ref() .contains(&(breakpoint as i32)) { info!( @@ -394,18 +404,18 @@ impl Tsffs { ); if object_is_processor(trigger_obj)? { - if *self.configuration().start_on_harness() - && magic_number == *self.configuration().magic_start() + if self.configuration_ref().start_on_harness_deref() + && magic_number == self.configuration_ref().magic_start_deref() { self.stop_simulation(StopReason::MagicStart( MagicStart::builder().processor(trigger_obj).build(), ))?; - } else if *self.configuration().stop_on_harness() - && magic_number == *self.configuration().magic_stop() + } else if self.configuration_ref().stop_on_harness_deref() + && magic_number == self.configuration_ref().magic_stop_deref() { self.stop_simulation(StopReason::MagicStop(Stop::default()))?; - } else if *self.configuration().stop_on_harness() - && magic_number == *self.configuration().magic_assert() + } else if self.configuration_ref().stop_on_harness_deref() + && magic_number == self.configuration_ref().magic_assert_deref() { self.stop_simulation(StopReason::Solution( Solution::builder().kind(SolutionKind::Manual).build(), diff --git a/modules/tsffs/src/tsffs/src/interface/mod.rs b/modules/tsffs/src/tsffs/src/interface/mod.rs index 5bc565ad..76e89edc 100644 --- a/modules/tsffs/src/tsffs/src/interface/mod.rs +++ b/modules/tsffs/src/tsffs/src/interface/mod.rs @@ -229,7 +229,7 @@ impl Tsffs { self.start_fuzzer_thread()?; } let testcase = self.get_testcase()?; - *self.cmplog_enabled_mut() = *testcase.cmplog(); + *self.cmplog_enabled_mut() = testcase.cmplog_deref(); trace!( self.as_conf_object(), "Coverage hash (before): {:#x}", @@ -245,7 +245,7 @@ impl Tsffs { ManualStart::builder().processor(cpu).build(), ))?; - testcase.testcase().clone().try_into() + testcase.testcase_clone().try_into() } /// Interface method to manually signal to stop a testcase execution. When this @@ -473,7 +473,7 @@ impl Tsffs { } pub fn get_configuration(&mut self) -> Result { - let value: AttrValueType = self.configuration().clone().try_into()?; + let value: AttrValueType = self.configuration_clone().try_into()?; Ok(AttrValue::try_from(value)?.into()) } @@ -597,7 +597,7 @@ impl Tsffs { *self.repro_testcase_mut() = Some(contents); - if *self.iterations() > 0 { + if self.iterations_deref() > 0 { // We've done an iteration already, so we need to reset and run self.restore_initial_snapshot()?; self.get_and_write_testcase()?; diff --git a/modules/tsffs/src/tsffs/src/lib.rs b/modules/tsffs/src/tsffs/src/lib.rs index 3fcfb08c..8bf2cf4a 100644 --- a/modules/tsffs/src/tsffs/src/lib.rs +++ b/modules/tsffs/src/tsffs/src/lib.rs @@ -35,12 +35,12 @@ use anyhow::{anyhow, Result}; use arch::{Architecture, ArchitectureOperations}; use configuration::Configuration; use fuzzer::{ShutdownMessage, Testcase}; -use getters::Getters; +use getters2::Getters; use libafl::prelude::ExitKind; use libafl_bolts::{prelude::OwnedMutSlice, AsSlice}; use libafl_targets::AFLppCmpLogMap; use serde::{Deserialize, Serialize}; -#[cfg(simics_experimentatl_api_snapshots)] +#[cfg(simics_experimental_api_snapshots)] use simics::api::{restore_snapshot, save_snapshot}; use simics::{ api::{ @@ -86,9 +86,11 @@ pub const CLASS_NAME: &str = env!("CARGO_PKG_NAME"); #[derive(TypedBuilder, Getters, Serialize, Deserialize, Clone, Debug)] pub struct StartBuffer { + #[getters(deref)] /// The physical address of the buffer. Must be physical, if the input address was /// virtual, it should be pre-translated pub physical_address: u64, + #[getters(deref)] /// Whether the address that translated to this physical address was virtual /// this should not be used or checked, it's simply informational pub virt: bool, @@ -119,6 +121,7 @@ pub struct Tsffs { /// The pointer to this instance. This is a self pointer. instance: *mut ConfObject, #[builder(default)] + #[getters(clone)] /// The configuration for the fuzzer configuration: Configuration, @@ -202,11 +205,13 @@ pub struct Tsffs { let layout = Layout::new::(); alloc_zeroed(layout) as *mut AFLppCmpLogMap })] + #[getters(deref)] /// Comparison logging map owned by the tracer aflpp_cmp_map_ptr: *mut AFLppCmpLogMap, #[builder(default = unsafe { &mut *aflpp_cmp_map_ptr})] aflpp_cmp_map: &'static mut AFLppCmpLogMap, #[builder(default = 0)] + #[getters(deref)] coverage_prev_loc: u64, // Registered events @@ -223,6 +228,7 @@ pub struct Tsffs { /// The name of the fuzz snapshot, if saved snapshot_name: Option, #[builder(default)] + #[getters(deref)] /// The index of the micro checkpoint saved for the fuzzer. Only present if not using /// snapshots. micro_checkpoint_index: Option, @@ -237,20 +243,25 @@ pub struct Tsffs { // Statistics #[builder(default = 0)] + #[getters(deref)] /// The number of fuzzing iterations run. Incremented on stop iterations: usize, #[builder(default = SystemTime::now())] + #[getters(deref)] /// The time the fuzzer was started at start_time: SystemTime, // State and settings #[builder(default = false)] + #[getters(deref)] /// Whether cmplog is currently enabled coverage_enabled: bool, #[builder(default = false)] + #[getters(deref)] /// Whether cmplog is currently enabled cmplog_enabled: bool, #[builder(default)] + #[getters(deref)] /// The number of the processor which starts the fuzzing loop (via magic or manual methods) start_processor_number: Option, #[builder(default)] @@ -261,8 +272,10 @@ pub struct Tsffs { /// A testcase to use for repro repro_testcase: Option>, #[builder(default)] + #[getters(deref)] repro_bookmark_set: bool, #[builder(default)] + #[getters(deref)] stopped_for_repro: bool, } @@ -295,13 +308,16 @@ impl Tsffs { pub fn add_processor(&mut self, cpu: *mut ConfObject, is_start: bool) -> Result<()> { let cpu_number = get_processor_number(cpu)?; - if !self.processors().contains_key(&cpu_number) { - let architecture = - if let Some(hint) = self.configuration().architecture_hints().get(&cpu_number) { - hint.architecture(cpu)? - } else { - Architecture::new(cpu)? - }; + if !self.processors_ref().contains_key(&cpu_number) { + let architecture = if let Some(hint) = self + .configuration_ref() + .architecture_hints_ref() + .get(&cpu_number) + { + hint.architecture(cpu)? + } else { + Architecture::new(cpu)? + }; self.processors_mut().insert(cpu_number, architecture); let mut cpu_interface: CpuInstrumentationSubscribeInterface = get_interface(cpu)?; cpu_interface.register_instruction_after_cb( @@ -324,15 +340,14 @@ impl Tsffs { } pub fn start_processor(&mut self) -> Option<&mut Architecture> { - self.start_processor_number() - .map(|n| self.processors_mut().get_mut(&n)) - .flatten() + self.start_processor_number_deref() + .and_then(|n| self.processors_mut().get_mut(&n)) } } impl Tsffs { pub fn save_initial_snapshot(&mut self) -> Result<()> { - if *self.configuration().use_snapshots() && self.snapshot_name().is_none() { + if self.configuration_ref().use_snapshots_deref() && self.snapshot_name_ref().is_none() { #[cfg(simics_experimental_api_snapshots)] { save_snapshot(Self::SNAPSHOT_NAME)?; @@ -340,9 +355,9 @@ impl Tsffs { } #[cfg(not(simics_experimental_api_snapshots))] panic!("Snapshots cannot be used without SIMICS support from recent SIMICS versions."); - } else if !self.configuration().use_snapshots() - && self.snapshot_name().is_none() - && self.micro_checkpoint_index().is_none() + } else if !self.configuration_ref().use_snapshots_deref() + && self.snapshot_name_ref().is_none() + && self.micro_checkpoint_index_ref().is_none() { save_micro_checkpoint( Self::SNAPSHOT_NAME, @@ -366,13 +381,13 @@ impl Tsffs { } pub fn restore_initial_snapshot(&mut self) -> Result<()> { - if *self.configuration().use_snapshots() { + if self.configuration_ref().use_snapshots_deref() { #[cfg(simics_experimental_api_snapshots)] restore_snapshot(Self::SNAPSHOT_NAME)?; #[cfg(not(simics_experimental_api_snapshots))] panic!("Snapshots cannot be used without SIMICS support from recent SIMICS versions."); } else { - restore_micro_checkpoint(self.micro_checkpoint_index().ok_or_else(|| { + restore_micro_checkpoint(self.micro_checkpoint_index_ref().ok_or_else(|| { anyhow!("Not using snapshots and no micro checkpoint index present") })?)?; @@ -383,14 +398,14 @@ impl Tsffs { } pub fn have_initial_snapshot(&self) -> bool { - (self.snapshot_name().is_some() && *self.configuration().use_snapshots()) - || (self.snapshot_name().is_some() - && self.micro_checkpoint_index().is_some() - && !self.configuration().use_snapshots()) + (self.snapshot_name_ref().is_some() && self.configuration_ref().use_snapshots_deref()) + || (self.snapshot_name_ref().is_some() + && self.micro_checkpoint_index_ref().is_some() + && !self.configuration_ref().use_snapshots_deref()) } pub fn save_repro_bookmark_if_needed(&mut self) -> Result<()> { - if self.repro_testcase().is_some() && !self.repro_bookmark_set() { + if self.repro_testcase_ref().is_some() && !self.repro_bookmark_set_deref() { free_attribute(run_command("set-bookmark start")?)?; *self.repro_bookmark_set_mut() = true; } @@ -404,17 +419,17 @@ impl Tsffs { pub fn get_and_write_testcase(&mut self) -> Result<()> { let testcase = self.get_testcase()?; - *self.cmplog_enabled_mut() = *testcase.cmplog(); + *self.cmplog_enabled_mut() = testcase.cmplog_deref(); // TODO: Fix cloning - refcell? let start_buffer = self - .start_buffer() + .start_buffer_ref() .as_ref() .ok_or_else(|| anyhow!("No start buffer"))? .clone(); let start_size = self - .start_size() + .start_size_ref() .as_ref() .ok_or_else(|| anyhow!("No start size"))? .clone(); @@ -423,7 +438,7 @@ impl Tsffs { .start_processor() .ok_or_else(|| anyhow!("No start processor"))?; - start_processor.write_start(testcase.testcase(), &start_buffer, &start_size)?; + start_processor.write_start(testcase.testcase_ref(), &start_buffer, &start_size)?; Ok(()) } @@ -436,18 +451,18 @@ impl Tsffs { let start_processor_time = start_processor.cycle().get_time()?; let start_processor_cpu = start_processor.cpu(); let start_processor_clock = object_clock(start_processor_cpu)?; - let timeout_time = *self.configuration().timeout() + start_processor_time; + let timeout_time = self.configuration_ref().timeout_deref() + start_processor_time; trace!( self.as_conf_object(), "Posting event on processor at time {} for {}s (time {})", start_processor_time, - *self.configuration().timeout(), + self.configuration_ref().timeout_deref(), timeout_time ); - self.timeout_event().post_time( + self.timeout_event_ref().post_time( start_processor_cpu, start_processor_clock, - *self.configuration().timeout(), + self.configuration_ref().timeout_deref(), move |obj| { let tsffs: &'static mut Tsffs = tsffs_ptr.into(); info!(tsffs.as_conf_object_mut(), "timeout({:#x})", obj as usize); @@ -468,7 +483,7 @@ impl Tsffs { let start_processor_cpu = start_processor.cpu(); let start_processor_clock = object_clock(start_processor_cpu)?; match self - .timeout_event() + .timeout_event_ref() .find_next_time(start_processor_clock, start_processor_cpu) { Ok(next_time) => trace!( @@ -484,20 +499,20 @@ impl Tsffs { "Not cancelling event with next time due to error: {e}" ), } - self.timeout_event() + self.timeout_event_ref() .cancel_time(start_processor_cpu, start_processor_clock)?; } Ok(()) } pub fn coverage_hash(&self) -> u32 { - crc32fast::hash(self.coverage_map().as_slice()) + crc32fast::hash(self.coverage_map_ref().as_slice()) } pub fn cmplog_hash(&self) -> u32 { crc32fast::hash(unsafe { from_raw_parts( - *self.aflpp_cmp_map_ptr() as *const u8, + self.aflpp_cmp_map_ptr_deref() as *const u8, size_of::(), ) }) diff --git a/modules/tsffs/src/tsffs/src/state/mod.rs b/modules/tsffs/src/tsffs/src/state/mod.rs index dc33b449..07438ee6 100644 --- a/modules/tsffs/src/tsffs/src/state/mod.rs +++ b/modules/tsffs/src/tsffs/src/state/mod.rs @@ -4,7 +4,7 @@ //! Definitions for tracking the state of the fuzzer use anyhow::{anyhow, Error, Result}; -use getters::Getters; +use getters2::Getters; use serde::{Deserialize, Serialize}; use serde_json::{from_str, to_string}; use simics::api::ConfObject; @@ -23,12 +23,14 @@ pub enum ManualStartSize { pub struct ManualStart { #[builder(default = null_mut())] #[serde(skip, default = "null_mut")] + #[getters(deref)] processor: *mut ConfObject, #[builder(default, setter(into, strip_option))] buffer: Option, #[builder(default = ManualStartSize::NoSize)] size: ManualStartSize, #[builder(default)] + #[getters(deref)] virt: bool, } @@ -37,6 +39,7 @@ pub struct ManualStart { pub struct MagicStart { #[builder(default = null_mut())] #[serde(skip, default = "null_mut")] + #[getters(deref)] processor: *mut ConfObject, } diff --git a/modules/tsffs/src/tsffs/src/tracer/mod.rs b/modules/tsffs/src/tsffs/src/tracer/mod.rs index dcf1e700..02ba074f 100644 --- a/modules/tsffs/src/tsffs/src/tracer/mod.rs +++ b/modules/tsffs/src/tsffs/src/tracer/mod.rs @@ -3,7 +3,7 @@ use anyhow::{anyhow, bail, Error, Result}; use ffi_macro::ffi; -use getters::Getters; +use getters2::Getters; use libafl::prelude::CmpValues; use libafl_bolts::{AsMutSlice, AsSlice}; use libafl_targets::{AFLppCmpLogOperands, AFLPP_CMPLOG_MAP_H, AFL_CMP_TYPE_INS}; @@ -126,6 +126,7 @@ fn hash_index(value: u64, len: u64) -> u64 { #[derive(TypedBuilder, Debug, Clone, Getters, PartialEq, Eq)] pub struct TraceEntry { #[builder(default, setter(into, strip_option))] + #[getters(deref)] /// The target of an edge in the trace edge: Option, #[builder(default, setter(into, strip_option))] @@ -205,11 +206,13 @@ impl From for AttrValueType { impl Tsffs { fn log_pc(&mut self, pc: u64) -> Result<()> { - let afl_idx = (pc ^ self.coverage_prev_loc) % self.coverage_map().as_slice().len() as u64; - let mut cur_byte: Wrapping = Wrapping(self.coverage_map().as_slice()[afl_idx as usize]); + let afl_idx = + (pc ^ self.coverage_prev_loc) % self.coverage_map_ref().as_slice().len() as u64; + let mut cur_byte: Wrapping = + Wrapping(self.coverage_map_ref().as_slice()[afl_idx as usize]); cur_byte += 1; self.coverage_map_mut().as_mut_slice()[afl_idx as usize] = cur_byte.0; - self.coverage_prev_loc = (pc >> 1) % self.coverage_map().as_slice().len() as u64; + self.coverage_prev_loc = (pc >> 1) % self.coverage_map_ref().as_slice().len() as u64; Ok(()) } @@ -220,7 +223,7 @@ impl Tsffs { let operands = cmp .to_u64_tuple() .ok_or_else(|| anyhow!("Conversion to tuple of non-integral operands not supported"))?; - let pc_index = hash_index(pc, self.aflpp_cmp_map().headers().len() as u64); + let pc_index = hash_index(pc, self.aflpp_cmp_map_ref().headers().len() as u64); let hits = self.aflpp_cmp_map_mut().headers_mut()[pc_index as usize].hits(); @@ -269,12 +272,12 @@ impl Tsffs { ) -> Result<()> { let processor_number = get_processor_number(cpu)?; - if *self.coverage_enabled() { + if self.coverage_enabled_deref() { if let Some(arch) = self.processors_mut().get_mut(&processor_number) { match arch.trace_pc(handle) { Ok(r) => { - if let Some(pc) = r.edge() { - self.log_pc(*pc)?; + if let Some(pc) = r.edge_deref() { + self.log_pc(pc)?; } } Err(_) => { @@ -305,11 +308,11 @@ impl Tsffs { ) -> Result<()> { let processor_number = get_processor_number(cpu)?; - if *self.configuration().cmplog() && *self.cmplog_enabled() { + if self.configuration_ref().cmplog_deref() && self.cmplog_enabled_deref() { if let Some(arch) = self.processors_mut().get_mut(&processor_number) { match arch.trace_cmp(handle) { Ok(r) => { - if let Some((pc, types, cmp)) = r.cmp() { + if let Some((pc, types, cmp)) = r.cmp_ref() { self.log_cmp(*pc, types.clone(), cmp.clone())?; } } diff --git a/modules/tsffs/src/util/getters/Cargo.toml b/modules/tsffs/src/util/getters/Cargo.toml deleted file mode 100644 index cca3005d..00000000 --- a/modules/tsffs/src/util/getters/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -[package] -name = "getters" -categories.workspace = true -description = "Macro for deriving getters and mutable getters for all fields of a struct" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -publish.workspace = true -readme.workspace = true -repository.workspace = true -version.workspace = true - - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -proc-macro = true - -[dependencies] -proc-macro2 = "1.0.56" -quote = "1.0.26" -syn = { version = "2.0.15", features = ["full"] } -darling = "0.20.3" - -[dev-dependencies] -anyhow.workspace = true -trybuild = "1.0.80" - diff --git a/modules/tsffs/src/util/getters/src/lib.rs b/modules/tsffs/src/util/getters/src/lib.rs deleted file mode 100644 index 8a32b8ae..00000000 --- a/modules/tsffs/src/util/getters/src/lib.rs +++ /dev/null @@ -1,112 +0,0 @@ -use darling::{ast::Data, util::Flag, FromDeriveInput, FromField}; -use proc_macro::TokenStream; -use proc_macro2::TokenStream as TokenStream2; -use quote::{format_ident, quote, ToTokens}; -use syn::{parse_macro_input, DeriveInput, Generics, Ident, Type}; - -#[derive(Debug, FromField)] -#[darling(attributes(getters))] -struct GettersField { - ident: Option, - ty: Type, - mutable: Flag, - skip: Flag, -} - -#[derive(Debug, FromDeriveInput)] -#[darling( - attributes(getters), - supports(struct_named), - forward_attrs(allow, doc, cfg) -)] -struct Getters { - ident: Ident, - generics: Generics, - data: Data<(), GettersField>, - mutable: Flag, -} - -impl ToTokens for Getters { - fn to_tokens(&self, tokens: &mut TokenStream2) { - let ident = &self.ident; - let (impl_generics, ty_generics, where_clause) = self.generics.split_for_impl(); - - let fields = self - .data - .as_ref() - .take_struct() - .expect("Expected named struct") - .fields; - - let fields = fields - .iter() - .filter(|f| !f.skip.is_present()) - .map(|f| { - let ident = f.ident.as_ref().unwrap(); - let ty = &f.ty; - let mutable = f.mutable.is_present() || self.mutable.is_present(); - - let immutable = quote! { - #[inline(always)] - /// Return a reference to the #ident field - pub fn #ident(&self) -> &#ty { - &self.#ident - } - }; - - if mutable { - let ident_mut = format_ident!("{}_mut", ident); - quote! { - #immutable - - #[inline(always)] - /// Return a mutable reference to the #ident field - pub fn #ident_mut(&mut self) -> &mut #ty { - &mut self.#ident - } - } - } else { - immutable - } - }) - .collect::(); - - tokens.extend(quote! { - impl #impl_generics #ident #ty_generics #where_clause { - #fields - } - }); - } -} - -#[proc_macro_derive(Getters, attributes(getters))] -#[allow(non_snake_case)] -/// Add immutable and (optionally) mutable accessors for every field of a struct -/// -/// ```rust,ignore -/// use getters::Getters; -/// -/// #[derive(Getters)] -/// pub struct Foo { -/// x: i32, -/// } -/// -/// let f = Foo { x: 0 }; -/// assert_eq!(f.x(), 0); -/// *f.eq_mut() = 1; -/// assert_eq!(f.x(), 1); -/// ``` -pub fn Getters(input: TokenStream) -> TokenStream { - let getters = match Getters::from_derive_input(&parse_macro_input!(input as DeriveInput)) { - Ok(g) => g, - Err(e) => { - return TokenStream::from(e.write_errors()); - } - }; - - let mut tokens = TokenStream2::new(); - - getters.to_tokens(&mut tokens); - - tokens.into() -} diff --git a/modules/tsffs/tests/Cargo.toml b/modules/tsffs/tests/Cargo.toml index 8fed4a35..fe6f3fec 100644 --- a/modules/tsffs/tests/Cargo.toml +++ b/modules/tsffs/tests/Cargo.toml @@ -18,7 +18,7 @@ version.workspace = true anyhow = { workspace = true } cargo_metadata = "0.18.1" command-ext.workspace = true -getters.workspace = true +getters2 = "0.1.2" indoc = "2.0.4" ispm-wrapper.workspace = true typed-builder = "0.18.0" diff --git a/modules/tsffs/tests/build.rs b/modules/tsffs/tests/build.rs index ced22b95..781b044d 100644 --- a/modules/tsffs/tests/build.rs +++ b/modules/tsffs/tests/build.rs @@ -11,11 +11,11 @@ const TESTS_FILE: &str = "tests.rs"; fn main() -> Result<()> { let packages = ispm::packages::list(&GlobalOptions::default())?; let base = packages - .installed_packages() + .installed_packages_ref() .as_ref() .ok_or_else(|| anyhow!("No installed packages"))? .iter() - .find(|p| p.package_number() == &1000isize) + .find(|p| p.package_number_deref() == 1000isize) .ok_or_else(|| anyhow!("No base in installed packages"))?; let out_dir = PathBuf::from( @@ -42,7 +42,7 @@ fn main() -> Result<()> { .current_dir(targets_dir) .env( "SIMICS_BASE", - base.paths() + base.paths_ref() .first() .ok_or_else(|| anyhow!("No path to base package"))? .to_string_lossy() diff --git a/modules/tsffs/tests/src/lib.rs b/modules/tsffs/tests/src/lib.rs index 946a4569..4186639c 100644 --- a/modules/tsffs/tests/src/lib.rs +++ b/modules/tsffs/tests/src/lib.rs @@ -4,8 +4,8 @@ //! SIMICS test utilities for test environment setup and configuration use anyhow::{anyhow, bail, ensure, Result}; +use getters2::Getters; use cargo_metadata::MetadataCommand; -use getters::Getters; use ispm_wrapper::{ data::ProjectPackage, ispm::{ @@ -74,19 +74,20 @@ pub fn local_or_remote_pkg_install(mut options: InstallOptions) -> Result<()> { } else { let installed = ispm::packages::list(&GlobalOptions::default())?; - for package in options.packages() { - let Some(installed) = installed.installed_packages() else { + for package in options.packages_ref() { + let Some(installed) = installed.installed_packages_ref() else { bail!("Did not get any installed packages"); }; let Some(available) = installed.iter().find(|p| { - p.package_number() == package.package_number() && p.version() == package.version() + p.package_number_deref() == package.package_number_deref() + && p.version_ref() == package.version_ref() }) else { bail!("Did not find package {package:?} in {installed:?}"); }; - let Some(path) = available.paths().first() else { + let Some(path) = available.paths_ref().first() else { bail!("No paths for available package {available:?}"); }; - let Some(install_dir) = options.global().install_dir() else { + let Some(install_dir) = options.global_ref().install_dir_ref() else { bail!("No install dir for global options {options:?}"); }; @@ -111,7 +112,7 @@ pub fn local_or_remote_pkg_install(mut options: InstallOptions) -> Result<()> { // Clear the remote packages to install, we can install local paths no problem options.packages_mut().clear(); - if !options.package_paths().is_empty() { + if !options.package_paths_ref().is_empty() { ispm::packages::install(&options)?; } } @@ -213,7 +214,7 @@ pub struct TestEnv { impl TestEnv { pub fn simics_base_dir(&self) -> Result { - read_dir(self.simics_home_dir())? + read_dir(self.simics_home_dir_ref())? .filter_map(|d| d.ok()) .filter(|d| d.path().is_dir()) .map(|d| d.path()) @@ -405,11 +406,11 @@ impl TestEnv { .build(), )?; - if let Some(installed) = installed.installed_packages() { + if let Some(installed) = installed.installed_packages_ref() { installed_packages.extend(installed.iter().map(|ip| { ProjectPackage::builder() - .package_number(*ip.package_number()) - .version(ip.version().clone()) + .package_number(ip.package_number_deref()) + .version(ip.version_clone()) .build() })); } @@ -456,7 +457,7 @@ impl TestEnv { } pub fn cleanup(&mut self) -> Result<()> { - remove_dir_all(self.test_dir()).map_err(|e| anyhow!("Error cleaning up: {e}")) + remove_dir_all(self.test_dir_ref()).map_err(|e| anyhow!("Error cleaning up: {e}")) } pub fn cleanup_if_env(&mut self) -> Result<()> { diff --git a/modules/tsffs/tests/tests/riscv_64.rs b/modules/tsffs/tests/tests/riscv_64.rs index 5fe4ec00..9c30f148 100644 --- a/modules/tsffs/tests/tests/riscv_64.rs +++ b/modules/tsffs/tests/tests/riscv_64.rs @@ -28,7 +28,7 @@ fn test_riscv_64_kernel_from_userspace_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -63,7 +63,7 @@ fn test_riscv_64_kernel_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -98,7 +98,7 @@ fn test_riscv_64_userspace_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") diff --git a/modules/tsffs/tests/tests/x86.rs b/modules/tsffs/tests/tests/x86.rs index fb7dc5d9..fea131de 100644 --- a/modules/tsffs/tests/tests/x86.rs +++ b/modules/tsffs/tests/tests/x86.rs @@ -40,7 +40,7 @@ fn test_x86_user_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") diff --git a/modules/tsffs/tests/tests/x86_64.rs b/modules/tsffs/tests/tests/x86_64.rs index 8e11032d..d257f25d 100644 --- a/modules/tsffs/tests/tests/x86_64.rs +++ b/modules/tsffs/tests/tests/x86_64.rs @@ -30,7 +30,7 @@ fn test_x86_64_edk2_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -63,7 +63,7 @@ fn test_x86_64_magic_crash() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -97,7 +97,7 @@ fn test_x86_64_timeout_edk2() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -131,7 +131,7 @@ fn test_x86_64_magic() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -169,7 +169,7 @@ fn test_x86_64_manual() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win") @@ -207,7 +207,7 @@ fn test_x86_64_manual_max() -> Result<()> { .to_env()?; let output = Command::new("./simics") - .current_dir(env.project_dir()) + .current_dir(env.project_dir_ref()) .arg("--batch-mode") .arg("-no-gui") .arg("--no-win")