Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions crates/libafl/src/stages/afl_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use libafl_bolts::{
Named,
core_affinity::CoreId,
current_time,
tuples::{Handle, Handled, MatchName},
tuples::{Handle, MatchName},
};
use serde::{Deserialize, Serialize};

Expand All @@ -29,7 +29,7 @@ use crate::{
corpus::{Corpus, HasCurrentCorpusId, SchedulerTestcaseMetadata, Testcase},
events::{Event, EventFirer, EventWithStats},
executors::HasObservers,
feedbacks::MapFeedbackMetadata,
feedbacks::{HasObserverHandle, MapFeedbackMetadata},
monitors::stats::{AggregatorOps, UserStats, UserStatsValue},
mutators::Tokens,
observers::MapObserver,
Expand Down Expand Up @@ -722,20 +722,15 @@ where
self.report_interval = interval;
self
}
/// Our `MapObserver`
#[must_use]
pub fn map_observer(mut self, map_observer: &C) -> Self {
self.map_observer_handle = Some(map_observer.handle());
self
}

/// map name to check the filled count
#[must_use]
pub fn map_name<F>(mut self, map_feedback: &F) -> Self
pub fn map_feedback<F>(mut self, map_feedback: &F) -> Self
where
F: Named,
F: Named + HasObserverHandle<Observer = C>,
{
self.map_name = Some(map_feedback.name().to_string());
self.map_observer_handle = Some(map_feedback.observer_handle().clone());
self
}

Expand Down Expand Up @@ -804,11 +799,8 @@ where
/// No `stats_file_path` provieded
#[allow(clippy::type_complexity)]
pub fn build(self) -> Result<AflStatsStage<C, I, O>, Error> {
if self.map_observer_handle.is_none() {
return Err(Error::illegal_argument("Must set `map_observer`"));
}
let Some(map_name) = self.map_name else {
return Err(Error::illegal_argument("Must set `map_name`"));
return Err(Error::illegal_argument("Must set `map_feedback`"));
};
if let Some(ref plot_file) = self.plot_file_path {
Self::create_plot_data_file(plot_file)?;
Expand Down
3 changes: 1 addition & 2 deletions fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ pub fn main() {

let calibration_stage = CalibrationStage::new(&feedback);
let stats_stage = AflStatsStage::builder()
.map_observer(&observer)
.map_name(&feedback)
.map_feedback(&feedback)
.build()
.unwrap();

Expand Down
6 changes: 2 additions & 4 deletions fuzzers/binary_only/qemu_launcher/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,13 @@ where
let stats_stage = IfStage::new(
|_, _, _, _| Ok(self.options.tui),
tuple_list!(AflStatsStage::builder()
.map_observer(&edges_observer)
.map_name(&map_feedback)
.map_feedback(&map_feedback)
.build()?),
);
let stats_stage_cmplog = IfStage::new(
|_, _, _, _| Ok(self.options.tui),
tuple_list!(AflStatsStage::builder()
.map_observer(&edges_observer)
.map_name(&map_feedback)
.map_feedback(&map_feedback)
.build()?),
);

Expand Down
3 changes: 1 addition & 2 deletions fuzzers/forkserver/libafl-fuzz/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
.plot_file(fuzzer_dir.join("plot_data"))
.core_id(core_id)
.report_interval(Duration::from_secs(opt.stats_interval))
.map_observer(&edges_observer)
.map_name(&map_feedback)
.map_feedback(&map_feedback)
.uses_autotokens(!opt.no_autodict)
.tokens(&tokens)
.banner(opt.executable.display().to_string())
Expand Down
Loading