diff --git a/libafl/src/events/llmp.rs b/libafl/src/events/llmp.rs index 53db7d30ae..b7200ec1d3 100644 --- a/libafl/src/events/llmp.rs +++ b/libafl/src/events/llmp.rs @@ -303,10 +303,15 @@ where // Correctly handled the event Ok(BrokerEventResult::Handled) } - Event::Objective { objective_size } => { + Event::Objective { + objective_size, + executions, + time, + } => { monitor.client_stats_insert(client_id); let client = monitor.client_stats_mut_for(client_id); client.update_objective_size(*objective_size as u64); + client.update_executions(*executions, *time); monitor.display(event.name(), client_id); Ok(BrokerEventResult::Handled) } diff --git a/libafl/src/events/mod.rs b/libafl/src/events/mod.rs index 178de9f8fb..f97ef86442 100644 --- a/libafl/src/events/mod.rs +++ b/libafl/src/events/mod.rs @@ -338,6 +338,10 @@ where Objective { /// Objective corpus size objective_size: usize, + /// The total number of executions when this objective is found + executions: u64, + /// The time when this event was created + time: Duration, }, /// Write a new log Log { diff --git a/libafl/src/events/simple.rs b/libafl/src/events/simple.rs index 94589c002d..a6ab1bde70 100644 --- a/libafl/src/events/simple.rs +++ b/libafl/src/events/simple.rs @@ -262,11 +262,18 @@ where monitor.display(event.name(), ClientId(0)); Ok(BrokerEventResult::Handled) } - Event::Objective { objective_size } => { + Event::Objective { + objective_size, + executions, + time, + } => { monitor.client_stats_insert(ClientId(0)); monitor .client_stats_mut_for(ClientId(0)) .update_objective_size(*objective_size as u64); + monitor + .client_stats_mut_for(ClientId(0)) + .update_executions(*executions, *time); monitor.display(event.name(), ClientId(0)); Ok(BrokerEventResult::Handled) } diff --git a/libafl/src/events/tcp.rs b/libafl/src/events/tcp.rs index 9fe7976ee8..daefd57d19 100644 --- a/libafl/src/events/tcp.rs +++ b/libafl/src/events/tcp.rs @@ -386,10 +386,15 @@ where // Correctly handled the event Ok(BrokerEventResult::Handled) } - Event::Objective { objective_size } => { + Event::Objective { + objective_size, + executions, + time, + } => { monitor.client_stats_insert(client_id); let client = monitor.client_stats_mut_for(client_id); client.update_objective_size(*objective_size as u64); + client.update_executions(*executions, *time); monitor.display(event.name(), client_id); Ok(BrokerEventResult::Handled) } diff --git a/libafl/src/executors/inprocess/mod.rs b/libafl/src/executors/inprocess/mod.rs index 27295815ed..cd8903e797 100644 --- a/libafl/src/executors/inprocess/mod.rs +++ b/libafl/src/executors/inprocess/mod.rs @@ -450,7 +450,8 @@ pub fn run_observers_and_save_state( .expect("In run_observers_and_save_state objective failure."); if interesting { - let mut new_testcase = Testcase::with_executions(input.clone(), *state.executions()); + let executions = *state.executions(); + let mut new_testcase = Testcase::with_executions(input.clone(), executions); new_testcase.add_metadata(exitkind); new_testcase.set_parent_id_optional(*state.corpus().current()); fuzzer @@ -466,6 +467,8 @@ pub fn run_observers_and_save_state( state, Event::Objective { objective_size: state.solutions().count(), + executions, + time: libafl_bolts::current_time(), }, ) .expect("Could not save state in run_observers_and_save_state"); diff --git a/libafl/src/fuzzer/mod.rs b/libafl/src/fuzzer/mod.rs index 6f5051de76..492aa019cc 100644 --- a/libafl/src/fuzzer/mod.rs +++ b/libafl/src/fuzzer/mod.rs @@ -415,8 +415,9 @@ where // Not interesting self.feedback_mut().discard_metadata(state, &input)?; + let executions = *state.executions(); // The input is a solution, add it to the respective corpus - let mut testcase = Testcase::with_executions(input, *state.executions()); + let mut testcase = Testcase::with_executions(input, executions); testcase.set_parent_id_optional(*state.corpus().current()); self.objective_mut() .append_metadata(state, manager, observers, &mut testcase)?; @@ -427,6 +428,8 @@ where state, Event::Objective { objective_size: state.solutions().count(), + executions, + time: current_time(), }, )?; } @@ -520,10 +523,13 @@ where .append_metadata(state, manager, observers, &mut testcase)?; let idx = state.solutions_mut().add(testcase)?; + let executions = *state.executions(); manager.fire( state, Event::Objective { objective_size: state.solutions().count(), + executions, + time: current_time(), }, )?; return Ok(idx);