Add AFLStats to QEMU_Launcher TUI (#2611)

* Remove prelude from qemu_launcher

* QEMU_Launcher: Add stats to TUI

* More tui
This commit is contained in:
Dominik Maier 2024-10-14 11:06:21 +02:00 committed by GitHub
parent 1ad64e7ae7
commit da8f17f29e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View File

@ -34,7 +34,7 @@ pub struct Client<'a> {
options: &'a FuzzerOptions, options: &'a FuzzerOptions,
} }
impl<'a> Client<'a> { impl Client<'_> {
pub fn new(options: &FuzzerOptions) -> Client { pub fn new(options: &FuzzerOptions) -> Client {
Client { options } Client { options }
} }

View File

@ -1,5 +1,5 @@
use core::{fmt::Debug, ptr::addr_of_mut}; use core::{fmt::Debug, ptr::addr_of_mut};
use std::{fs, marker::PhantomData, ops::Range, process}; use std::{fs, marker::PhantomData, ops::Range, process, time::Duration};
#[cfg(feature = "simplemgr")] #[cfg(feature = "simplemgr")]
use libafl::events::SimpleEventManager; use libafl::events::SimpleEventManager;
@ -23,8 +23,8 @@ use libafl::{
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, PowerQueueScheduler, powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, PowerQueueScheduler,
}, },
stages::{ stages::{
calibrate::CalibrationStage, power::StdPowerMutationalStage, ShadowTracingStage, calibrate::CalibrationStage, power::StdPowerMutationalStage, AflStatsStage, IfStage,
StagesTuple, StdMutationalStage, ShadowTracingStage, StagesTuple, StdMutationalStage,
}, },
state::{HasCorpus, StdState, UsesState}, state::{HasCorpus, StdState, UsesState},
Error, HasMetadata, NopFuzzer, Error, HasMetadata, NopFuzzer,
@ -73,7 +73,7 @@ pub struct Instance<'a, M: Monitor> {
phantom: PhantomData<M>, phantom: PhantomData<M>,
} }
impl<'a, M: Monitor> Instance<'a, M> { impl<M: Monitor> Instance<'_, M> {
#[allow(clippy::similar_names)] // elf != self #[allow(clippy::similar_names)] // elf != self
fn coverage_filter(&self, qemu: Qemu) -> Result<StdAddressFilter, Error> { fn coverage_filter(&self, qemu: Qemu) -> Result<StdAddressFilter, Error> {
/* Conversion is required on 32-bit targets, but not on 64-bit ones */ /* Conversion is required on 32-bit targets, but not on 64-bit ones */
@ -107,6 +107,7 @@ impl<'a, M: Monitor> Instance<'a, M> {
} }
} }
#[allow(clippy::too_many_lines)]
pub fn run<ET>(&mut self, modules: ET, state: Option<ClientState>) -> Result<(), Error> pub fn run<ET>(&mut self, modules: ET, state: Option<ClientState>) -> Result<(), Error>
where where
ET: EmulatorModuleTuple<ClientState> + Debug, ET: EmulatorModuleTuple<ClientState> + Debug,
@ -135,6 +136,11 @@ impl<'a, M: Monitor> Instance<'a, M> {
let calibration = CalibrationStage::new(&map_feedback); let calibration = CalibrationStage::new(&map_feedback);
let stats_stage = IfStage::new(
|_, _, _, _| Ok(self.options.tui),
tuple_list!(AflStatsStage::new(Duration::from_secs(5))),
);
// Feedback to rate the interestingness of an input // Feedback to rate the interestingness of an input
// This one is composed by two Feedbacks in OR // This one is composed by two Feedbacks in OR
let mut feedback = feedback_or!( let mut feedback = feedback_or!(
@ -268,7 +274,7 @@ impl<'a, M: Monitor> Instance<'a, M> {
StdPowerMutationalStage::new(mutator); StdPowerMutationalStage::new(mutator);
// The order of the stages matter! // The order of the stages matter!
let mut stages = tuple_list!(calibration, tracing, i2s, power); let mut stages = tuple_list!(calibration, tracing, i2s, power, stats_stage);
self.fuzz(&mut state, &mut fuzzer, &mut executor, &mut stages) self.fuzz(&mut state, &mut fuzzer, &mut executor, &mut stages)
} else { } else {

View File

@ -199,7 +199,7 @@ impl FuzzerOptions {
let mut cmd = FuzzerOptions::command(); let mut cmd = FuzzerOptions::command();
cmd.error( cmd.error(
ErrorKind::ValueValidation, ErrorKind::ValueValidation,
format!("The `drcov` option is only supported with `rerun_input`."), "The `drcov` option is only supported with `rerun_input`.".to_string(),
) )
.exit(); .exit();
} }