move codepieces
This commit is contained in:
parent
c5c9a052e4
commit
d8a15adb1d
@ -36,6 +36,7 @@ pub enum CaptureEvent {
|
||||
Undefined,
|
||||
}
|
||||
|
||||
// ============================= State info
|
||||
|
||||
/// Raw info Dump from Qemu
|
||||
#[derive(Debug, Default)]
|
||||
@ -179,6 +180,8 @@ impl fmt::Display for ReducedFreeRTOSSystemState {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================= Interval info
|
||||
|
||||
// #[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
// pub enum ExecLevel {
|
||||
// APP = 0,
|
||||
@ -244,51 +247,9 @@ impl ExecInterval {
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapper around Vec<RefinedFreeRTOSSystemState> to attach as Metadata
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||
pub struct FreeRTOSSystemStateMetadata {
|
||||
pub inner: Vec<ReducedFreeRTOSSystemState>,
|
||||
// TODO: Add abbs and memory reads
|
||||
trace_length: usize,
|
||||
indices: Vec<usize>, // Hashed enumeration of States
|
||||
tcref: isize,
|
||||
}
|
||||
impl FreeRTOSSystemStateMetadata {
|
||||
pub fn new(inner: Vec<ReducedFreeRTOSSystemState>) -> Self{
|
||||
let tmp = inner.iter().enumerate().map(|x| compute_hash(x) as usize).collect();
|
||||
Self {trace_length: inner.len(), inner: inner, indices: tmp, tcref: 0}
|
||||
}
|
||||
}
|
||||
pub fn compute_hash<T>(obj: T) -> u64
|
||||
where
|
||||
T: Hash
|
||||
{
|
||||
let mut s = DefaultHasher::new();
|
||||
obj.hash(&mut s);
|
||||
s.finish()
|
||||
}
|
||||
|
||||
// impl AsSlice for FreeRTOSSystemStateMetadata {
|
||||
// /// Convert the slice of system-states to a slice of hashes over enumerated states
|
||||
// fn as_slice(&self) -> &[usize] {
|
||||
// self.indices.as_slice()
|
||||
// }
|
||||
|
||||
// type Entry = usize;
|
||||
// }
|
||||
|
||||
impl HasRefCnt for FreeRTOSSystemStateMetadata {
|
||||
fn refcnt(&self) -> isize {
|
||||
self.tcref
|
||||
}
|
||||
|
||||
fn refcnt_mut(&mut self) -> &mut isize {
|
||||
&mut self.tcref
|
||||
}
|
||||
}
|
||||
|
||||
libafl_bolts::impl_serdeany!(FreeRTOSSystemStateMetadata);
|
||||
// ============================= Atomic Basic Block
|
||||
|
||||
/// A single-entry multiple-exit region between api calls. May be used referenced in multiple intervals.
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
pub struct AtomicBasicBlock {
|
||||
start: GuestAddr,
|
||||
@ -300,7 +261,7 @@ pub struct AtomicBasicBlock {
|
||||
|
||||
impl PartialEq for AtomicBasicBlock {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.start == other.start && self.ends == other.ends && self.level == other.level
|
||||
self.start == other.start && self.ends == other.ends && self.level == other.level && self.instance_name == other.instance_name
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,6 +274,7 @@ impl Hash for AtomicBasicBlock {
|
||||
let mut keys : Vec<_> = self.ends.iter().collect();
|
||||
keys.sort();
|
||||
self.level.hash(state);
|
||||
self.instance_name.hash(state);
|
||||
keys.hash(state);
|
||||
}
|
||||
}
|
||||
@ -393,3 +355,50 @@ fn get_task_names(trace: &Vec<ReducedFreeRTOSSystemState>) -> HashSet<String> {
|
||||
}
|
||||
|
||||
libafl_bolts::impl_serdeany!(AtomicBasicBlock);
|
||||
|
||||
// ============================= Per testcase metadata
|
||||
|
||||
// Wrapper around Vec<RefinedFreeRTOSSystemState> to attach as Metadata
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||
pub struct FreeRTOSSystemStateMetadata {
|
||||
pub inner: Vec<ReducedFreeRTOSSystemState>,
|
||||
// TODO: Add abbs and memory reads
|
||||
trace_length: usize,
|
||||
indices: Vec<usize>, // Hashed enumeration of States
|
||||
tcref: isize,
|
||||
}
|
||||
impl FreeRTOSSystemStateMetadata {
|
||||
pub fn new(inner: Vec<ReducedFreeRTOSSystemState>) -> Self{
|
||||
let tmp = inner.iter().enumerate().map(|x| compute_hash(x) as usize).collect();
|
||||
Self {trace_length: inner.len(), inner: inner, indices: tmp, tcref: 0}
|
||||
}
|
||||
}
|
||||
pub fn compute_hash<T>(obj: T) -> u64
|
||||
where
|
||||
T: Hash
|
||||
{
|
||||
let mut s = DefaultHasher::new();
|
||||
obj.hash(&mut s);
|
||||
s.finish()
|
||||
}
|
||||
|
||||
// impl AsSlice for FreeRTOSSystemStateMetadata {
|
||||
// /// Convert the slice of system-states to a slice of hashes over enumerated states
|
||||
// fn as_slice(&self) -> &[usize] {
|
||||
// self.indices.as_slice()
|
||||
// }
|
||||
|
||||
// type Entry = usize;
|
||||
// }
|
||||
|
||||
impl HasRefCnt for FreeRTOSSystemStateMetadata {
|
||||
fn refcnt(&self) -> isize {
|
||||
self.tcref
|
||||
}
|
||||
|
||||
fn refcnt_mut(&mut self) -> &mut isize {
|
||||
&mut self.tcref
|
||||
}
|
||||
}
|
||||
|
||||
libafl_bolts::impl_serdeany!(FreeRTOSSystemStateMetadata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user