Merge branch 'main' of github.com:AFLplusplus/libAFLrs into main

This commit is contained in:
Andrea Fioraldi 2020-12-11 11:09:04 +01:00
commit 9dae6b0516
3 changed files with 17 additions and 1 deletions

View File

@ -69,6 +69,7 @@ const INTERESTING_32: [i32; 27] = [
2147483647, 2147483647,
]; ];
#[inline]
fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) { fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) {
debug_assert!(from + len <= data.len()); debug_assert!(from + len <= data.len());
debug_assert!(to + len <= data.len()); debug_assert!(to + len <= data.len());
@ -76,6 +77,7 @@ fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) {
unsafe { core::ptr::copy(ptr.offset(from as isize), ptr.offset(to as isize), len) } unsafe { core::ptr::copy(ptr.offset(from as isize), ptr.offset(to as isize), len) }
} }
#[inline]
fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) { fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) {
debug_assert!(from + len <= src.len()); debug_assert!(from + len <= src.len());
debug_assert!(to + len <= dst.len()); debug_assert!(to + len <= dst.len());
@ -90,6 +92,7 @@ fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) {
} }
} }
#[inline]
fn mem_set(data: &mut [u8], from: usize, len: usize, val: u8) { fn mem_set(data: &mut [u8], from: usize, len: usize, val: u8) {
debug_assert!(from + len <= data.len()); debug_assert!(from + len <= data.len());
let ptr = data.as_mut_ptr(); let ptr = data.as_mut_ptr();

View File

@ -13,7 +13,6 @@ use crate::AflError;
/// Observers observe different information about the target. /// Observers observe different information about the target.
/// They can then be used by various sorts of feedback. /// They can then be used by various sorts of feedback.
pub trait Observer: SerdeAny + 'static { pub trait Observer: SerdeAny + 'static {
/// The testcase finished execution, calculate any changes. /// The testcase finished execution, calculate any changes.
#[inline] #[inline]
fn flush(&mut self) -> Result<(), AflError> { fn flush(&mut self) -> Result<(), AflError> {
@ -82,10 +81,12 @@ impl<T> Observer for StdMapObserver<T>
where where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{ {
#[inline]
fn reset(&mut self) -> Result<(), AflError> { fn reset(&mut self) -> Result<(), AflError> {
self.reset_map() self.reset_map()
} }
#[inline]
fn name(&self) -> &String { fn name(&self) -> &String {
&self.name &self.name
} }
@ -95,9 +96,12 @@ impl<T> SerdeAny for StdMapObserver<T>
where where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{ {
#[inline]
fn as_any(&self) -> &dyn Any { fn as_any(&self) -> &dyn Any {
self self
} }
#[inline]
fn as_any_mut(&mut self) -> &mut dyn Any { fn as_any_mut(&mut self) -> &mut dyn Any {
self self
} }
@ -107,22 +111,27 @@ impl<T> MapObserver<T> for StdMapObserver<T>
where where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{ {
#[inline]
fn map(&self) -> &[T] { fn map(&self) -> &[T] {
self.map.as_slice() self.map.as_slice()
} }
#[inline]
fn map_mut(&mut self) -> &mut [T] { fn map_mut(&mut self) -> &mut [T] {
self.map.as_mut_slice() self.map.as_mut_slice()
} }
#[inline]
fn initial(&self) -> T { fn initial(&self) -> T {
self.initial self.initial
} }
#[inline]
fn initial_mut(&mut self) -> &mut T { fn initial_mut(&mut self) -> &mut T {
&mut self.initial &mut self.initial
} }
#[inline]
fn set_initial(&mut self, initial: T) { fn set_initial(&mut self, initial: T) {
self.initial = initial self.initial = initial
} }

View File

@ -34,6 +34,7 @@ where
/// Gets the number of iterations this mutator should run for. /// Gets the number of iterations this mutator should run for.
/// This call uses internal mutability, so it may change for each call /// This call uses internal mutability, so it may change for each call
#[inline]
fn iterations(&mut self, rand: &mut R) -> usize { fn iterations(&mut self, rand: &mut R) -> usize {
1 + rand.below(128) as usize 1 + rand.below(128) as usize
} }
@ -106,11 +107,13 @@ where
R: Rand, R: Rand,
{ {
/// The mutator, added to this stage /// The mutator, added to this stage
#[inline]
fn mutator(&self) -> &M { fn mutator(&self) -> &M {
&self.mutator &self.mutator
} }
/// The list of mutators, added to this stage (as mutable ref) /// The list of mutators, added to this stage (as mutable ref)
#[inline]
fn mutator_mut(&mut self) -> &mut M { fn mutator_mut(&mut self) -> &mut M {
&mut self.mutator &mut self.mutator
} }
@ -125,6 +128,7 @@ where
I: Input, I: Input,
R: Rand, R: Rand,
{ {
#[inline]
fn perform( fn perform(
&mut self, &mut self,
rand: &mut R, rand: &mut R,