Rename HasCurrentStage to HasCurrentStageId for consistency (#2514)
This commit is contained in:
parent
70f1c13a4f
commit
25624d8eec
@ -116,7 +116,7 @@ use crate::events::multi_machine::NodeId;
|
||||
#[cfg(feature = "introspection")]
|
||||
use crate::monitors::ClientPerfMonitor;
|
||||
use crate::{
|
||||
inputs::UsesInput, observers::TimeObserver, stages::HasCurrentStage, state::UsesState,
|
||||
inputs::UsesInput, observers::TimeObserver, stages::HasCurrentStageId, state::UsesState,
|
||||
};
|
||||
|
||||
/// The log event severity
|
||||
@ -545,7 +545,7 @@ where
|
||||
/// Restartable trait
|
||||
pub trait EventRestarter: UsesState {
|
||||
/// For restarting event managers, implement a way to forward state to their next peers.
|
||||
/// You *must* ensure that [`HasCurrentStage::on_restart`] will be invoked in this method, by you
|
||||
/// You *must* ensure that [`HasCurrentStageId::on_restart`] will be invoked in this method, by you
|
||||
/// or an internal [`EventRestarter`], before the state is saved for recovery.
|
||||
#[inline]
|
||||
fn on_restart(&mut self, state: &mut Self::State) -> Result<(), Error> {
|
||||
|
@ -15,7 +15,7 @@ use crate::{
|
||||
mark_feature_time,
|
||||
observers::ObserversTuple,
|
||||
schedulers::Scheduler,
|
||||
stages::{HasCurrentStage, StagesTuple},
|
||||
stages::{HasCurrentStageId, StagesTuple},
|
||||
start_timer,
|
||||
state::{
|
||||
HasCorpus, HasCurrentTestcase, HasExecutions, HasLastFoundTime, HasLastReportTime,
|
||||
@ -769,7 +769,7 @@ where
|
||||
+ HasTestcase
|
||||
+ HasLastReportTime
|
||||
+ HasCurrentCorpusId
|
||||
+ HasCurrentStage,
|
||||
+ HasCurrentStageId,
|
||||
ST: StagesTuple<E, EM, Self::State, Self>,
|
||||
{
|
||||
fn fuzz_one(
|
||||
@ -940,7 +940,7 @@ pub mod test {
|
||||
use crate::{
|
||||
corpus::CorpusId,
|
||||
events::{EventProcessor, ProgressReporter},
|
||||
stages::{HasCurrentStage, StagesTuple},
|
||||
stages::{HasCurrentStageId, StagesTuple},
|
||||
state::{HasExecutions, HasLastReportTime, State, UsesState},
|
||||
Fuzzer, HasMetadata,
|
||||
};
|
||||
@ -977,7 +977,7 @@ pub mod test {
|
||||
E: UsesState,
|
||||
EM: ProgressReporter<State = Self::State> + EventProcessor<E, Self>,
|
||||
ST: StagesTuple<E, EM, Self::State, Self>,
|
||||
Self::State: HasMetadata + HasExecutions + HasLastReportTime + HasCurrentStage,
|
||||
Self::State: HasMetadata + HasExecutions + HasLastReportTime + HasCurrentStageId,
|
||||
{
|
||||
fn fuzz_one(
|
||||
&mut self,
|
||||
|
@ -3,7 +3,7 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use crate::{
|
||||
stages::{HasCurrentStage, HasNestedStageStatus, Stage, StageId, StagesTuple},
|
||||
stages::{HasCurrentStageId, HasNestedStageStatus, Stage, StageId, StagesTuple},
|
||||
state::UsesState,
|
||||
Error,
|
||||
};
|
||||
@ -61,7 +61,7 @@ where
|
||||
state: &mut Self::State,
|
||||
manager: &mut EM,
|
||||
) -> Result<(), Error> {
|
||||
while state.current_stage_idx()?.is_some()
|
||||
while state.current_stage_id()?.is_some()
|
||||
|| (self.closure)(fuzzer, executor, state, manager)?
|
||||
{
|
||||
self.stages.perform_all(fuzzer, executor, state, manager)?;
|
||||
@ -126,7 +126,7 @@ where
|
||||
state: &mut Self::State,
|
||||
manager: &mut EM,
|
||||
) -> Result<(), Error> {
|
||||
if state.current_stage_idx()?.is_some() || (self.closure)(fuzzer, executor, state, manager)?
|
||||
if state.current_stage_id()?.is_some() || (self.closure)(fuzzer, executor, state, manager)?
|
||||
{
|
||||
self.if_stages
|
||||
.perform_all(fuzzer, executor, state, manager)?;
|
||||
@ -192,21 +192,21 @@ where
|
||||
state: &mut Self::State,
|
||||
manager: &mut EM,
|
||||
) -> Result<(), Error> {
|
||||
let current = state.current_stage_idx()?;
|
||||
let current = state.current_stage_id()?;
|
||||
|
||||
let fresh = current.is_none();
|
||||
let closure_return = fresh && (self.closure)(fuzzer, executor, state, manager)?;
|
||||
|
||||
if current == Some(StageId(0)) || closure_return {
|
||||
if fresh {
|
||||
state.set_current_stage_idx(StageId(0))?;
|
||||
state.set_current_stage_id(StageId(0))?;
|
||||
}
|
||||
state.enter_inner_stage()?;
|
||||
self.if_stages
|
||||
.perform_all(fuzzer, executor, state, manager)?;
|
||||
} else {
|
||||
if fresh {
|
||||
state.set_current_stage_idx(StageId(1))?;
|
||||
state.set_current_stage_id(StageId(1))?;
|
||||
}
|
||||
state.enter_inner_stage()?;
|
||||
self.else_stages
|
||||
@ -214,7 +214,7 @@ where
|
||||
}
|
||||
|
||||
state.exit_inner_stage()?;
|
||||
state.clear_stage()?;
|
||||
state.clear_stage_id()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ where
|
||||
E: UsesState<State = S>,
|
||||
EM: UsesState<State = S>,
|
||||
Z: UsesState<State = S>,
|
||||
S: UsesInput + HasCurrentStage,
|
||||
S: UsesInput + HasCurrentStageId,
|
||||
{
|
||||
/// Performs all `Stages` in this tuple.
|
||||
fn perform_all(
|
||||
@ -152,7 +152,7 @@ where
|
||||
E: UsesState<State = S>,
|
||||
EM: UsesState<State = S>,
|
||||
Z: UsesState<State = S>,
|
||||
S: UsesInput + HasCurrentStage,
|
||||
S: UsesInput + HasCurrentStageId,
|
||||
{
|
||||
fn perform_all(
|
||||
&mut self,
|
||||
@ -161,7 +161,7 @@ where
|
||||
stage: &mut S,
|
||||
_: &mut EM,
|
||||
) -> Result<(), Error> {
|
||||
if stage.current_stage_idx()?.is_some() {
|
||||
if stage.current_stage_id()?.is_some() {
|
||||
Err(Error::illegal_state(
|
||||
"Got to the end of the tuple without completing resume.",
|
||||
))
|
||||
@ -178,7 +178,7 @@ where
|
||||
E: UsesState<State = Head::State>,
|
||||
EM: UsesState<State = Head::State> + EventProcessor<E, Z>,
|
||||
Z: UsesState<State = Head::State>,
|
||||
Head::State: HasCurrentStage,
|
||||
Head::State: HasCurrentStageId,
|
||||
{
|
||||
/// Performs all stages in the tuple,
|
||||
/// Checks after every stage if state wants to stop
|
||||
@ -190,7 +190,7 @@ where
|
||||
state: &mut Head::State,
|
||||
manager: &mut EM,
|
||||
) -> Result<(), Error> {
|
||||
match state.current_stage_idx()? {
|
||||
match state.current_stage_id()? {
|
||||
Some(idx) if idx < StageId(Self::LEN) => {
|
||||
// do nothing; we are resuming
|
||||
}
|
||||
@ -200,19 +200,19 @@ where
|
||||
|
||||
stage.perform_restartable(fuzzer, executor, state, manager)?;
|
||||
|
||||
state.clear_stage()?;
|
||||
state.clear_stage_id()?;
|
||||
}
|
||||
Some(idx) if idx > StageId(Self::LEN) => {
|
||||
unreachable!("We should clear the stage index before we get here...");
|
||||
}
|
||||
// this is None, but the match can't deduce that
|
||||
_ => {
|
||||
state.set_current_stage_idx(StageId(Self::LEN))?;
|
||||
state.set_current_stage_id(StageId(Self::LEN))?;
|
||||
|
||||
let stage = &mut self.0;
|
||||
stage.perform_restartable(fuzzer, executor, state, manager)?;
|
||||
|
||||
state.clear_stage()?;
|
||||
state.clear_stage_id()?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ where
|
||||
E: UsesState<State = Head::State>,
|
||||
EM: UsesState<State = Head::State>,
|
||||
Z: UsesState<State = Head::State>,
|
||||
Head::State: HasCurrentStage,
|
||||
Head::State: HasCurrentStageId,
|
||||
{
|
||||
fn into_vec_reversed(
|
||||
self,
|
||||
@ -286,7 +286,7 @@ where
|
||||
E: UsesState<State = S>,
|
||||
EM: UsesState<State = S> + EventProcessor<E, Z>,
|
||||
Z: UsesState<State = S>,
|
||||
S: UsesInput + HasCurrentStage + State,
|
||||
S: UsesInput + HasCurrentStageId + State,
|
||||
{
|
||||
/// Performs all stages in the `Vec`
|
||||
/// Checks after every stage if state wants to stop
|
||||
@ -592,15 +592,15 @@ impl fmt::Display for StageId {
|
||||
}
|
||||
|
||||
/// Trait for types which track the current stage
|
||||
pub trait HasCurrentStage {
|
||||
pub trait HasCurrentStageId {
|
||||
/// Set the current stage; we have started processing this stage
|
||||
fn set_current_stage_idx(&mut self, idx: StageId) -> Result<(), Error>;
|
||||
fn set_current_stage_id(&mut self, id: StageId) -> Result<(), Error>;
|
||||
|
||||
/// Clear the current stage; we are done processing this stage
|
||||
fn clear_stage(&mut self) -> Result<(), Error>;
|
||||
fn clear_stage_id(&mut self) -> Result<(), Error>;
|
||||
|
||||
/// Fetch the current stage -- typically used after a state recovery or transfer
|
||||
fn current_stage_idx(&self) -> Result<Option<StageId>, Error>;
|
||||
fn current_stage_id(&self) -> Result<Option<StageId>, Error>;
|
||||
|
||||
/// Notify of a reset from which we may recover
|
||||
fn on_restart(&mut self) -> Result<(), Error> {
|
||||
@ -610,7 +610,7 @@ pub trait HasCurrentStage {
|
||||
|
||||
/// Trait for types which track nested stages. Stages which themselves contain stage tuples should
|
||||
/// ensure that they constrain the state with this trait accordingly.
|
||||
pub trait HasNestedStageStatus: HasCurrentStage {
|
||||
pub trait HasNestedStageStatus: HasCurrentStageId {
|
||||
/// Enter a stage scope, potentially resuming to an inner stage status. Returns Ok(true) if
|
||||
/// resumed.
|
||||
fn enter_inner_stage(&mut self) -> Result<(), Error>;
|
||||
|
@ -37,7 +37,7 @@ use crate::{
|
||||
fuzzer::{Evaluator, ExecuteInputResult},
|
||||
generators::Generator,
|
||||
inputs::{Input, UsesInput},
|
||||
stages::{HasCurrentStage, HasNestedStageStatus, StageId},
|
||||
stages::{HasCurrentStageId, HasNestedStageStatus, StageId},
|
||||
Error, HasMetadata, HasNamedMetadata,
|
||||
};
|
||||
|
||||
@ -54,7 +54,7 @@ pub trait State:
|
||||
+ MaybeHasClientPerfMonitor
|
||||
+ MaybeHasScalabilityMonitor
|
||||
+ HasCurrentCorpusId
|
||||
+ HasCurrentStage
|
||||
+ HasCurrentStageId
|
||||
+ Stoppable
|
||||
{
|
||||
}
|
||||
@ -587,17 +587,17 @@ impl<I, C, R, SC> Stoppable for StdState<I, C, R, SC> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, C, R, SC> HasCurrentStage for StdState<I, C, R, SC> {
|
||||
fn set_current_stage_idx(&mut self, idx: StageId) -> Result<(), Error> {
|
||||
self.stage_stack.set_current_stage_idx(idx)
|
||||
impl<I, C, R, SC> HasCurrentStageId for StdState<I, C, R, SC> {
|
||||
fn set_current_stage_id(&mut self, idx: StageId) -> Result<(), Error> {
|
||||
self.stage_stack.set_current_stage_id(idx)
|
||||
}
|
||||
|
||||
fn clear_stage(&mut self) -> Result<(), Error> {
|
||||
self.stage_stack.clear_stage()
|
||||
fn clear_stage_id(&mut self) -> Result<(), Error> {
|
||||
self.stage_stack.clear_stage_id()
|
||||
}
|
||||
|
||||
fn current_stage_idx(&self) -> Result<Option<StageId>, Error> {
|
||||
self.stage_stack.current_stage_idx()
|
||||
fn current_stage_id(&self) -> Result<Option<StageId>, Error> {
|
||||
self.stage_stack.current_stage_id()
|
||||
}
|
||||
|
||||
fn on_restart(&mut self) -> Result<(), Error> {
|
||||
@ -1300,16 +1300,16 @@ impl<I> HasCurrentCorpusId for NopState<I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> HasCurrentStage for NopState<I> {
|
||||
fn set_current_stage_idx(&mut self, _idx: StageId) -> Result<(), Error> {
|
||||
impl<I> HasCurrentStageId for NopState<I> {
|
||||
fn set_current_stage_id(&mut self, _idx: StageId) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clear_stage(&mut self) -> Result<(), Error> {
|
||||
fn clear_stage_id(&mut self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn current_stage_idx(&self) -> Result<Option<StageId>, Error> {
|
||||
fn current_stage_id(&self) -> Result<Option<StageId>, Error> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use alloc::vec::Vec;
|
||||
use libafl_bolts::Error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::stages::{HasCurrentStage, HasNestedStageStatus, StageId};
|
||||
use crate::stages::{HasCurrentStageId, HasNestedStageStatus, StageId};
|
||||
|
||||
/// A stack to keep track of which stage is executing
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
@ -14,8 +14,8 @@ pub struct StageStack {
|
||||
stage_depth: usize,
|
||||
}
|
||||
|
||||
impl HasCurrentStage for StageStack {
|
||||
fn set_current_stage_idx(&mut self, idx: StageId) -> Result<(), Error> {
|
||||
impl HasCurrentStageId for StageStack {
|
||||
fn set_current_stage_id(&mut self, idx: StageId) -> Result<(), Error> {
|
||||
// ensure we are in the right frame
|
||||
if self.stage_depth != self.stage_idx_stack.len() {
|
||||
return Err(Error::illegal_state(
|
||||
@ -26,12 +26,12 @@ impl HasCurrentStage for StageStack {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clear_stage(&mut self) -> Result<(), Error> {
|
||||
fn clear_stage_id(&mut self) -> Result<(), Error> {
|
||||
self.stage_idx_stack.truncate(self.stage_depth);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn current_stage_idx(&self) -> Result<Option<StageId>, Error> {
|
||||
fn current_stage_id(&self) -> Result<Option<StageId>, Error> {
|
||||
Ok(self.stage_idx_stack.get(self.stage_depth).copied())
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ use libafl::{
|
||||
executors::ExitKind,
|
||||
inputs::UsesInput,
|
||||
monitors::{tui::TuiMonitor, Monitor, MultiMonitor},
|
||||
stages::{HasCurrentStage, StagesTuple},
|
||||
stages::{HasCurrentStageId, StagesTuple},
|
||||
state::{HasExecutions, HasLastReportTime, HasSolutions, Stoppable, UsesState},
|
||||
Error, Fuzzer, HasMetadata,
|
||||
};
|
||||
@ -68,7 +68,7 @@ where
|
||||
+ UsesInput
|
||||
+ HasSolutions
|
||||
+ HasLastReportTime
|
||||
+ HasCurrentStage
|
||||
+ HasCurrentStageId
|
||||
+ Stoppable,
|
||||
E: UsesState<State = S>,
|
||||
EM: ProgressReporter<State = S> + EventProcessor<E, F>,
|
||||
|
@ -6,7 +6,7 @@ use libafl::{
|
||||
feedbacks::MapFeedbackMetadata,
|
||||
inputs::UsesInput,
|
||||
monitors::SimpleMonitor,
|
||||
stages::{HasCurrentStage, StagesTuple},
|
||||
stages::{HasCurrentStageId, StagesTuple},
|
||||
state::{HasExecutions, HasLastReportTime, Stoppable},
|
||||
Error, Fuzzer, HasMetadata, HasNamedMetadata,
|
||||
};
|
||||
@ -29,7 +29,7 @@ where
|
||||
+ HasExecutions
|
||||
+ UsesInput
|
||||
+ HasLastReportTime
|
||||
+ HasCurrentStage
|
||||
+ HasCurrentStageId
|
||||
+ Stoppable,
|
||||
E: HasObservers<State = S>,
|
||||
EM: ProgressReporter<State = S> + EventProcessor<E, F>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user