release settings changed

This commit is contained in:
Dominik Maier 2020-12-11 11:09:11 +01:00
parent 6e81c259f7
commit 7af0ae421e
8 changed files with 67 additions and 67 deletions

View File

@ -21,7 +21,11 @@ harness = false
name = "hash_speeds"
harness = false
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
debug = true
[features]
default = ["std"]

View File

@ -213,14 +213,15 @@ where
if !self.add_if_interesting(corpus, input, fitness)?.is_none() {
added += 1;
}
manager.fire(
Event::LoadInitial {
sender_id: 0,
phantom: PhantomData,
}
)?;
manager.fire(Event::LoadInitial {
sender_id: 0,
phantom: PhantomData,
})?;
}
manager.fire(Event::log(0, format!("Loaded {} over {} initial testcases", added, num)))?;
manager.fire(Event::log(
0,
format!("Loaded {} over {} initial testcases", added, num),
))?;
manager.process(self, corpus)?;
Ok(())
}
@ -318,7 +319,10 @@ where
let cur = current_milliseconds();
if cur - last > 60 * 100 {
last = cur;
manager.fire(Event::update_stats(state.executions(), state.executions_over_seconds()))?;
manager.fire(Event::update_stats(
state.executions(),
state.executions_over_seconds(),
))?;
}
}
}

View File

