towards compilation
This commit is contained in:
parent
b2e1fa0de4
commit
1467d1fa9c
@ -115,12 +115,15 @@ where
|
|||||||
|
|
||||||
/// Adds a feedback
|
/// Adds a feedback
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_feedback(&mut self, feedback: Box<dyn Feedback<I>>) {
|
pub fn add_feedback(&mut self, feedback: Box<FT>) {
|
||||||
self.feedbacks_mut().push(feedback);
|
self.feedbacks_mut().push(feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move some of these, like evaluate_input, to FuzzingEngine
|
// TODO move some of these, like evaluate_input, to FuzzingEngine
|
||||||
pub fn is_interesting(&mut self, input: &I, observers: &crate::observers::observer_serde::NamedSerdeAnyMap) -> Result<u32, AflError> {
|
pub fn is_interesting<OT>(&mut self, input: &I, observers: &OT) -> Result<u32, AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
let mut fitness;
|
let mut fitness;
|
||||||
for feedback in self.feedbacks_mut() {
|
for feedback in self.feedbacks_mut() {
|
||||||
fitness += feedback.is_interesting(&input, observers)?;
|
fitness += feedback.is_interesting(&input, observers)?;
|
||||||
|
@ -238,12 +238,11 @@ impl LlmpConnection {
|
|||||||
/// Sends the given buffer over this connection, no matter if client or broker.
|
/// Sends the given buffer over this connection, no matter if client or broker.
|
||||||
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), AflError> {
|
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), AflError> {
|
||||||
match self {
|
match self {
|
||||||
LlmpConnection::IsBroker {broker, listener_thread: _} => {
|
LlmpConnection::IsBroker {
|
||||||
broker.send_buf(tag, buf)
|
broker,
|
||||||
},
|
listener_thread: _,
|
||||||
LlmpConnection::IsClient {client} => {
|
} => broker.send_buf(tag, buf),
|
||||||
client.send_buf(tag, buf)
|
LlmpConnection::IsClient { client } => client.send_buf(tag, buf),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,12 +250,11 @@ impl LlmpConnection {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn recv_buf(&mut self) -> Result<Option<(u32, &[u8])>, AflError> {
|
pub fn recv_buf(&mut self) -> Result<Option<(u32, &[u8])>, AflError> {
|
||||||
match self {
|
match self {
|
||||||
LlmpConnection::IsBroker {broker, listener_thread: _} => {
|
LlmpConnection::IsBroker {
|
||||||
broker.recv_buf()
|
broker,
|
||||||
},
|
listener_thread: _,
|
||||||
LlmpConnection::IsClient {client} => {
|
} => broker.recv_buf(),
|
||||||
client.recv_buf()
|
LlmpConnection::IsClient { client } => client.recv_buf(),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +264,6 @@ impl LlmpConnection {
|
|||||||
pub unsafe fn recv_blocking(&mut self) -> Result<*mut LlmpMsg, AflError> {
|
pub unsafe fn recv_blocking(&mut self) -> Result<*mut LlmpMsg, AflError> {
|
||||||
self.llmp_in.recv_blocking()
|
self.llmp_in.recv_blocking()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Contents of the share mem pages, used by llmp internally
|
/// Contents of the share mem pages, used by llmp internally
|
||||||
|
@ -12,10 +12,12 @@ use serde::{Deserialize, Serialize};
|
|||||||
//pub mod shmem_translated;
|
//pub mod shmem_translated;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::{io::Write, time::{SystemTime, UNIX_EPOCH}};
|
use std::{
|
||||||
|
io::Write,
|
||||||
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::corpus::Corpus;
|
use crate::corpus::Corpus;
|
||||||
use crate::{engines::State, utils};
|
|
||||||
use crate::executors::Executor;
|
use crate::executors::Executor;
|
||||||
use crate::feedbacks::FeedbacksTuple;
|
use crate::feedbacks::FeedbacksTuple;
|
||||||
use crate::inputs::Input;
|
use crate::inputs::Input;
|
||||||
@ -23,6 +25,7 @@ use crate::observers::ObserversTuple;
|
|||||||
use crate::serde_anymap::{Ptr, PtrMut, SerdeAny};
|
use crate::serde_anymap::{Ptr, PtrMut, SerdeAny};
|
||||||
use crate::utils::Rand;
|
use crate::utils::Rand;
|
||||||
use crate::AflError;
|
use crate::AflError;
|
||||||
|
use crate::{engines::State, utils};
|
||||||
|
|
||||||
/// Indicate if an event worked or not
|
/// Indicate if an event worked or not
|
||||||
pub enum BrokerEventResult {
|
pub enum BrokerEventResult {
|
||||||
@ -201,14 +204,18 @@ where
|
|||||||
/// Total executions
|
/// Total executions
|
||||||
#[inline]
|
#[inline]
|
||||||
fn total_execs(&mut self) -> u64 {
|
fn total_execs(&mut self) -> u64 {
|
||||||
self.client_stats().iter().fold(0u64, |acc, x| acc + x.executions)
|
self.client_stats()
|
||||||
|
.iter()
|
||||||
|
.fold(0u64, |acc, x| acc + x.executions)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executions per second
|
/// Executions per second
|
||||||
#[inline]
|
#[inline]
|
||||||
fn execs_per_sec(&mut self) -> u64 {
|
fn execs_per_sec(&mut self) -> u64 {
|
||||||
let time_since_start = (utils::current_time() - self.start_time()).as_secs();
|
let time_since_start = (utils::current_time() - self.start_time()).as_secs();
|
||||||
if time_since_start == 0 { 0 } else {
|
if time_since_start == 0 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
self.total_execs() / time_since_start
|
self.total_execs() / time_since_start
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +232,9 @@ where
|
|||||||
self.corpus_size_inc();
|
self.corpus_size_inc();
|
||||||
println!(
|
println!(
|
||||||
"[NEW] corpus: {} execs: {} execs/s: {}",
|
"[NEW] corpus: {} execs: {} execs/s: {}",
|
||||||
self.corpus_size(), self.total_execs(), self.execs_per_sec()
|
self.corpus_size(),
|
||||||
|
self.total_execs(),
|
||||||
|
self.execs_per_sec()
|
||||||
);
|
);
|
||||||
Ok(BrokerEventResult::Forward)
|
Ok(BrokerEventResult::Forward)
|
||||||
}
|
}
|
||||||
@ -242,13 +251,15 @@ where
|
|||||||
id: client_stat_count + i,
|
id: client_stat_count + i,
|
||||||
corpus_size: 0,
|
corpus_size: 0,
|
||||||
execs_over_sec: 0,
|
execs_over_sec: 0,
|
||||||
executions: 0
|
executions: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let mut stat = &mut self.client_stats_mut()[*sender_id as usize];
|
let mut stat = &mut self.client_stats_mut()[*sender_id as usize];
|
||||||
println!(
|
println!(
|
||||||
"[UPDATE] corpus: {} execs: {} execs/s: {}",
|
"[UPDATE] corpus: {} execs: {} execs/s: {}",
|
||||||
self.corpus_size(), self.total_execs(), self.execs_per_sec()
|
self.corpus_size(),
|
||||||
|
self.total_execs(),
|
||||||
|
self.execs_per_sec()
|
||||||
);
|
);
|
||||||
Ok(BrokerEventResult::Handled)
|
Ok(BrokerEventResult::Handled)
|
||||||
}
|
}
|
||||||
@ -385,7 +396,6 @@ where
|
|||||||
fn start_time(&mut self) -> time::Duration {
|
fn start_time(&mut self) -> time::Duration {
|
||||||
self.start_time
|
self.start_time
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@ -414,7 +424,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
/// Forward this to the client
|
/// Forward this to the client
|
||||||
const LLMP_TAG_EVENT_TO_CLIENT: llmp::Tag = 0x2C11E471;
|
const LLMP_TAG_EVENT_TO_CLIENT: llmp::Tag = 0x2C11E471;
|
||||||
@ -425,8 +434,6 @@ const _LLMP_TAG_EVENT_TO_BROKER: llmp::Tag = 0x2B80438;
|
|||||||
/// Handle in both
|
/// Handle in both
|
||||||
const _LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741;
|
const _LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub struct LlmpEventManager<C, E, I, R, W>
|
pub struct LlmpEventManager<C, E, I, R, W>
|
||||||
where
|
where
|
||||||
@ -451,7 +458,6 @@ impl<C, E, I, R, W> EventManager<C, E, I, R> for LlmpEventManager<C, E, I, R, W>
|
|||||||
where
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
E: Executor<I>,
|
E: Executor<I>,
|
||||||
OT: ObserversTuple,
|
|
||||||
FT: FeedbacksTuple<I>,
|
FT: FeedbacksTuple<I>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
@ -461,12 +467,15 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn fire<'a>(&mut self, event: Event<'a, I>) -> Result<(), AflError> {
|
fn fire<'a>(&mut self, event: Event<'a, I>) -> Result<(), AflError> {
|
||||||
let serialized = postcard::to_allocvec(&event)?;
|
let serialized = postcard::to_allocvec(&event)?;
|
||||||
self
|
self.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
|
||||||
.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process(&mut self, _state: &mut State<I, R>, _corpus: &mut C) -> Result<usize, AflError> {
|
fn process(
|
||||||
|
&mut self,
|
||||||
|
_state: &mut State<I, R, FT>,
|
||||||
|
_corpus: &mut C,
|
||||||
|
) -> Result<usize, AflError> {
|
||||||
let c = self.count;
|
let c = self.count;
|
||||||
self.count = 0;
|
self.count = 0;
|
||||||
Ok(c)
|
Ok(c)
|
||||||
@ -492,7 +501,6 @@ where
|
|||||||
fn start_time(&mut self) -> time::Duration {
|
fn start_time(&mut self) -> time::Duration {
|
||||||
self.start_time
|
self.start_time
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//! Utility functions for AFL
|
//! Utility functions for AFL
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::{cell::RefCell, time};
|
|
||||||
use core::debug_assert;
|
use core::debug_assert;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
use core::{cell::RefCell, time};
|
||||||
use xxhash_rust::xxh3::xxh3_64_with_seed;
|
use xxhash_rust::xxh3::xxh3_64_with_seed;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user