diff --git a/fuzzer/src/depot/depot.rs b/fuzzer/src/depot/depot.rs index e8daeca..f1d3c19 100644 --- a/fuzzer/src/depot/depot.rs +++ b/fuzzer/src/depot/depot.rs @@ -11,6 +11,7 @@ use std::{ atomic::{AtomicUsize, Ordering}, Mutex, RwLock, }, + time::{SystemTime, UNIX_EPOCH}, }; // https://crates.io/crates/priority-queue use angora_common::config; @@ -23,6 +24,14 @@ pub struct Depot { pub num_crashes: AtomicUsize, pub dirs: DepotDir, pub cfg: RwLock, + pub start_time: u128, +} + +macro_rules! get_cur_time { + () => {{ + SystemTime::now().duration_since(UNIX_EPOCH) + .expect("Cannot get timestamp").as_millis() + }} } impl Depot { @@ -33,7 +42,7 @@ impl Depot { num_hangs: AtomicUsize::new(0), num_crashes: AtomicUsize::new(0), dirs: DepotDir::new(in_dir, out_dir), - cfg + cfg, start_time: get_cur_time!() } } @@ -43,6 +52,7 @@ impl Depot { num: &AtomicUsize, cmpid: u32, dir: &Path, + time: Option ) -> usize { let id = num.fetch_add(1, Ordering::Relaxed); trace!( @@ -51,7 +61,7 @@ impl Depot { status, cmpid ); - let new_path = get_file_name(dir, id); + let new_path = get_file_name(dir, id, time); let mut f = fs::File::create(new_path.as_path()).expect("Could not save new input file."); f.write_all(buf) .expect("Could not write seed buffer to file."); @@ -62,10 +72,10 @@ impl Depot { pub fn save(&self, status: StatusType, buf: &Vec, cmpid: u32) -> usize { match status { StatusType::Normal => { - Self::save_input(&status, buf, &self.num_inputs, cmpid, &self.dirs.inputs_dir) + Self::save_input(&status, buf, &self.num_inputs, cmpid, &self.dirs.inputs_dir, None) }, StatusType::Timeout => { - Self::save_input(&status, buf, &self.num_hangs, cmpid, &self.dirs.hangs_dir) + Self::save_input(&status, buf, &self.num_hangs, cmpid, &self.dirs.hangs_dir, None) }, StatusType::Crash => Self::save_input( &status, @@ -73,6 +83,7 @@ impl Depot { &self.num_crashes, cmpid, &self.dirs.crashes_dir, + Some(get_cur_time!() - self.start_time) ), _ => 0, } @@ -87,7 +98,7 @@ impl Depot { } pub fn get_input_buf(&self, id: usize) -> Vec { - let path = get_file_name(&self.dirs.inputs_dir, id); + let path = get_file_name(&self.dirs.inputs_dir, id, None); read_from_file(&path) } diff --git a/fuzzer/src/depot/file.rs b/fuzzer/src/depot/file.rs index e29d021..a037c81 100644 --- a/fuzzer/src/depot/file.rs +++ b/fuzzer/src/depot/file.rs @@ -4,8 +4,11 @@ use std::{ path::{Path, PathBuf}, }; -pub fn get_file_name(dir: &Path, id: usize) -> PathBuf { - let file_name = format!("id:{:06}", id); +pub fn get_file_name(dir: &Path, id: usize, time: Option) -> PathBuf { + let file_name = match time { + Some(t) => format!("id:{:06},{}", id, t), + None => format!("id:{:06}", id) + }; dir.join(file_name) } diff --git a/tools/llvm-diff-parmesan/id-assigner-pass/src/IDAssigner.cpp b/tools/llvm-diff-parmesan/id-assigner-pass/src/IDAssigner.cpp index 009035b..895d9a1 100644 --- a/tools/llvm-diff-parmesan/id-assigner-pass/src/IDAssigner.cpp +++ b/tools/llvm-diff-parmesan/id-assigner-pass/src/IDAssigner.cpp @@ -92,6 +92,7 @@ Constant *ParmeSanDummyCall; void IDAssigner::collectCallSiteDominators(Function *F) { for (auto &BB : *F) { CallSiteIdType PrevCallSiteId; + bool HasPrevCallSiteId = false; for (auto &I : BB) { if (StoreInst *SI = dyn_cast(&I)) { Value *V = SI->getPointerOperand(); @@ -102,6 +103,7 @@ void IDAssigner::collectCallSiteDominators(Function *F) { if (CV) { if (ConstantInt *ConstInt = dyn_cast(CV)) { PrevCallSiteId = ConstInt->getZExtValue(); + HasPrevCallSiteId = true; } } } @@ -130,7 +132,8 @@ void IDAssigner::collectCallSiteDominators(Function *F) { } } - CallSiteDominatorsMap[PrevCallSiteId] = CSDominatorCmpIds; + if (HasPrevCallSiteId) + CallSiteDominatorsMap[PrevCallSiteId] = CSDominatorCmpIds; } } @@ -434,6 +437,9 @@ void IDAssigner::addCustomTargetsFromFile(const std::string Path, Module *M) { static const std::string Xlibs("/usr/"); if (filename.empty() || line == 0 || !filename.compare(0, Xlibs.size(), Xlibs)) continue; + std::size_t found0 = filename.find_last_of("/\\"); + if (found0 != std::string::npos) + filename = filename.substr(found0 + 1); for (auto &target : targets) { std::size_t found = target.find_last_of("/\\"); if (found != std::string::npos)