@ -60,7 +60,7 @@ where
sender_id: u64,
input: Ptr<'a, I>,
observers: PtrMut<'a, crate::observers::observer_serde::NamedSerdeAnyMap>,
corpus_count: usize
corpus_count: usize,
},
UpdateStats {
sender_id: u64,
@ -109,7 +109,7 @@ where
sender_id: _,
input: _,
observers: _,
corpus_count: _
corpus_count: _,
} => "New Testcase",
Event::UpdateStats {
sender_id: _,
@ -135,7 +135,7 @@ where
} => "Log",
Event::None { phantom: _ } => "None",
Event::Custom {
sender_id, /*custom_event} => custom_event.name()*/
sender_id: _, /*custom_event} => custom_event.name()*/
} => "todo",
}
}
@ -167,10 +167,7 @@ where
R: Rand,
{
/// Fire an Event
fn fire<'a>(
&mut self,
event: Event<'a, I>
) -> Result<(), AflError>;
fn fire<'a>(&mut self, event: Event<'a, I>) -> Result<(), AflError>;
/// Lookup for incoming events and process them.
/// Return the number of processes events or an error
@ -183,10 +180,7 @@ where
}
// TODO the broker has a state? do we need to pass state and corpus?
fn handle_in_broker(
&mut self,
event: &Event<I>,
) -> Result<BrokerEventResult, AflError> {
fn handle_in_broker(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError> {
match event {
Event::LoadInitial {
sender_id: _,
@ -196,7 +190,7 @@ where
sender_id: _,
input: _,
observers: _,
corpus_count: _
corpus_count: _,
} => Ok(BrokerEventResult::Forward),
Event::UpdateStats {
sender_id: _,
@ -233,7 +227,7 @@ where
}
Event::None { phantom: _ } => Ok(BrokerEventResult::Handled),
Event::Custom {
sender_id, /*custom_event} => custom_event.handle_in_broker(state, corpus)*/
sender_id: _, /*custom_event} => custom_event.handle_in_broker(state, corpus)*/
} => Ok(BrokerEventResult::Forward),
//_ => Ok(BrokerEventResult::Forward),
}
@ -250,7 +244,7 @@ where
sender_id: _,
input: _,
observers: _,
corpus_count: _
corpus_count: _,
} => {
// here u should match sender_id, if equal to the current one do not re-execute
// we need to pass engine to process() too, TODO
@ -304,10 +298,7 @@ where
W: Write,
//CE: CustomEvent<I>,
{
fn fire<'a>(
&mut self,
event: Event<'a, I>,
) -> Result<(), AflError> {
fn fire<'a>(&mut self, event: Event<'a, I>) -> Result<(), AflError> {
match self.handle_in_broker(&event)? {
BrokerEventResult::Forward => (), //self.handle_in_client(event, state, corpus)?,
// Ignore broker-only events
@ -322,21 +313,22 @@ where
Ok(c)
}
fn handle_in_broker(
&mut self,
event: &Event<I>,
) -> Result<BrokerEventResult, AflError> {
fn handle_in_broker(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError> {
match event {
Event::NewTestcase {
sender_id: _,
input: _,
observers: _,
corpus_count
corpus_count,
} => {
self.corpus_count = *corpus_count;
writeln!(self.writer, "[NEW] corpus: {} execs: {} execs/s: {}", self.corpus_count, self.executions, self.execs_over_sec);
writeln!(
self.writer,
"[NEW] corpus: {} execs: {} execs/s: {}",
self.corpus_count, self.executions, self.execs_over_sec
)?;
Ok(BrokerEventResult::Handled)
},
}
Event::UpdateStats {
sender_id: _,
executions,
@ -345,7 +337,11 @@ where
} => {
self.executions = *executions;
self.execs_over_sec = *execs_over_sec;
writeln!(self.writer, "[UPDATE] corpus: {} execs: {} execs/s: {}", self.corpus_count, self.executions, self.execs_over_sec);
writeln!(
self.writer,
"[UPDATE] corpus: {} execs: {} execs/s: {}",
self.corpus_count, self.executions, self.execs_over_sec
)?;
Ok(BrokerEventResult::Handled)
}
Event::Crash {
@ -354,7 +350,7 @@ where
phantom: _,
} => {
panic!("LoggerEventManager cannot handle Event::Crash");
},
}
Event::Timeout {
sender_id: _,
input: _,
@ -363,12 +359,12 @@ where
panic!("LoggerEventManager cannot handle Event::Timeout");
}
Event::Log {
sender_id,
sender_id: _,
severity_level,
message,
phantom: _,
} => {
writeln!(self.writer, "[LOG {}]: {}", severity_level, message);
writeln!(self.writer, "[LOG {}]: {}", severity_level, message)?;
Ok(BrokerEventResult::Handled)
}
_ => Ok(BrokerEventResult::Handled),
@ -417,10 +413,10 @@ where
const LLMP_TAG_EVENT_TO_CLIENT: llmp::Tag = 0x2C11E471;
#[cfg(feature = "std")]
/// Only handle this in the broker
const LLMP_TAG_EVENT_TO_BROKER: llmp::Tag = 0x2B80438;
const _LLMP_TAG_EVENT_TO_BROKER: llmp::Tag = 0x2B80438;
#[cfg(feature = "std")]
/// Handle in both
const LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741;
const _LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741;
/// Eventmanager for multi-processed application
#[cfg(feature = "std")]
@ -432,7 +428,7 @@ where
R: Rand,
//CE: CustomEvent<I>,
{
llmp_client: llmp::LlmpClient,
_llmp_client: llmp::LlmpClient,
phantom: PhantomData<(C, E, I, R)>,
}
@ -445,10 +441,7 @@ where
R: Rand,
{
/// Fire an Event
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)?;
self.llmp_broker
.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
@ -490,10 +483,7 @@ where
Ok(())
}
fn handle_in_broker(
&mut self,
event: &Event<I>,
) -> Result<BrokerEventResult, AflError> {
fn handle_in_broker(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError> {
match event {
Event::LoadInitial {
sender_id: _,
@ -503,7 +493,7 @@ where
sender_id: _,
input: _,
observers: _,
corpus_count: _
corpus_count: _,
} => Ok(BrokerEventResult::Forward),
Event::UpdateStats {
sender_id: _,
@ -540,7 +530,7 @@ where
}
Event::None { phantom: _ } => Ok(BrokerEventResult::Handled),
Event::Custom {
sender_id, /*custom_event} => custom_event.handle_in_broker(state, corpus)*/
sender_id: _, /*custom_event} => custom_event.handle_in_broker(state, corpus)*/
} => Ok(BrokerEventResult::Forward),
//_ => Ok(BrokerEventResult::Forward),
}
@ -550,14 +540,14 @@ where
&mut self,
event: Event<I>,
/*client: &dyn EventManager<C, E, I, R>,*/ _state: &mut State<I, R>,
corpus: &mut C,
_corpus: &mut C,
) -> Result<(), AflError> {
match event {
Event::NewTestcase {
sender_id: _,
input: _,
observers: _,
corpus_count: _
corpus_count: _,
} => {
// here u should match sender_id, if equal to the current one do not re-execute
// we need to pass engine to process() too, TODO
@ -599,7 +589,7 @@ mod tests {
sender_id: 0,
input: Ptr::Ref(&i),
observers: PtrMut::Ref(&mut map),
corpus_count: 1
corpus_count: 1,
};
let j = serde_json::to_string(&e).unwrap();
@ -610,7 +600,7 @@ mod tests {
sender_id: _,
input: _,
observers: obs,
corpus_count: _
corpus_count: _,
} => {
let o = obs
.as_ref()

View File

@ -3,8 +3,6 @@ pub use bytes::BytesInput;
use alloc::vec::Vec;
use core::clone::Clone;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::fs::File;

View File

@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use alloc::boxed::Box;
use alloc::vec::Vec;

View File

@ -68,14 +68,12 @@ where
let testcase_maybe = state.testcase_if_interesting(input_mut, fitness)?;
if let Some(mut testcase) = testcase_maybe {
// TODO decouple events manager and engine
manager.fire(
Event::NewTestcase {
sender_id: 0,
input: Ptr::Ref(testcase.load_input()?),
observers: PtrMut::Ref(engine.executor_mut().observers_mut()),
corpus_count: corpus.count() +1
}
)?;
manager.fire(Event::NewTestcase {
sender_id: 0,
input: Ptr::Ref(testcase.load_input()?),
observers: PtrMut::Ref(engine.executor_mut().observers_mut()),
corpus_count: corpus.count() + 1,
})?;
let _ = corpus.add(testcase);
}
}

View File

@ -10,6 +10,12 @@ edition = "2018"
default = ["std"]
std = []
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
debug = true
[dependencies]
afl = { path = "../../afl/" }

View File

@ -22,7 +22,7 @@ use afl::observers::StdMapObserver;
use afl::stages::mutational::StdMutationalStage;
use afl::utils::StdRand;
const MAP_SIZE: usize = 65536;
// const MAP_SIZE: usize = 65536;
#[no_mangle]
extern "C" {