Use Associated Types for Has* traits and AsSlice (#881)
* More Associated Types * AsSlice associated-ified * added script to find unused files * fixes for python * build all the things * windows fixes
This commit is contained in:
parent
18f288e2d3
commit
6b6570ae5f
@ -574,7 +574,7 @@ impl LlmpMsg {
|
|||||||
slice::from_raw_parts(self.buf.as_ptr(), self.buf_len as usize)
|
slice::from_raw_parts(self.buf.as_ptr(), self.buf_len as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the buffer from this message as slice, with the corrent length.
|
/// Gets the buffer from this message as slice, with the correct length.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_as_slice<SHM: ShMem>(&self, map: &mut LlmpSharedMap<SHM>) -> Result<&[u8], Error> {
|
pub fn try_as_slice<SHM: ShMem>(&self, map: &mut LlmpSharedMap<SHM>) -> Result<&[u8], Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -586,7 +586,7 @@ impl LlmpMsg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true, if the pointer is, indeed, in the page of this shared map.
|
/// Returns `true`, if the pointer is, indeed, in the page of this shared map.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn in_shmem<SHM: ShMem>(&self, map: &mut LlmpSharedMap<SHM>) -> bool {
|
pub fn in_shmem<SHM: ShMem>(&self, map: &mut LlmpSharedMap<SHM>) -> bool {
|
||||||
let map_size = map.shmem.as_slice().len();
|
let map_size = map.shmem.as_slice().len();
|
||||||
|
@ -35,15 +35,19 @@ use core::{iter::Iterator, time};
|
|||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
/// Can be converted to a slice
|
/// Can be converted to a slice
|
||||||
pub trait AsSlice<T> {
|
pub trait AsSlice {
|
||||||
|
/// Type of the entries in this slice
|
||||||
|
type Entry;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_slice(&self) -> &[T];
|
fn as_slice(&self) -> &[Self::Entry];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can be converted to a mutable slice
|
/// Can be converted to a mutable slice
|
||||||
pub trait AsMutSlice<T> {
|
pub trait AsMutSlice {
|
||||||
|
/// Type of the entries in this mut slice
|
||||||
|
type Entry;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_mut_slice(&mut self) -> &mut [T];
|
fn as_mut_slice(&mut self) -> &mut [Self::Entry];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an `Iterator` from a reference
|
/// Create an `Iterator` from a reference
|
||||||
|
@ -95,18 +95,20 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SH> AsSlice<u8> for ServedShMem<SH>
|
impl<SH> AsSlice for ServedShMem<SH>
|
||||||
where
|
where
|
||||||
SH: ShMem,
|
SH: ShMem,
|
||||||
{
|
{
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
self.inner.as_slice()
|
self.inner.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<SH> AsMutSlice<u8> for ServedShMem<SH>
|
impl<SH> AsMutSlice for ServedShMem<SH>
|
||||||
where
|
where
|
||||||
SH: ShMem,
|
SH: ShMem,
|
||||||
{
|
{
|
||||||
|
type Entry = u8;
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
self.inner.as_mut_slice()
|
self.inner.as_mut_slice()
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,8 @@ impl<'a, T> From<OwnedSliceMut<'a, T>> for OwnedSlice<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Sized> AsSlice<T> for OwnedSlice<'a, T> {
|
impl<'a, T: Sized> AsSlice for OwnedSlice<'a, T> {
|
||||||
|
type Entry = T;
|
||||||
/// Get the [`OwnedSlice`] as slice.
|
/// Get the [`OwnedSlice`] as slice.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
@ -416,7 +417,8 @@ impl<'a, T: 'a + Sized> OwnedSliceMut<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Sized> AsSlice<T> for OwnedSliceMut<'a, T> {
|
impl<'a, T: Sized> AsSlice for OwnedSliceMut<'a, T> {
|
||||||
|
type Entry = T;
|
||||||
/// Get the value as slice
|
/// Get the value as slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
@ -427,7 +429,8 @@ impl<'a, T: Sized> AsSlice<T> for OwnedSliceMut<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a, T: Sized> AsMutSlice<T> for OwnedSliceMut<'a, T> {
|
impl<'a, T: Sized> AsMutSlice for OwnedSliceMut<'a, T> {
|
||||||
|
type Entry = T;
|
||||||
/// Get the value as mut slice
|
/// Get the value as mut slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
|
@ -137,7 +137,8 @@ impl ShMemId {
|
|||||||
alloc::str::from_utf8(&self.id[..self.null_pos()]).unwrap()
|
alloc::str::from_utf8(&self.id[..self.null_pos()]).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsSlice<u8> for ShMemId {
|
impl AsSlice for ShMemId {
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
&self.id
|
&self.id
|
||||||
}
|
}
|
||||||
@ -158,7 +159,7 @@ impl Display for ShMemId {
|
|||||||
/// A [`ShMem`] is an interface to shared maps.
|
/// A [`ShMem`] is an interface to shared maps.
|
||||||
/// They are the backbone of [`crate::bolts::llmp`] for inter-process communication.
|
/// They are the backbone of [`crate::bolts::llmp`] for inter-process communication.
|
||||||
/// All you need for scaling on a new target is to implement this interface, as well as the respective [`ShMemProvider`].
|
/// All you need for scaling on a new target is to implement this interface, as well as the respective [`ShMemProvider`].
|
||||||
pub trait ShMem: Sized + Debug + Clone + AsSlice<u8> + AsMutSlice<u8> {
|
pub trait ShMem: Sized + Debug + Clone + AsSlice<Entry = u8> + AsMutSlice<Entry = u8> {
|
||||||
/// Get the id of this shared memory mapping
|
/// Get the id of this shared memory mapping
|
||||||
fn id(&self) -> ShMemId;
|
fn id(&self) -> ShMemId;
|
||||||
|
|
||||||
@ -312,19 +313,21 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> AsSlice<u8> for RcShMem<T>
|
impl<T> AsSlice for RcShMem<T>
|
||||||
where
|
where
|
||||||
T: ShMemProvider + Debug,
|
T: ShMemProvider + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
self.internal.as_slice()
|
self.internal.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> AsMutSlice<u8> for RcShMem<T>
|
impl<T> AsMutSlice for RcShMem<T>
|
||||||
where
|
where
|
||||||
T: ShMemProvider + Debug,
|
T: ShMemProvider + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = u8;
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
self.internal.as_mut_slice()
|
self.internal.as_mut_slice()
|
||||||
}
|
}
|
||||||
@ -754,13 +757,15 @@ pub mod unix_shmem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<u8> for MmapShMem {
|
impl AsSlice for MmapShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsMutSlice<u8> for MmapShMem {
|
impl AsMutSlice for MmapShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
@ -867,13 +872,15 @@ pub mod unix_shmem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<u8> for CommonUnixShMem {
|
impl AsSlice for CommonUnixShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsMutSlice<u8> for CommonUnixShMem {
|
impl AsMutSlice for CommonUnixShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
@ -1077,13 +1084,16 @@ pub mod unix_shmem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<u8> for AshmemShMem {
|
impl AsSlice for AshmemShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsMutSlice<u8> for AshmemShMem {
|
impl AsMutSlice for AshmemShMem {
|
||||||
|
type Entry = u8;
|
||||||
|
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
@ -1275,12 +1285,14 @@ pub mod win32_shmem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<u8> for Win32ShMem {
|
impl AsSlice for Win32ShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[u8] {
|
||||||
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<u8> for Win32ShMem {
|
impl AsMutSlice for Win32ShMem {
|
||||||
|
type Entry = u8;
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||||
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
unsafe { slice::from_raw_parts_mut(self.map, self.map_size) }
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ where
|
|||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
CS: Scheduler<State = E::State>,
|
CS: Scheduler<State = E::State>,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = E::State>,
|
||||||
Z: HasScheduler<CS, State = E::State>;
|
Z: HasScheduler<Scheduler = CS, State = E::State>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Minimizes a corpus according to coverage maps, weighting by the specified `TestcaseScore`.
|
/// Minimizes a corpus according to coverage maps, weighting by the specified `TestcaseScore`.
|
||||||
@ -102,7 +102,7 @@ where
|
|||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
CS: Scheduler<State = E::State>,
|
CS: Scheduler<State = E::State>,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = E::State>,
|
||||||
Z: HasScheduler<CS, State = E::State>,
|
Z: HasScheduler<Scheduler = CS, State = E::State>,
|
||||||
{
|
{
|
||||||
let cfg = Config::default();
|
let cfg = Config::default();
|
||||||
let ctx = Context::new(&cfg);
|
let ctx = Context::new(&cfg);
|
||||||
|
@ -552,7 +552,7 @@ where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, SP> HasCustomBufHandlers<S> for LlmpEventManager<S, SP>
|
impl<S, SP> HasCustomBufHandlers for LlmpEventManager<S, SP>
|
||||||
where
|
where
|
||||||
S: UsesInput,
|
S: UsesInput,
|
||||||
SP: ShMemProvider,
|
SP: ShMemProvider,
|
||||||
|
@ -466,9 +466,9 @@ type CustomBufHandlerFn<S> =
|
|||||||
dyn FnMut(&mut S, &String, &[u8]) -> Result<CustomBufEventResult, Error>;
|
dyn FnMut(&mut S, &String, &[u8]) -> Result<CustomBufEventResult, Error>;
|
||||||
|
|
||||||
/// Supports custom buf handlers to handle `CustomBuf` events.
|
/// Supports custom buf handlers to handle `CustomBuf` events.
|
||||||
pub trait HasCustomBufHandlers<S> {
|
pub trait HasCustomBufHandlers: UsesState {
|
||||||
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
|
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
|
||||||
fn add_custom_buf_handler(&mut self, handler: Box<CustomBufHandlerFn<S>>);
|
fn add_custom_buf_handler(&mut self, handler: Box<CustomBufHandlerFn<Self::State>>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An eventmgr for tests, and as placeholder if you really don't need an event manager.
|
/// An eventmgr for tests, and as placeholder if you really don't need an event manager.
|
||||||
@ -528,10 +528,15 @@ impl<E, S, Z> EventManager<E, Z> for NopEventManager<S> where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> HasCustomBufHandlers<S> for NopEventManager<S> {
|
impl<S> HasCustomBufHandlers for NopEventManager<S>
|
||||||
|
where
|
||||||
|
S: UsesInput,
|
||||||
|
{
|
||||||
fn add_custom_buf_handler(
|
fn add_custom_buf_handler(
|
||||||
&mut self,
|
&mut self,
|
||||||
_handler: Box<dyn FnMut(&mut S, &String, &[u8]) -> Result<CustomBufEventResult, Error>>,
|
_handler: Box<
|
||||||
|
dyn FnMut(&mut Self::State, &String, &[u8]) -> Result<CustomBufEventResult, Error>,
|
||||||
|
>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MT, S> HasCustomBufHandlers<S> for SimpleEventManager<MT, S>
|
impl<MT, S> HasCustomBufHandlers for SimpleEventManager<MT, S>
|
||||||
where
|
where
|
||||||
MT: Monitor, //CE: CustomEvent<I, OT>,
|
MT: Monitor, //CE: CustomEvent<I, OT>,
|
||||||
S: UsesInput,
|
S: UsesInput,
|
||||||
@ -136,7 +136,9 @@ where
|
|||||||
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
|
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
|
||||||
fn add_custom_buf_handler(
|
fn add_custom_buf_handler(
|
||||||
&mut self,
|
&mut self,
|
||||||
handler: Box<dyn FnMut(&mut S, &String, &[u8]) -> Result<CustomBufEventResult, Error>>,
|
handler: Box<
|
||||||
|
dyn FnMut(&mut Self::State, &String, &[u8]) -> Result<CustomBufEventResult, Error>,
|
||||||
|
>,
|
||||||
) {
|
) {
|
||||||
self.custom_buf_handlers.push(handler);
|
self.custom_buf_handlers.push(handler);
|
||||||
}
|
}
|
||||||
@ -371,7 +373,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl<MT, S, SP> HasCustomBufHandlers<S> for SimpleRestartingEventManager<MT, S, SP>
|
impl<MT, S, SP> HasCustomBufHandlers for SimpleRestartingEventManager<MT, S, SP>
|
||||||
where
|
where
|
||||||
MT: Monitor,
|
MT: Monitor,
|
||||||
S: UsesInput,
|
S: UsesInput,
|
||||||
|
@ -184,7 +184,7 @@ where
|
|||||||
Self: Executor<EM, Z, State = S>,
|
Self: Executor<EM, Z, State = S>,
|
||||||
EM: EventFirer<State = S> + EventRestarter,
|
EM: EventFirer<State = S> + EventRestarter,
|
||||||
OF: Feedback<S>,
|
OF: Feedback<S>,
|
||||||
Z: HasObjective<OF, State = S>,
|
Z: HasObjective<Objective = OF, State = S>,
|
||||||
{
|
{
|
||||||
let handlers = InProcessHandlers::new::<Self, EM, OF, Z, H>()?;
|
let handlers = InProcessHandlers::new::<Self, EM, OF, Z, H>()?;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -342,7 +342,7 @@ impl InProcessHandlers {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
H: FnMut(&<E::State as UsesInput>::Input) -> ExitKind + ?Sized,
|
H: FnMut(&<E::State as UsesInput>::Input) -> ExitKind + ?Sized,
|
||||||
{
|
{
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
@ -614,7 +614,7 @@ mod unix_signal_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
let old_hook = panic::take_hook();
|
let old_hook = panic::take_hook();
|
||||||
panic::set_hook(Box::new(move |panic_info| {
|
panic::set_hook(Box::new(move |panic_info| {
|
||||||
@ -687,7 +687,7 @@ mod unix_signal_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
if !data.is_valid() {
|
if !data.is_valid() {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@ -765,7 +765,7 @@ mod unix_signal_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
|
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
|
||||||
let _context = &mut *(((_context as *mut _ as *mut libc::c_void as usize) + 128)
|
let _context = &mut *(((_context as *mut _ as *mut libc::c_void as usize) + 128)
|
||||||
@ -949,7 +949,7 @@ mod windows_exception_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
let old_hook = panic::take_hook();
|
let old_hook = panic::take_hook();
|
||||||
panic::set_hook(Box::new(move |panic_info| {
|
panic::set_hook(Box::new(move |panic_info| {
|
||||||
@ -1039,7 +1039,7 @@ mod windows_exception_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
let data: &mut InProcessExecutorHandlerData =
|
let data: &mut InProcessExecutorHandlerData =
|
||||||
&mut *(global_state as *mut InProcessExecutorHandlerData);
|
&mut *(global_state as *mut InProcessExecutorHandlerData);
|
||||||
@ -1135,7 +1135,7 @@ mod windows_exception_handler {
|
|||||||
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
|
||||||
OF: Feedback<E::State>,
|
OF: Feedback<E::State>,
|
||||||
E::State: HasSolutions + HasClientPerfMonitor,
|
E::State: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
// Have we set a timer_before?
|
// Have we set a timer_before?
|
||||||
if !(data.tp_timer as *mut windows::Win32::System::Threading::TP_TIMER).is_null() {
|
if !(data.tp_timer as *mut windows::Win32::System::Threading::TP_TIMER).is_null() {
|
||||||
@ -1701,7 +1701,7 @@ where
|
|||||||
EM: EventFirer<State = S> + EventRestarter,
|
EM: EventFirer<State = S> + EventRestarter,
|
||||||
OF: Feedback<S>,
|
OF: Feedback<S>,
|
||||||
S: HasSolutions + HasClientPerfMonitor,
|
S: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = S>,
|
Z: HasObjective<Objective = OF, State = S>,
|
||||||
{
|
{
|
||||||
let handlers = InChildProcessHandlers::new::<Self>()?;
|
let handlers = InChildProcessHandlers::new::<Self>()?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@ -1748,7 +1748,7 @@ where
|
|||||||
EM: EventFirer<State = S> + EventRestarter<State = S>,
|
EM: EventFirer<State = S> + EventRestarter<State = S>,
|
||||||
OF: Feedback<S>,
|
OF: Feedback<S>,
|
||||||
S: HasSolutions + HasClientPerfMonitor,
|
S: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = S>,
|
Z: HasObjective<Objective = OF, State = S>,
|
||||||
{
|
{
|
||||||
let handlers = InChildProcessHandlers::with_timeout::<Self>()?;
|
let handlers = InChildProcessHandlers::with_timeout::<Self>()?;
|
||||||
let milli_sec = timeout.as_millis();
|
let milli_sec = timeout.as_millis();
|
||||||
|
@ -214,13 +214,15 @@ pub struct MapIndexesMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(MapIndexesMetadata);
|
crate::impl_serdeany!(MapIndexesMetadata);
|
||||||
|
|
||||||
impl AsSlice<usize> for MapIndexesMetadata {
|
impl AsSlice for MapIndexesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_slice(&self) -> &[usize] {
|
fn as_slice(&self) -> &[usize] {
|
||||||
self.list.as_slice()
|
self.list.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<usize> for MapIndexesMetadata {
|
impl AsMutSlice for MapIndexesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_mut_slice(&mut self) -> &mut [usize] {
|
fn as_mut_slice(&mut self) -> &mut [usize] {
|
||||||
self.list.as_mut_slice()
|
self.list.as_mut_slice()
|
||||||
@ -254,14 +256,16 @@ pub struct MapNoveltiesMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(MapNoveltiesMetadata);
|
crate::impl_serdeany!(MapNoveltiesMetadata);
|
||||||
|
|
||||||
impl AsSlice<usize> for MapNoveltiesMetadata {
|
impl AsSlice for MapNoveltiesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_slice(&self) -> &[usize] {
|
fn as_slice(&self) -> &[usize] {
|
||||||
self.list.as_slice()
|
self.list.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<usize> for MapNoveltiesMetadata {
|
impl AsMutSlice for MapNoveltiesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_mut_slice(&mut self) -> &mut [usize] {
|
fn as_mut_slice(&mut self) -> &mut [usize] {
|
||||||
@ -430,7 +434,7 @@ where
|
|||||||
#[rustversion::nightly]
|
#[rustversion::nightly]
|
||||||
impl<O, S> Feedback<S> for MapFeedback<DifferentIsNovel, O, MaxReducer, S, u8>
|
impl<O, S> Feedback<S> for MapFeedback<DifferentIsNovel, O, MaxReducer, S, u8>
|
||||||
where
|
where
|
||||||
O: MapObserver<Entry = u8> + AsSlice<u8>,
|
O: MapObserver<Entry = u8> + AsSlice<Entry = u8>,
|
||||||
for<'it> O: AsIter<'it, Item = u8>,
|
for<'it> O: AsIter<'it, Item = u8>,
|
||||||
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor + Debug,
|
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor + Debug,
|
||||||
{
|
{
|
||||||
|
@ -31,41 +31,45 @@ use crate::{
|
|||||||
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
|
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
|
||||||
|
|
||||||
/// Holds a scheduler
|
/// Holds a scheduler
|
||||||
pub trait HasScheduler<CS>: UsesState
|
pub trait HasScheduler: UsesState {
|
||||||
where
|
/// The [`Scheduler`] for this fuzzer
|
||||||
CS: Scheduler<State = Self::State>,
|
type Scheduler: Scheduler<State = Self::State>;
|
||||||
{
|
|
||||||
/// The scheduler
|
/// The scheduler
|
||||||
fn scheduler(&self) -> &CS;
|
fn scheduler(&self) -> &Self::Scheduler;
|
||||||
|
|
||||||
/// The scheduler (mutable)
|
/// The scheduler (mutable)
|
||||||
fn scheduler_mut(&mut self) -> &mut CS;
|
fn scheduler_mut(&mut self) -> &mut Self::Scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds an feedback
|
/// Holds an feedback
|
||||||
pub trait HasFeedback<F>: UsesState
|
pub trait HasFeedback: UsesState
|
||||||
where
|
where
|
||||||
F: Feedback<Self::State>,
|
|
||||||
Self::State: HasClientPerfMonitor,
|
Self::State: HasClientPerfMonitor,
|
||||||
{
|
{
|
||||||
|
/// The feedback type
|
||||||
|
type Feedback: Feedback<Self::State>;
|
||||||
|
|
||||||
/// The feedback
|
/// The feedback
|
||||||
fn feedback(&self) -> &F;
|
fn feedback(&self) -> &Self::Feedback;
|
||||||
|
|
||||||
/// The feedback (mutable)
|
/// The feedback (mutable)
|
||||||
fn feedback_mut(&mut self) -> &mut F;
|
fn feedback_mut(&mut self) -> &mut Self::Feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds an objective feedback
|
/// Holds an objective feedback
|
||||||
pub trait HasObjective<OF>: UsesState
|
pub trait HasObjective: UsesState
|
||||||
where
|
where
|
||||||
OF: Feedback<Self::State>,
|
|
||||||
Self::State: HasClientPerfMonitor,
|
Self::State: HasClientPerfMonitor,
|
||||||
{
|
{
|
||||||
|
/// The type of the [`Feedback`] used to find objectives for this fuzzer
|
||||||
|
type Objective: Feedback<Self::State>;
|
||||||
|
|
||||||
/// The objective feedback
|
/// The objective feedback
|
||||||
fn objective(&self) -> &OF;
|
fn objective(&self) -> &Self::Objective;
|
||||||
|
|
||||||
/// The objective feedback (mutable)
|
/// The objective feedback (mutable)
|
||||||
fn objective_mut(&mut self) -> &mut OF;
|
fn objective_mut(&mut self) -> &mut Self::Objective;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate if an input is interesting using the feedback
|
/// Evaluate if an input is interesting using the feedback
|
||||||
@ -263,13 +267,15 @@ where
|
|||||||
type State = CS::State;
|
type State = CS::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, F, OF, OT> HasScheduler<CS> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasScheduler for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<CS::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor,
|
CS::State: HasClientPerfMonitor,
|
||||||
{
|
{
|
||||||
|
type Scheduler = CS;
|
||||||
|
|
||||||
fn scheduler(&self) -> &CS {
|
fn scheduler(&self) -> &CS {
|
||||||
&self.scheduler
|
&self.scheduler
|
||||||
}
|
}
|
||||||
@ -279,29 +285,33 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, F, OF, OT> HasFeedback<F> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasFeedback for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<CS::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor,
|
CS::State: HasClientPerfMonitor,
|
||||||
{
|
{
|
||||||
fn feedback(&self) -> &F {
|
type Feedback = F;
|
||||||
|
|
||||||
|
fn feedback(&self) -> &Self::Feedback {
|
||||||
&self.feedback
|
&self.feedback
|
||||||
}
|
}
|
||||||
|
|
||||||
fn feedback_mut(&mut self) -> &mut F {
|
fn feedback_mut(&mut self) -> &mut Self::Feedback {
|
||||||
&mut self.feedback
|
&mut self.feedback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, F, OF, OT> HasObjective<OF> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasObjective for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<CS::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor,
|
CS::State: HasClientPerfMonitor,
|
||||||
{
|
{
|
||||||
|
type Objective = OF;
|
||||||
|
|
||||||
fn objective(&self) -> &OF {
|
fn objective(&self) -> &OF {
|
||||||
&self.objective
|
&self.objective
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,15 @@ pub struct LogMutationMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(LogMutationMetadata);
|
crate::impl_serdeany!(LogMutationMetadata);
|
||||||
|
|
||||||
impl AsSlice<String> for LogMutationMetadata {
|
impl AsSlice for LogMutationMetadata {
|
||||||
|
type Entry = String;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_slice(&self) -> &[String] {
|
fn as_slice(&self) -> &[String] {
|
||||||
self.list.as_slice()
|
self.list.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<String> for LogMutationMetadata {
|
impl AsMutSlice for LogMutationMetadata {
|
||||||
|
type Entry = String;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_mut_slice(&mut self) -> &mut [String] {
|
fn as_mut_slice(&mut self) -> &mut [String] {
|
||||||
self.list.as_mut_slice()
|
self.list.as_mut_slice()
|
||||||
|
@ -266,7 +266,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<Vec<u8>> for Tokens {
|
impl AsSlice for Tokens {
|
||||||
|
type Entry = Vec<u8>;
|
||||||
fn as_slice(&self) -> &[Vec<u8>] {
|
fn as_slice(&self) -> &[Vec<u8>] {
|
||||||
self.tokens()
|
self.tokens()
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,16 @@ pub struct CmpValuesMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(CmpValuesMetadata);
|
crate::impl_serdeany!(CmpValuesMetadata);
|
||||||
|
|
||||||
impl AsSlice<CmpValues> for CmpValuesMetadata {
|
impl AsSlice for CmpValuesMetadata {
|
||||||
|
type Entry = CmpValues;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_slice(&self) -> &[CmpValues] {
|
fn as_slice(&self) -> &[CmpValues] {
|
||||||
self.list.as_slice()
|
self.list.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<CmpValues> for CmpValuesMetadata {
|
impl AsMutSlice for CmpValuesMetadata {
|
||||||
|
type Entry = CmpValues;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn as_mut_slice(&mut self) -> &mut [CmpValues] {
|
fn as_mut_slice(&mut self) -> &mut [CmpValues] {
|
||||||
|
@ -404,20 +404,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> AsSlice<T> for StdMapObserver<'a, T>
|
impl<'a, T> AsSlice for StdMapObserver<'a, T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
self.map.as_slice()
|
self.map.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a, T> AsMutSlice<T> for StdMapObserver<'a, T>
|
impl<'a, T> AsMutSlice for StdMapObserver<'a, T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
@ -700,19 +702,21 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, const N: usize> AsSlice<T> for ConstMapObserver<'a, T, N>
|
impl<'a, T, const N: usize> AsSlice for ConstMapObserver<'a, T, N>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
self.map.as_slice()
|
self.map.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a, T, const N: usize> AsMutSlice<T> for ConstMapObserver<'a, T, N>
|
impl<'a, T, const N: usize> AsMutSlice for ConstMapObserver<'a, T, N>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
self.map.as_mut_slice()
|
self.map.as_mut_slice()
|
||||||
@ -969,7 +973,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> AsSlice<T> for VariableMapObserver<'a, T>
|
impl<'a, T> AsSlice for VariableMapObserver<'a, T>
|
||||||
where
|
where
|
||||||
T: Bounded
|
T: Bounded
|
||||||
+ PartialEq
|
+ PartialEq
|
||||||
@ -980,16 +984,18 @@ where
|
|||||||
+ serde::de::DeserializeOwned
|
+ serde::de::DeserializeOwned
|
||||||
+ Debug,
|
+ Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
let cnt = self.usable_count();
|
let cnt = self.usable_count();
|
||||||
&self.map.as_slice()[..cnt]
|
&self.map.as_slice()[..cnt]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a, T> AsMutSlice<T> for VariableMapObserver<'a, T>
|
impl<'a, T> AsMutSlice for VariableMapObserver<'a, T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
self.map.as_mut_slice()
|
self.map.as_mut_slice()
|
||||||
@ -1044,7 +1050,7 @@ where
|
|||||||
|
|
||||||
impl<S, M> Observer<S> for HitcountsMapObserver<M>
|
impl<S, M> Observer<S> for HitcountsMapObserver<M>
|
||||||
where
|
where
|
||||||
M: MapObserver<Entry = u8> + Observer<S> + AsMutSlice<u8>,
|
M: MapObserver<Entry = u8> + Observer<S> + AsMutSlice<Entry = u8>,
|
||||||
S: UsesInput,
|
S: UsesInput,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1155,21 +1161,23 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M> AsSlice<u8> for HitcountsMapObserver<M>
|
impl<M> AsSlice for HitcountsMapObserver<M>
|
||||||
where
|
where
|
||||||
M: MapObserver + AsSlice<u8>,
|
M: MapObserver + AsSlice,
|
||||||
{
|
{
|
||||||
|
type Entry = <M as AsSlice>::Entry;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[Self::Entry] {
|
||||||
self.base.as_slice()
|
self.base.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<M> AsMutSlice<u8> for HitcountsMapObserver<M>
|
impl<M> AsMutSlice for HitcountsMapObserver<M>
|
||||||
where
|
where
|
||||||
M: MapObserver + AsMutSlice<u8>,
|
M: MapObserver + AsMutSlice,
|
||||||
{
|
{
|
||||||
|
type Entry = <M as AsMutSlice>::Entry;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [Self::Entry] {
|
||||||
self.base.as_mut_slice()
|
self.base.as_mut_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1349,21 +1357,23 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M> AsSlice<u8> for HitcountsIterableMapObserver<M>
|
impl<M> AsSlice for HitcountsIterableMapObserver<M>
|
||||||
where
|
where
|
||||||
M: MapObserver + AsSlice<u8>,
|
M: MapObserver + AsSlice,
|
||||||
{
|
{
|
||||||
|
type Entry = <M as AsSlice>::Entry;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[u8] {
|
fn as_slice(&self) -> &[Self::Entry] {
|
||||||
self.base.as_slice()
|
self.base.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<M> AsMutSlice<u8> for HitcountsIterableMapObserver<M>
|
impl<M> AsMutSlice for HitcountsIterableMapObserver<M>
|
||||||
where
|
where
|
||||||
M: MapObserver + AsMutSlice<u8>,
|
M: MapObserver + AsMutSlice,
|
||||||
{
|
{
|
||||||
|
type Entry = <M as AsMutSlice>::Entry;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [u8] {
|
fn as_mut_slice(&mut self) -> &mut [Self::Entry] {
|
||||||
self.base.as_mut_slice()
|
self.base.as_mut_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1873,20 +1883,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> AsSlice<T> for OwnedMapObserver<T>
|
impl<T> AsSlice for OwnedMapObserver<T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &[T] {
|
fn as_slice(&self) -> &[T] {
|
||||||
self.map.as_slice()
|
self.map.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T> AsMutSlice<T> for OwnedMapObserver<T>
|
impl<T> AsMutSlice for OwnedMapObserver<T>
|
||||||
where
|
where
|
||||||
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
T: Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||||
{
|
{
|
||||||
|
type Entry = T;
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
@ -2171,13 +2183,15 @@ pub mod pybind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsSlice<$datatype> for $struct_name_trait {
|
impl AsSlice for $struct_name_trait {
|
||||||
|
type Entry = $datatype;
|
||||||
fn as_slice(&self) -> &[$datatype] {
|
fn as_slice(&self) -> &[$datatype] {
|
||||||
mapob_unwrap_me!($wrapper_name, self.wrapper, m, { unsafe { std::mem::transmute(m.as_slice()) }} )
|
mapob_unwrap_me!($wrapper_name, self.wrapper, m, { unsafe { std::mem::transmute(m.as_slice()) }} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsMutSlice<$datatype> for $struct_name_trait {
|
impl AsMutSlice for $struct_name_trait {
|
||||||
|
type Entry = $datatype;
|
||||||
fn as_mut_slice(&mut self) -> &mut [$datatype] {
|
fn as_mut_slice(&mut self) -> &mut [$datatype] {
|
||||||
mapob_unwrap_me_mut!($wrapper_name, self.wrapper, m, { unsafe { std::mem::transmute(m.as_mut_slice()) }} )
|
mapob_unwrap_me_mut!($wrapper_name, self.wrapper, m, { unsafe { std::mem::transmute(m.as_mut_slice()) }} )
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,16 @@ pub struct AccountingIndexesMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(AccountingIndexesMetadata);
|
crate::impl_serdeany!(AccountingIndexesMetadata);
|
||||||
|
|
||||||
impl AsSlice<usize> for AccountingIndexesMetadata {
|
impl AsSlice for AccountingIndexesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_slice(&self) -> &[usize] {
|
fn as_slice(&self) -> &[usize] {
|
||||||
self.list.as_slice()
|
self.list.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsMutSlice<usize> for AccountingIndexesMetadata {
|
impl AsMutSlice for AccountingIndexesMetadata {
|
||||||
|
type Entry = usize;
|
||||||
|
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
fn as_mut_slice(&mut self) -> &mut [usize] {
|
fn as_mut_slice(&mut self) -> &mut [usize] {
|
||||||
self.list.as_mut_slice()
|
self.list.as_mut_slice()
|
||||||
|
@ -78,7 +78,7 @@ impl<CS, F, M> Scheduler for MinimizerScheduler<CS, F, M>
|
|||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: TestcaseScore<CS::State>,
|
F: TestcaseScore<CS::State>,
|
||||||
M: AsSlice<usize> + SerdeAny + HasRefCnt,
|
M: AsSlice<Entry = usize> + SerdeAny + HasRefCnt,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand,
|
CS::State: HasCorpus + HasMetadata + HasRand,
|
||||||
{
|
{
|
||||||
/// Add an entry to the corpus and return its index
|
/// Add an entry to the corpus and return its index
|
||||||
@ -190,7 +190,7 @@ impl<CS, F, M> MinimizerScheduler<CS, F, M>
|
|||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: TestcaseScore<CS::State>,
|
F: TestcaseScore<CS::State>,
|
||||||
M: AsSlice<usize> + SerdeAny + HasRefCnt,
|
M: AsSlice<Entry = usize> + SerdeAny + HasRefCnt,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand,
|
CS::State: HasCorpus + HasMetadata + HasRand,
|
||||||
{
|
{
|
||||||
/// Update the `Corpus` score using the `MinimizerScheduler`
|
/// Update the `Corpus` score using the `MinimizerScheduler`
|
||||||
|
@ -244,7 +244,7 @@ where
|
|||||||
Z: ExecutesInput<E, EM, State = CS::State>
|
Z: ExecutesInput<E, EM, State = CS::State>
|
||||||
+ ExecutionProcessor<OT, State = CS::State>
|
+ ExecutionProcessor<OT, State = CS::State>
|
||||||
+ EvaluatorObservers<OT>
|
+ EvaluatorObservers<OT>
|
||||||
+ HasScheduler<CS>,
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -38,7 +38,9 @@ where
|
|||||||
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasRand,
|
CS::State: HasClientPerfMonitor + HasRand,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// The [`crate::state::State`]
|
/// The [`crate::state::State`]
|
||||||
pub state: CS::State,
|
pub state: CS::State,
|
||||||
@ -57,7 +59,9 @@ where
|
|||||||
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasRand,
|
CS::State: HasClientPerfMonitor + HasRand,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// Create a new `PushStageSharedState` that can be used by all [`PushStage`]s
|
/// Create a new `PushStageSharedState` that can be used by all [`PushStage`]s
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -80,7 +84,9 @@ where
|
|||||||
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasRand,
|
CS::State: HasClientPerfMonitor + HasRand,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// If this stage has already been initalized.
|
/// If this stage has already been initalized.
|
||||||
/// This gets reset to `false` after one iteration of the stage is done.
|
/// This gets reset to `false` after one iteration of the stage is done.
|
||||||
@ -110,7 +116,9 @@ where
|
|||||||
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasRand,
|
CS::State: HasClientPerfMonitor + HasRand,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// Create a new [`PushStageHelper`]
|
/// Create a new [`PushStageHelper`]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -178,7 +186,9 @@ where
|
|||||||
CS::State: HasClientPerfMonitor + HasRand + HasExecutions + HasMetadata,
|
CS::State: HasClientPerfMonitor + HasRand + HasExecutions + HasMetadata,
|
||||||
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId + ProgressReporter,
|
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId + ProgressReporter,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// Gets the [`PushStageHelper`]
|
/// Gets the [`PushStageHelper`]
|
||||||
fn push_stage_helper(&self) -> &PushStageHelper<CS, EM, OT, Z>;
|
fn push_stage_helper(&self) -> &PushStageHelper<CS, EM, OT, Z>;
|
||||||
|
@ -44,7 +44,9 @@ where
|
|||||||
M: Mutator<CS::State>,
|
M: Mutator<CS::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasRand + Clone + Debug,
|
CS::State: HasClientPerfMonitor + HasRand + Clone + Debug,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
current_corpus_idx: Option<usize>,
|
current_corpus_idx: Option<usize>,
|
||||||
testcases_to_do: usize,
|
testcases_to_do: usize,
|
||||||
@ -64,7 +66,9 @@ where
|
|||||||
M: Mutator<CS::State>,
|
M: Mutator<CS::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
|
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// Gets the number of iterations as a random number
|
/// Gets the number of iterations as a random number
|
||||||
#[allow(clippy::unused_self, clippy::unnecessary_wraps)] // TODO: we should put this function into a trait later
|
#[allow(clippy::unused_self, clippy::unnecessary_wraps)] // TODO: we should put this function into a trait later
|
||||||
@ -86,7 +90,9 @@ where
|
|||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State:
|
CS::State:
|
||||||
HasClientPerfMonitor + HasCorpus + HasRand + HasExecutions + HasMetadata + Clone + Debug,
|
HasClientPerfMonitor + HasCorpus + HasRand + HasExecutions + HasMetadata + Clone + Debug,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn push_stage_helper(&self) -> &PushStageHelper<CS, EM, OT, Z> {
|
fn push_stage_helper(&self) -> &PushStageHelper<CS, EM, OT, Z> {
|
||||||
@ -197,7 +203,9 @@ where
|
|||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State:
|
CS::State:
|
||||||
HasClientPerfMonitor + HasCorpus + HasRand + HasExecutions + HasMetadata + Clone + Debug,
|
HasClientPerfMonitor + HasCorpus + HasRand + HasExecutions + HasMetadata + Clone + Debug,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
type Item = Result<<CS::State as UsesInput>::Input, Error>;
|
type Item = Result<<CS::State as UsesInput>::Input, Error>;
|
||||||
|
|
||||||
@ -213,7 +221,9 @@ where
|
|||||||
M: Mutator<CS::State>,
|
M: Mutator<CS::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
|
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State> + EvaluatorObservers<OT> + HasScheduler<CS>,
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
|
+ EvaluatorObservers<OT>
|
||||||
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// Creates a new default mutational stage
|
/// Creates a new default mutational stage
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -45,8 +45,8 @@ where
|
|||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
Z: ExecutionProcessor<OT, State = Self::State>
|
Z: ExecutionProcessor<OT, State = Self::State>
|
||||||
+ ExecutesInput<E, EM>
|
+ ExecutesInput<E, EM>
|
||||||
+ HasFeedback<F1>
|
+ HasFeedback<Feedback = F1>
|
||||||
+ HasScheduler<CS>,
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// The mutator registered for this stage
|
/// The mutator registered for this stage
|
||||||
fn mutator(&self) -> &M;
|
fn mutator(&self) -> &M;
|
||||||
@ -198,8 +198,8 @@ where
|
|||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<CS::State>,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
+ ExecutesInput<E, EM>
|
+ ExecutesInput<E, EM>
|
||||||
+ HasFeedback<F1>
|
+ HasFeedback<Feedback = F1>
|
||||||
+ HasScheduler<CS>,
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -246,8 +246,8 @@ where
|
|||||||
CS::State: HasClientPerfMonitor + HasCorpus + HasExecutions + HasMaxSize,
|
CS::State: HasClientPerfMonitor + HasCorpus + HasExecutions + HasMaxSize,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>
|
Z: ExecutionProcessor<OT, State = CS::State>
|
||||||
+ ExecutesInput<E, EM>
|
+ ExecutesInput<E, EM>
|
||||||
+ HasFeedback<F1>
|
+ HasFeedback<Feedback = F1>
|
||||||
+ HasScheduler<CS>,
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
/// The mutator, added to this stage
|
/// The mutator, added to this stage
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -66,7 +66,7 @@ where
|
|||||||
EM: EventFirer<State = S> + EventRestarter<State = S>,
|
EM: EventFirer<State = S> + EventRestarter<State = S>,
|
||||||
OF: Feedback<S>,
|
OF: Feedback<S>,
|
||||||
S: State + HasExecutions + HasCorpus + HasSolutions + HasClientPerfMonitor,
|
S: State + HasExecutions + HasCorpus + HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = S>,
|
Z: HasObjective<Objective = OF, State = S>,
|
||||||
{
|
{
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
first_exec: true,
|
first_exec: true,
|
||||||
@ -215,7 +215,7 @@ where
|
|||||||
EM: EventFirer<State = S> + EventRestarter,
|
EM: EventFirer<State = S> + EventRestarter,
|
||||||
OF: Feedback<S>,
|
OF: Feedback<S>,
|
||||||
S: HasSolutions + HasClientPerfMonitor,
|
S: HasSolutions + HasClientPerfMonitor,
|
||||||
Z: HasObjective<OF, State = S>,
|
Z: HasObjective<Objective = OF, State = S>,
|
||||||
{
|
{
|
||||||
assert!(!QT::HOOKS_DO_SIDE_EFFECTS, "When using QemuForkExecutor, the hooks must not do any side effect as they will happen in the child process and then discarded");
|
assert!(!QT::HOOKS_DO_SIDE_EFFECTS, "When using QemuForkExecutor, the hooks must not do any side effect as they will happen in the child process and then discarded");
|
||||||
|
|
||||||
|
8
scripts/find_unused_rs_files.sh
Executable file
8
scripts/find_unused_rs_files.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script to find .rs files that don't get built.
|
||||||
|
|
||||||
|
cargo +nightly build --examples --all-features --tests
|
||||||
|
|
||||||
|
# Find all files in deps, then compare to all actual .d files. Ignore a range of files.
|
||||||
|
grep --no-filename '^[^/].*\.rs:$' target/debug/deps/*.d | sed 's/:$//' | sort -u | diff - <(find . -name '*.rs' | sed 's/\.\///' | sort -u) | grep -Ev '(target/|scripts/|symcc_runtime/|build.rs|fuzzers/)'
|
Loading…
x
Reference in New Issue
Block a user