Rename Reference to Handle (#2142)

* rename

* rename

* fmt

* fix

* fmt
This commit is contained in:
Dongjia "toka" Zhang 2024-05-04 18:16:28 +02:00 committed by GitHub
parent 41ff7438eb
commit b0ac25a7b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 154 additions and 155 deletions

View File

@ -21,7 +21,7 @@ use libafl::{
use libafl_bolts::{
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, MatchNameRef, Merge, Referenceable},
tuples::{tuple_list, Handler, MatchNameRef, Merge},
AsSliceMut, Truncate,
};
use libafl_targets::EDGES_MAP_SIZE_IN_USE;
@ -166,7 +166,7 @@ pub fn main() {
// Create the executor for the forkserver
let args = opt.arguments;
let observer_ref = edges_observer.reference();
let observer_ref = edges_observer.handle();
let mut tokens = Tokens::new();
let mut executor = ForkserverExecutor::builder()

View File

@ -22,7 +22,7 @@ use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
tuples::{tuple_list, Handler, Merge},
AsSliceMut, Truncate,
};
use nix::sys::signal::Signal;
@ -163,7 +163,7 @@ pub fn main() {
// Create the executor for the forkserver
let args = opt.arguments;
let observer_ref = edges_observer.reference();
let observer_ref = edges_observer.handle();
let mut tokens = Tokens::new();
let mut executor = ForkserverExecutor::builder()

View File

@ -37,7 +37,7 @@ use libafl_bolts::{
ownedref::OwnedRefMut,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
tuples::{tuple_list, Handler, Merge},
AsSliceMut,
};
use libafl_targets::{
@ -355,7 +355,7 @@ fn fuzz(
let cmpmap = unsafe { OwnedRefMut::from_shmem(&mut cmplog_shmem) };
let cmplog_observer = AFLppCmpLogObserver::new("cmplog", cmpmap, true);
let cmplog_ref = cmplog_observer.reference();
let cmplog_ref = cmplog_observer.handle();
let cmplog_executor = ForkserverExecutor::builder()
.program(exec)

View File

@ -42,7 +42,7 @@ use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Referenceable},
tuples::{tuple_list, Handler},
AsSlice, AsSliceMut,
};
use libafl_targets::{
@ -207,7 +207,7 @@ fn fuzz(
// The concolic observer observers the concolic shared memory map.
let concolic_observer = ConcolicObserver::new("concolic", concolic_shmem.as_slice_mut());
let concolic_ref = concolic_observer.reference();
let concolic_ref = concolic_observer.handle();
// The order of the stages matter!
let mut stages = tuple_list!(

View File

@ -7,7 +7,7 @@ use core::{hash::Hash, marker::PhantomData};
use hashbrown::{HashMap, HashSet};
use libafl_bolts::{
current_time,
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
AsIter, Named,
};
use num_traits::ToPrimitive;
@ -51,7 +51,7 @@ where
/// Algorithm based on WMOPT: <https://hexhive.epfl.ch/publications/files/21ISSTA2.pdf>
#[derive(Debug)]
pub struct MapCorpusMinimizer<C, E, O, T, TS> {
obs_ref: Reference<C>,
obs_ref: Handle<C>,
phantom: PhantomData<(E, O, T, TS)>,
}
@ -70,7 +70,7 @@ where
/// in the future to get observed maps from an executed input.
pub fn new(obs: &C) -> Self {
Self {
obs_ref: obs.reference(),
obs_ref: obs.handle(),
phantom: PhantomData,
}
}

View File

@ -11,7 +11,7 @@ use alloc::{boxed::Box, string::String, vec::Vec};
use core::{marker::PhantomData, num::NonZeroUsize, time::Duration};
#[cfg(feature = "adaptive_serialization")]
use libafl_bolts::tuples::{Reference, Referenceable};
use libafl_bolts::tuples::{Handle, Handler};
#[cfg(feature = "llmp_compression")]
use libafl_bolts::{
compress::GzipCompressor,
@ -226,7 +226,7 @@ where
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor,
#[cfg(feature = "adaptive_serialization")]
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
is_main: bool,
}
@ -270,7 +270,7 @@ where
self.inner.should_serialize_cnt_mut()
}
fn time_ref(&self) -> &Reference<TimeObserver> {
fn time_ref(&self) -> &Handle<TimeObserver> {
&self.time_ref
}
}
@ -493,7 +493,7 @@ where
client,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
time_ref: time_obs.reference(),
time_ref: time_obs.handle(),
is_main,
})
}
@ -532,7 +532,7 @@ where
client,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
time_ref: time_obs.reference(),
time_ref: time_obs.handle(),
is_main,
})
}
@ -570,7 +570,7 @@ where
client: LlmpClient::on_existing_from_env(shmem_provider, env_name)?,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
time_ref: time_obs.reference(),
time_ref: time_obs.handle(),
is_main,
})
}
@ -606,7 +606,7 @@ where
client: LlmpClient::existing_client_from_description(shmem_provider, description)?,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
time_ref: time_obs.reference(),
time_ref: time_obs.handle(),
is_main,
})
}

View File

@ -33,7 +33,7 @@ use libafl_bolts::os::dup2;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use libafl_bolts::os::startable_self;
#[cfg(feature = "adaptive_serialization")]
use libafl_bolts::tuples::{Reference, Referenceable};
use libafl_bolts::tuples::{Handle, Handler};
#[cfg(all(unix, feature = "std", feature = "fork"))]
use libafl_bolts::{
core_affinity::get_core_ids,
@ -125,7 +125,7 @@ where
#[builder(default = None)]
remote_broker_addr: Option<SocketAddr>,
#[cfg(feature = "adaptive_serialization")]
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
/// If this launcher should spawn a new `broker` on `[Self::broker_port]` (default).
/// The reason you may not want this is, if you already have a [`Launcher`]
/// with a different configuration (for the same target) running on this machine.
@ -683,7 +683,7 @@ where
.serialize_state(self.serialize_state)
.hooks(tuple_list!());
#[cfg(feature = "adaptive_serialization")]
let builder = builder.time_ref(self.time_obs.reference());
let builder = builder.time_ref(self.time_obs.handle());
let (state, mgr) = builder.build().launch()?;
#[cfg(not(feature = "adaptive_serialization"))]
@ -727,7 +727,7 @@ where
.hooks(tuple_list!());
#[cfg(feature = "adaptive_serialization")]
let builder = builder.time_ref(self.time_obs.reference());
let builder = builder.time_ref(self.time_obs.handle());
builder.build().launch()?;

View File

@ -33,7 +33,7 @@ use libafl_bolts::{
#[cfg(feature = "adaptive_serialization")]
use libafl_bolts::{
current_time,
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
};
#[cfg(feature = "std")]
use libafl_bolts::{llmp::LlmpConnection, shmem::StdShMemProvider, staterestore::StateRestorer};
@ -367,7 +367,7 @@ where
#[cfg(feature = "adaptive_serialization")]
should_serialize_cnt: usize,
#[cfg(feature = "adaptive_serialization")]
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
phantom: PhantomData<S>,
}
@ -403,7 +403,7 @@ where
&mut self.should_serialize_cnt
}
fn time_ref(&self) -> &Reference<TimeObserver> {
fn time_ref(&self) -> &Handle<TimeObserver> {
&self.time_ref
}
}
@ -498,7 +498,7 @@ where
pub fn new(
llmp: LlmpClient<SP>,
configuration: EventConfig,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<Self, Error> {
Ok(LlmpEventManager {
hooks: tuple_list!(),
@ -525,7 +525,7 @@ where
shmem_provider: SP,
port: u16,
configuration: EventConfig,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<LlmpEventManager<(), S, SP>, Error> {
let llmp = LlmpClient::create_attach_to_tcp(shmem_provider, port)?;
Self::new(llmp, configuration, time_ref)
@ -538,7 +538,7 @@ where
shmem_provider: SP,
env_name: &str,
configuration: EventConfig,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<LlmpEventManager<(), S, SP>, Error> {
let llmp = LlmpClient::on_existing_from_env(shmem_provider, env_name)?;
Self::new(llmp, configuration, time_ref)
@ -550,7 +550,7 @@ where
shmem_provider: SP,
description: &LlmpClientDescription,
configuration: EventConfig,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<LlmpEventManager<(), S, SP>, Error> {
let llmp = LlmpClient::existing_client_from_description(shmem_provider, description)?;
Self::new(llmp, configuration, time_ref)
@ -628,7 +628,7 @@ where
llmp: LlmpClient<SP>,
configuration: EventConfig,
hooks: EMH,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<Self, Error> {
Ok(Self {
hooks,
@ -657,7 +657,7 @@ where
port: u16,
configuration: EventConfig,
hooks: EMH,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<Self, Error> {
let llmp = LlmpClient::create_attach_to_tcp(shmem_provider, port)?;
Self::with_hooks(llmp, configuration, hooks, time_ref)
@ -672,7 +672,7 @@ where
env_name: &str,
configuration: EventConfig,
hooks: EMH,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<Self, Error> {
let llmp = LlmpClient::on_existing_from_env(shmem_provider, env_name)?;
Self::with_hooks(llmp, configuration, hooks, time_ref)
@ -685,7 +685,7 @@ where
description: &LlmpClientDescription,
configuration: EventConfig,
hooks: EMH,
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
) -> Result<Self, Error> {
let llmp = LlmpClient::existing_client_from_description(shmem_provider, description)?;
Self::with_hooks(llmp, configuration, hooks, time_ref)
@ -1091,7 +1091,7 @@ where
self.llmp_mgr.should_serialize_cnt_mut()
}
fn time_ref(&self) -> &Reference<TimeObserver> {
fn time_ref(&self) -> &Handle<TimeObserver> {
&self.llmp_mgr.time_ref
}
}
@ -1362,7 +1362,7 @@ where
.broker_port(broker_port)
.configuration(configuration)
.hooks(tuple_list!())
.time_ref(time_obs.reference())
.time_ref(time_obs.handle())
.build()
.launch()
}
@ -1412,7 +1412,7 @@ where
/// The hooks passed to event manager:
hooks: EMH,
#[cfg(feature = "adaptive_serialization")]
time_ref: Reference<TimeObserver>,
time_ref: Handle<TimeObserver>,
#[builder(setter(skip), default = PhantomData)]
phantom_data: PhantomData<(EMH, S)>,
}
@ -2058,7 +2058,7 @@ mod tests {
use core::sync::atomic::{compiler_fence, Ordering};
#[cfg(feature = "adaptive_serialization")]
use libafl_bolts::tuples::Referenceable;
use libafl_bolts::tuples::Handler;
use libafl_bolts::{
llmp::{LlmpClient, LlmpSharedMap},
rands::StdRand,
@ -2092,7 +2092,7 @@ mod tests {
let time = TimeObserver::new("time");
#[cfg(feature = "adaptive_serialization")]
let time_ref = time.reference();
let time_ref = time.handle();
let mut corpus = InMemoryCorpus::<BytesInput>::new();
let testcase = Testcase::new(vec![0; 4].into());

View File

@ -33,7 +33,7 @@ pub use launcher::*;
#[cfg(all(unix, feature = "std"))]
use libafl_bolts::os::unix_signals::{siginfo_t, ucontext_t, Handler, Signal};
#[cfg(feature = "adaptive_serialization")]
use libafl_bolts::tuples::{MatchNameRef, Reference};
use libafl_bolts::tuples::{Handle, MatchNameRef};
use libafl_bolts::{current_time, ClientId};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
@ -859,8 +859,8 @@ pub trait AdaptiveSerializer {
/// How many times shoukd have been serialized an observer (mut)
fn should_serialize_cnt_mut(&mut self) -> &mut usize;
/// A [`Reference`] to the time observer to determine the `time_factor`
fn time_ref(&self) -> &Reference<TimeObserver>;
/// A [`Handle`] to the time observer to determine the `time_factor`
fn time_ref(&self) -> &Handle<TimeObserver>;
/// Serialize the observer using the `time_factor` and `percentage_threshold`.
/// These parameters are unique to each of the different types of `EventManager`

View File

@ -22,7 +22,7 @@ use libafl_bolts::{
fs::{get_unique_std_input_file, InputFile},
os::{dup2, pipes::Pipe},
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{MatchNameRef, Prepend, RefIndexable, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef, Prepend, RefIndexable},
AsSlice, AsSliceMut, Truncate,
};
use nix::{
@ -498,7 +498,7 @@ where
phantom: PhantomData<S>,
map_size: Option<usize>,
#[cfg(feature = "regex")]
asan_obs: Reference<AsanBacktraceObserver>,
asan_obs: Handle<AsanBacktraceObserver>,
timeout: TimeSpec,
crash_exitcode: Option<i8>,
}
@ -587,7 +587,7 @@ pub struct ForkserverExecutorBuilder<'a, SP> {
kill_signal: Option<Signal>,
timeout: Option<Duration>,
#[cfg(feature = "regex")]
asan_obs: Option<Reference<AsanBacktraceObserver>>,
asan_obs: Option<Handle<AsanBacktraceObserver>>,
crash_exitcode: Option<i8>,
}
@ -640,7 +640,7 @@ impl<'a, SP> ForkserverExecutorBuilder<'a, SP> {
asan_obs: self
.asan_obs
.clone()
.unwrap_or(AsanBacktraceObserver::default().reference()),
.unwrap_or(AsanBacktraceObserver::default().handle()),
crash_exitcode: self.crash_exitcode,
})
}
@ -702,7 +702,7 @@ impl<'a, SP> ForkserverExecutorBuilder<'a, SP> {
asan_obs: self
.asan_obs
.clone()
.unwrap_or(AsanBacktraceObserver::default().reference()),
.unwrap_or(AsanBacktraceObserver::default().handle()),
crash_exitcode: self.crash_exitcode,
})
}

View File

@ -7,7 +7,7 @@ use alloc::borrow::Cow;
use core::{fmt::Debug, marker::PhantomData};
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Named,
};
@ -28,7 +28,7 @@ use crate::{
/// Requires a [`ConcolicObserver`] to observe the concolic trace.
#[derive(Debug)]
pub struct ConcolicFeedback<'map, S> {
obs_ref: Reference<ConcolicObserver<'map>>,
obs_ref: Handle<ConcolicObserver<'map>>,
phantom: PhantomData<S>,
}
@ -38,7 +38,7 @@ impl<'map, S> ConcolicFeedback<'map, S> {
#[must_use]
pub fn from_observer(observer: &ConcolicObserver<'map>) -> Self {
Self {
obs_ref: observer.reference(),
obs_ref: observer.handle(),
phantom: PhantomData,
}
}

View File

@ -8,7 +8,7 @@ use core::{
};
use libafl_bolts::{
tuples::{MatchName, MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchName, MatchNameRef},
Named,
};
use serde::{Deserialize, Serialize};
@ -58,9 +58,9 @@ where
/// This feedback's name
name: Cow<'static, str>,
/// The first observer to compare against
o1_ref: Reference<O1>,
o1_ref: Handle<O1>,
/// The second observer to compare against
o2_ref: Reference<O2>,
o2_ref: Handle<O2>,
/// The function used to compare the two observers
compare_fn: F,
phantomm: PhantomData<(I, S)>,
@ -74,8 +74,8 @@ where
{
/// Create a new [`DiffFeedback`] using two observers and a test function.
pub fn new(name: &'static str, o1: &O1, o2: &O2, compare_fn: F) -> Result<Self, Error> {
let o1_ref = o1.reference();
let o2_ref = o2.reference();
let o1_ref = o1.handle();
let o2_ref = o2.handle();
if o1_ref.name() == o2_ref.name() {
Err(Error::illegal_argument(format!(
"DiffFeedback: observer names must be different (both were {})",

View File

@ -3,7 +3,7 @@ use core::{fmt::Debug, hash::Hash};
use hashbrown::HashSet;
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Error, HasRefCnt, Named,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -73,7 +73,7 @@ pub struct ListFeedback<T>
where
T: Hash + Eq,
{
obs_ref: Reference<ListObserver<T>>,
obs_ref: Handle<ListObserver<T>>,
novelty: HashSet<T>,
}
@ -163,7 +163,7 @@ where
#[must_use]
pub fn new(observer: &ListObserver<T>) -> Self {
Self {
obs_ref: observer.reference(),
obs_ref: observer.handle(),
novelty: HashSet::<T>::new(),
}
}

View File

@ -12,7 +12,7 @@ use core::{
#[rustversion::nightly]
use libafl_bolts::AsSlice;
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
AsIter, HasRefCnt, Named,
};
use num_traits::PrimInt;
@ -388,7 +388,7 @@ pub struct MapFeedback<C, N, O, R, T> {
/// Name identifier of this instance
name: Cow<'static, str>,
/// Name identifier of the observer
map_ref: Reference<C>,
map_ref: Handle<C>,
/// Name of the feedback as shown in the `UserStats`
stats_name: Cow<'static, str>,
/// Phantom Data of Reducer
@ -668,7 +668,7 @@ where
type Observer = C;
#[inline]
fn observer_ref(&self) -> &Reference<C> {
fn observer_ref(&self) -> &Handle<C> {
&self.map_ref
}
}
@ -697,7 +697,7 @@ where
Self {
novelties: if C::NOVELTIES { Some(vec![]) } else { None },
name: map_observer.name().clone(),
map_ref: map_observer.reference(),
map_ref: map_observer.handle(),
stats_name: create_stats_name(map_observer.name()),
phantom: PhantomData,
}
@ -711,7 +711,7 @@ where
let name = Cow::from(name);
Self {
novelties: if C::NOVELTIES { Some(vec![]) } else { None },
map_ref: map_observer.reference(),
map_ref: map_observer.handle(),
stats_name: create_stats_name(&name),
name,
phantom: PhantomData,

View File

@ -14,7 +14,7 @@ use core::{
pub use concolic::ConcolicFeedback;
pub use differential::DiffFeedback;
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Named,
};
pub use list::*;
@ -143,7 +143,7 @@ pub trait HasObserverReference {
type Observer: ?Sized;
/// The name associated with the observer
fn observer_ref(&self) -> &Reference<Self::Observer>;
fn observer_ref(&self) -> &Handle<Self::Observer>;
}
/// A combined feedback consisting of multiple [`Feedback`]s
@ -934,7 +934,7 @@ pub type TimeoutFeedbackFactory = DefaultFeedbackFactory<TimeoutFeedback>;
/// It decides, if the given [`TimeObserver`] value of a run is interesting.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct TimeFeedback {
obs_ref: Reference<TimeObserver>,
obs_ref: Handle<TimeObserver>,
}
impl<S> Feedback<S> for TimeFeedback
@ -995,7 +995,7 @@ impl TimeFeedback {
#[must_use]
pub fn new(observer: &TimeObserver) -> Self {
Self {
obs_ref: observer.reference(),
obs_ref: observer.handle(),
}
}
}

View File

@ -5,7 +5,7 @@ use std::{fmt::Debug, marker::PhantomData};
use hashbrown::HashSet;
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Named,
};
use serde::{Deserialize, Serialize};
@ -82,7 +82,7 @@ impl HashSetState<u64> for NewHashFeedbackMetadata {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct NewHashFeedback<O, S> {
name: Cow<'static, str>,
o_ref: Reference<O>,
o_ref: Handle<O>,
/// Initial capacity of hash set
capacity: usize,
phantom: PhantomData<S>,
@ -149,7 +149,7 @@ impl<O, S> HasObserverReference for NewHashFeedback<O, S> {
type Observer = O;
#[inline]
fn observer_ref(&self) -> &Reference<O> {
fn observer_ref(&self) -> &Handle<O> {
&self.o_ref
}
}
@ -176,7 +176,7 @@ where
pub fn with_capacity(observer: &O, capacity: usize) -> Self {
Self {
name: Cow::from(NEWHASHFEEDBACK_PREFIX.to_string() + observer.name()),
o_ref: observer.reference(),
o_ref: observer.handle(),
capacity,
phantom: PhantomData,
}

View File

@ -4,7 +4,7 @@ use alloc::{borrow::Cow, string::String};
use libafl_bolts::{
impl_serdeany,
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Named,
};
use serde::{Deserialize, Serialize};
@ -32,7 +32,7 @@ impl_serdeany!(StdOutMetadata);
/// is never interesting (use with an OR).
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct StdOutToMetadataFeedback {
o_ref: Reference<StdOutObserver>,
o_ref: Handle<StdOutObserver>,
}
impl<S> Feedback<S> for StdOutToMetadataFeedback
@ -104,7 +104,7 @@ impl StdOutToMetadataFeedback {
#[must_use]
pub fn new(observer: &StdOutObserver) -> Self {
Self {
o_ref: observer.reference(),
o_ref: observer.handle(),
}
}
}
@ -122,7 +122,7 @@ impl_serdeany!(StdErrMetadata);
/// is never interesting (use with an OR).
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct StdErrToMetadataFeedback {
o_ref: Reference<StdErrObserver>,
o_ref: Handle<StdErrObserver>,
}
impl<S> Feedback<S> for StdErrToMetadataFeedback
@ -194,7 +194,7 @@ impl StdErrToMetadataFeedback {
#[must_use]
pub fn new(observer: &StdErrObserver) -> Self {
Self {
o_ref: observer.reference(),
o_ref: observer.handle(),
}
}
}

View File

@ -390,7 +390,7 @@ where
}
}
/// Reference the stored auxiliary data associated with the [`CmpObserverMetadata`]
/// Handle the stored auxiliary data associated with the [`CmpObserverMetadata`]
pub fn data(&self) -> &M::Data {
&self.data
}

View File

@ -29,7 +29,7 @@ pub use weighted::{StdWeightedScheduler, WeightedScheduler};
pub mod tuneable;
use libafl_bolts::{
rands::Rand,
tuples::{MatchNameRef, Reference},
tuples::{Handle, MatchNameRef},
};
pub use tuneable::*;
@ -82,7 +82,7 @@ where
fn set_last_hash(&mut self, value: usize);
/// Get the observer map observer name
fn map_observer_ref(&self) -> &Reference<C>;
fn map_observer_ref(&self) -> &Handle<C>;
/// Called when a [`Testcase`] is added to the corpus
fn on_add_metadata(&self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {

View File

@ -4,7 +4,7 @@ use alloc::vec::Vec;
use core::{marker::PhantomData, time::Duration};
use libafl_bolts::{
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
Named,
};
use serde::{Deserialize, Serialize};
@ -173,7 +173,7 @@ pub enum PowerSchedule {
#[derive(Clone, Debug)]
pub struct PowerQueueScheduler<C, O, S> {
strat: PowerSchedule,
map_observer_ref: Reference<C>,
map_observer_ref: Handle<C>,
last_hash: usize,
phantom: PhantomData<(O, S)>,
}
@ -226,7 +226,7 @@ where
self.last_hash = hash;
}
fn map_observer_ref(&self) -> &Reference<C> {
fn map_observer_ref(&self) -> &Handle<C> {
&self.map_observer_ref
}
}
@ -305,7 +305,7 @@ where
}
PowerQueueScheduler {
strat,
map_observer_ref: map_observer.reference(),
map_observer_ref: map_observer.handle(),
last_hash: 0,
phantom: PhantomData,
}

View File

@ -6,7 +6,7 @@ use core::marker::PhantomData;
use hashbrown::HashMap;
use libafl_bolts::{
rands::Rand,
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
Named,
};
use serde::{Deserialize, Serialize};
@ -98,7 +98,7 @@ libafl_bolts::impl_serdeany!(WeightedScheduleMetadata);
pub struct WeightedScheduler<C, F, O, S> {
table_invalidated: bool,
strat: Option<PowerSchedule>,
map_observer_ref: Reference<C>,
map_observer_ref: Handle<C>,
last_hash: usize,
phantom: PhantomData<(F, O, S)>,
}
@ -124,7 +124,7 @@ where
Self {
strat,
map_observer_ref: map_observer.reference(),
map_observer_ref: map_observer.handle(),
last_hash: 0,
table_invalidated: true,
phantom: PhantomData,
@ -274,7 +274,7 @@ where
self.last_hash = hash;
}
fn map_observer_ref(&self) -> &Reference<C> {
fn map_observer_ref(&self) -> &Handle<C> {
&self.map_observer_ref
}
}

View File

@ -4,7 +4,7 @@ use alloc::{borrow::Cow, vec::Vec};
use core::{fmt::Debug, marker::PhantomData, time::Duration};
use hashbrown::HashSet;
use libafl_bolts::{current_time, impl_serdeany, tuples::Reference, AsIter, Named};
use libafl_bolts::{current_time, impl_serdeany, tuples::Handle, AsIter, Named};
use num_traits::Bounded;
use serde::{Deserialize, Serialize};
@ -63,7 +63,7 @@ impl UnstableEntriesMetadata {
/// The calibration stage will measure the average exec time and the target's stability for this input.
#[derive(Clone, Debug)]
pub struct CalibrationStage<C, O, OT, S> {
map_observer_ref: Reference<C>,
map_observer_ref: Handle<C>,
map_name: Cow<'static, str>,
stage_max: usize,
/// If we should track stability

View File

@ -4,7 +4,7 @@ use core::{cmp::Ordering, fmt::Debug, marker::PhantomData, ops::Range};
use libafl_bolts::{
rands::Rand,
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
Named,
};
use serde::{Deserialize, Serialize};
@ -55,7 +55,7 @@ impl Ord for Earlier {
/// The mutational stage using power schedules
#[derive(Clone, Debug)]
pub struct ColorizationStage<C, E, EM, O, Z> {
map_observer_ref: Reference<C>,
map_observer_ref: Handle<C>,
#[allow(clippy::type_complexity)]
phantom: PhantomData<(E, EM, O, E, Z)>,
}
@ -168,7 +168,7 @@ where
executor: &mut E,
state: &mut E::State,
manager: &mut EM,
obs_ref: &Reference<C>,
obs_ref: &Handle<C>,
) -> Result<E::Input, Error> {
let mut input = state.current_input_cloned()?;
// The backup of the input
@ -301,7 +301,7 @@ where
/// Creates a new [`ColorizationStage`]
pub fn new(map_observer: &C) -> Self {
Self {
map_observer_ref: map_observer.reference(),
map_observer_ref: map_observer.handle(),
phantom: PhantomData,
}
}
@ -313,7 +313,7 @@ where
state: &mut E::State,
manager: &mut EM,
input: E::Input,
obs_ref: &Reference<C>,
obs_ref: &Handle<C>,
) -> Result<usize, Error> {
executor.observers_mut().pre_exec_all(state, &input)?;

View File

@ -9,7 +9,7 @@ use alloc::{string::ToString, vec::Vec};
use core::marker::PhantomData;
use libafl_bolts::{
tuples::{MatchNameRef, Reference},
tuples::{Handle, MatchNameRef},
Named,
};
@ -39,7 +39,7 @@ use crate::{
#[derive(Clone, Debug)]
pub struct ConcolicTracingStage<'a, EM, TE, Z> {
inner: TracingStage<EM, TE, Z>,
obs_ref: Reference<ConcolicObserver<'a>>,
obs_ref: Handle<ConcolicObserver<'a>>,
}
impl<EM, TE, Z> UsesState for ConcolicTracingStage<'_, EM, TE, Z>
@ -95,7 +95,7 @@ where
impl<'a, EM, TE, Z> ConcolicTracingStage<'a, EM, TE, Z> {
/// Creates a new default tracing stage using the given [`Executor`], observing traces from a
/// [`ConcolicObserver`] with the given name.
pub fn new(inner: TracingStage<EM, TE, Z>, obs_ref: Reference<ConcolicObserver<'a>>) -> Self {
pub fn new(inner: TracingStage<EM, TE, Z>, obs_ref: Handle<ConcolicObserver<'a>>) -> Self {
Self { inner, obs_ref }
}
}

View File

@ -4,7 +4,7 @@ use alloc::{borrow::Cow, vec::Vec};
use core::{fmt::Debug, marker::PhantomData};
use libafl_bolts::{
tuples::{Reference, Referenceable},
tuples::{Handle, Handler},
AsSlice, Named,
};
@ -43,7 +43,7 @@ fn find_next_char(list: &[Option<u8>], mut idx: usize, ch: u8) -> usize {
/// A stage that runs a tracer executor
#[derive(Clone, Debug)]
pub struct GeneralizationStage<C, EM, O, OT, Z> {
map_observer_ref: Reference<C>,
map_observer_ref: Handle<C>,
#[allow(clippy::type_complexity)]
phantom: PhantomData<(EM, O, OT, Z)>,
}
@ -347,7 +347,7 @@ where
pub fn new(map_observer: &C) -> Self {
require_novelties_tracking!("GeneralizationStage", C);
Self {
map_observer_ref: map_observer.reference(),
map_observer_ref: map_observer.handle(),
phantom: PhantomData,
}
}

View File

@ -5,7 +5,7 @@ use core::{borrow::BorrowMut, fmt::Debug, hash::Hash, marker::PhantomData};
use ahash::RandomState;
use libafl_bolts::{
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
HasLen, Named,
};
@ -353,7 +353,7 @@ where
#[derive(Clone, Debug)]
pub struct MapEqualityFeedback<C, M, S> {
name: Cow<'static, str>,
map_ref: Reference<C>,
map_ref: Handle<C>,
orig_hash: u64,
phantom: PhantomData<(M, S)>,
}
@ -367,7 +367,7 @@ impl<C, M, S> Named for MapEqualityFeedback<C, M, S> {
impl<C, M, S> HasObserverReference for MapEqualityFeedback<C, M, S> {
type Observer = C;
fn observer_ref(&self) -> &Reference<Self::Observer> {
fn observer_ref(&self) -> &Handle<Self::Observer> {
&self.map_ref
}
}
@ -400,19 +400,19 @@ where
/// A feedback factory for ensuring that the maps for minimized inputs are the same
#[derive(Debug, Clone)]
pub struct MapEqualityFactory<C, M, S> {
map_ref: Reference<C>,
map_ref: Handle<C>,
phantom: PhantomData<(C, M, S)>,
}
impl<C, M, S> MapEqualityFactory<C, M, S>
where
M: MapObserver,
C: AsRef<M> + Referenceable,
C: AsRef<M> + Handler,
{
/// Creates a new map equality feedback for the given observer
pub fn new(obs: &C) -> Self {
Self {
map_ref: obs.reference(),
map_ref: obs.handle(),
phantom: PhantomData,
}
}
@ -421,7 +421,7 @@ where
impl<C, M, S> HasObserverReference for MapEqualityFactory<C, M, S> {
type Observer = C;
fn observer_ref(&self) -> &Reference<C> {
fn observer_ref(&self) -> &Handle<C> {
&self.map_ref
}
}
@ -430,7 +430,7 @@ impl<C, M, OT, S> FeedbackFactory<MapEqualityFeedback<C, M, S>, S, OT>
for MapEqualityFactory<C, M, S>
where
M: MapObserver,
C: AsRef<M> + Referenceable,
C: AsRef<M> + Handler,
OT: ObserversTuple<S>,
S: State + Debug,
{
@ -440,7 +440,7 @@ where
.expect("Should have been provided valid observer name.");
MapEqualityFeedback {
name: Cow::from("MapEq"),
map_ref: obs.reference(),
map_ref: obs.handle(),
orig_hash: obs.as_ref().hash_simple(),
phantom: PhantomData,
}

View File

@ -318,7 +318,7 @@ pub trait ShMemProvider: Clone + Default + Debug {
}
}
/// A Reference Counted shared map,
/// A Handle Counted shared map,
/// that can use internal mutability.
/// Useful if the `ShMemProvider` needs to keep local state.
#[cfg(feature = "alloc")]
@ -367,7 +367,7 @@ impl<T: ShMemProvider> Drop for RcShMem<T> {
}
}
/// A Reference Counted `ShMemProvider`,
/// A Handle Counted `ShMemProvider`,
/// that can use internal mutability.
/// Useful if the `ShMemProvider` needs to keep local state.
#[derive(Debug, Clone)]

View File

@ -501,13 +501,13 @@ where
}
}
/// Structs that has `Reference `
/// Structs that has `Handle `
/// You should use this when you want to avoid specifying types using `match_name_type_mut`
#[cfg(feature = "alloc")]
pub trait Referenceable: Named {
/// Return the `Reference `
fn reference(&self) -> Reference<Self> {
Reference {
pub trait Handler: Named {
/// Return the `Handle `
fn handle(&self) -> Handle<Self> {
Handle {
name: Named::name(self).clone(),
phantom: PhantomData,
}
@ -515,23 +515,23 @@ pub trait Referenceable: Named {
}
#[cfg(feature = "alloc")]
impl<N> Referenceable for N where N: Named {}
impl<N> Handler for N where N: Named {}
/// Object with the type T and the name associated with its concrete value
#[derive(Serialize, Deserialize)]
#[cfg(feature = "alloc")]
pub struct Reference<T: ?Sized> {
pub struct Handle<T: ?Sized> {
name: Cow<'static, str>,
#[serde(skip)]
phantom: PhantomData<T>,
}
#[cfg(feature = "alloc")]
impl<T: ?Sized> Reference<T> {
impl<T: ?Sized> Handle<T> {
/// Fetch the name of the referenced instance.
///
/// We explicitly do *not* implement [`Named`], as this could potentially lead to confusion
/// where we make a [`Reference`] of a [`Reference`] as [`Named`] is blanket implemented.
/// where we make a [`Handle`] of a [`Handle`] as [`Named`] is blanket implemented.
#[must_use]
pub fn name(&self) -> &Cow<'static, str> {
&self.name
@ -539,7 +539,7 @@ impl<T: ?Sized> Reference<T> {
}
#[cfg(feature = "alloc")]
impl<T> Clone for Reference<T> {
impl<T> Clone for Handle<T> {
fn clone(&self) -> Self {
Self {
name: self.name.clone(),
@ -549,23 +549,23 @@ impl<T> Clone for Reference<T> {
}
#[cfg(feature = "alloc")]
impl<T> Debug for Reference<T> {
impl<T> Debug for Handle<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Reference")
f.debug_struct("Handle")
.field("name", self.name())
.field("type", &type_name::<T>())
.finish()
}
}
/// Search using `Reference `
/// Search using `Handle `
#[cfg(feature = "alloc")]
pub trait MatchNameRef {
/// Search using name and `Reference `
fn get<T>(&self, rf: &Reference<T>) -> Option<&T>;
/// Search using name and `Handle `
fn get<T>(&self, rf: &Handle<T>) -> Option<&T>;
/// Search using name and `Reference `
fn get_mut<T>(&mut self, rf: &Reference<T>) -> Option<&mut T>;
/// Search using name and `Handle `
fn get_mut<T>(&mut self, rf: &Handle<T>) -> Option<&mut T>;
}
#[cfg(feature = "alloc")]
@ -574,11 +574,11 @@ impl<M> MatchNameRef for M
where
M: MatchName,
{
fn get<T>(&self, rf: &Reference<T>) -> Option<&T> {
fn get<T>(&self, rf: &Handle<T>) -> Option<&T> {
self.match_name::<T>(&rf.name)
}
fn get_mut<T>(&mut self, rf: &Reference<T>) -> Option<&mut T> {
fn get_mut<T>(&mut self, rf: &Handle<T>) -> Option<&mut T> {
self.match_name_mut::<T>(&rf.name)
}
}
@ -623,14 +623,14 @@ where
}
#[cfg(feature = "alloc")]
impl<T, RM, M> Index<&Reference<T>> for RefIndexable<RM, M>
impl<T, RM, M> Index<&Handle<T>> for RefIndexable<RM, M>
where
RM: Deref<Target = M>,
M: MatchName,
{
type Output = T;
fn index(&self, index: &Reference<T>) -> &Self::Output {
fn index(&self, index: &Handle<T>) -> &Self::Output {
let Some(e) = self.get(index) else {
panic!("Could not find entry matching {index:?}")
};
@ -639,12 +639,12 @@ where
}
#[cfg(feature = "alloc")]
impl<T, RM, M> IndexMut<&Reference<T>> for RefIndexable<RM, M>
impl<T, RM, M> IndexMut<&Handle<T>> for RefIndexable<RM, M>
where
RM: DerefMut<Target = M>,
M: MatchName,
{
fn index_mut(&mut self, index: &Reference<T>) -> &mut Self::Output {
fn index_mut(&mut self, index: &Handle<T>) -> &mut Self::Output {
let Some(e) = self.get_mut(index) else {
panic!("Could not find entry matching {index:?}")
};

View File

@ -24,7 +24,7 @@ use libafl::{
};
use libafl_bolts::{
ownedref::OwnedPtr,
tuples::{MatchNameRef, Reference, Referenceable},
tuples::{Handle, Handler, MatchNameRef},
Named, SerdeAny,
};
use serde::{Deserialize, Serialize};
@ -646,7 +646,7 @@ impl AsanErrorsObserver {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AsanErrorsFeedback<S> {
errors: Option<AsanErrors>,
obs_ref: Reference<AsanErrorsObserver>,
obs_ref: Handle<AsanErrorsObserver>,
phantom: PhantomData<S>,
}
@ -716,7 +716,7 @@ impl<S> AsanErrorsFeedback<S> {
pub fn new(obs: &AsanErrorsObserver) -> Self {
Self {
errors: None,
obs_ref: obs.reference(),
obs_ref: obs.handle(),
phantom: PhantomData,
}
}

View File

@ -2340,6 +2340,7 @@ pub type DeviceReset = ::std::option::Option<unsafe extern "C" fn(dev: *mut Devi
#[derive(Debug, Copy, Clone)]
pub struct DeviceClass {
pub parent_class: ObjectClass,
#[doc = " @categories: device categories device belongs to"]
pub categories: [::std::os::raw::c_ulong; 1usize],
#[doc = " @fw_name: name used to identify device to firmware interfaces"]
pub fw_name: *const ::std::os::raw::c_char,

View File

@ -26,7 +26,6 @@ pub const __USE_ATFILE: u32 = 1;
pub const __USE_FORTIFY_LEVEL: u32 = 0;
pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0;
pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0;
pub const __GLIBC_USE_C2X_STRTOL: u32 = 0;
pub const _STDC_PREDEF_H: u32 = 1;
pub const __STDC_IEC_559__: u32 = 1;
pub const __STDC_IEC_60559_BFP__: u32 = 201404;
@ -35,7 +34,7 @@ pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404;
pub const __STDC_ISO_10646__: u32 = 201706;
pub const __GNU_LIBRARY__: u32 = 6;
pub const __GLIBC__: u32 = 2;
pub const __GLIBC_MINOR__: u32 = 39;
pub const __GLIBC_MINOR__: u32 = 35;
pub const _SYS_CDEFS_H: u32 = 1;
pub const __glibc_c99_flexarr_available: u32 = 1;
pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0;
@ -59,7 +58,6 @@ pub const _BITS_TIME64_H: u32 = 1;
pub const _BITS_WCHAR_H: u32 = 1;
pub const _BITS_STDINT_INTN_H: u32 = 1;
pub const _BITS_STDINT_UINTN_H: u32 = 1;
pub const _BITS_STDINT_LEAST_H: u32 = 1;
pub const INT8_MIN: i32 = -128;
pub const INT16_MIN: i32 = -32768;
pub const INT32_MIN: i32 = -2147483648;

View File

@ -6,7 +6,7 @@ use libafl::{
inputs::{Input, UsesInput},
observers::{stacktrace::BacktraceObserver, ObserversTuple},
};
use libafl_bolts::tuples::{MatchFirstType, MatchNameRef, Reference, Referenceable};
use libafl_bolts::tuples::{Handle, Handler, MatchFirstType, MatchNameRef};
use libafl_qemu_sys::GuestAddr;
use thread_local::ThreadLocal;
@ -439,7 +439,7 @@ where
#[derive(Debug)]
pub struct OnCrashBacktraceCollector<'a> {
callstack_hash: u64,
obs_ref: Reference<BacktraceObserver<'a>>,
obs_ref: Handle<BacktraceObserver<'a>>,
}
impl<'a> OnCrashBacktraceCollector<'a> {
@ -447,7 +447,7 @@ impl<'a> OnCrashBacktraceCollector<'a> {
pub fn new(observer: &BacktraceObserver<'a>) -> Self {
Self {
callstack_hash: 0,
obs_ref: observer.reference(),
obs_ref: observer.handle(),
}
}

View File

@ -25,7 +25,7 @@ use libafl_bolts::{
core_affinity::Cores,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
tuples::{tuple_list, Handler, Merge},
AsSliceMut,
};
use typed_builder::TypedBuilder;
@ -115,7 +115,7 @@ impl<'a> ForkserverBytesCoverageSugar<'a> {
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
let time_ref = time_observer.reference();
let time_ref = time_observer.handle();
let mut run_client = |state: Option<_>,
mut mgr: LlmpRestartingEventManager<_, _, _>,

View File

@ -29,7 +29,7 @@ use libafl_bolts::{
ownedref::OwnedMutSlice,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
tuples::{tuple_list, Handler, Merge},
AsSlice,
};
use libafl_targets::{edges_map_mut_ptr, CmpLogObserver};
@ -143,7 +143,7 @@ where
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
let time_ref = time_observer.reference();
let time_ref = time_observer.handle();
let mut run_client = |state: Option<_>,
mut mgr: LlmpRestartingEventManager<_, _, _>,

View File

@ -32,7 +32,7 @@ use libafl_bolts::{
ownedref::OwnedMutSlice,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
tuples::{tuple_list, Handler, Merge},
AsSlice,
};
pub use libafl_qemu::emu::Qemu;
@ -148,7 +148,7 @@ where
// Create an observation channel to keep track of the execution time
let time_observer = TimeObserver::new("time");
let time_ref = time_observer.reference();
let time_ref = time_observer.handle();
let mut run_client = |state: Option<_>,
mut mgr: LlmpRestartingEventManager<_, _, _>,

View File

@ -283,7 +283,7 @@ impl Debug for AFLppCmpLogVals {
impl AFLppCmpLogVals {
#[must_use]
/// Reference comparison values as comparison operands
/// Handle comparison values as comparison operands
pub fn operands(&self) -> &[[AFLppCmpLogOperands; CMPLOG_MAP_H]; CMPLOG_MAP_W] {
unsafe { &self.operands }
}
@ -295,7 +295,7 @@ impl AFLppCmpLogVals {
}
#[must_use]
/// Reference comparison values as comparison function operands
/// Handle comparison values as comparison function operands
pub fn fn_operands(
&self,
) -> &[[AFLppCmpLogFnOperands; CMPLOG_MAP_RTN_EXTENDED_H]; CMPLOG_MAP_W] {
@ -450,7 +450,7 @@ impl AFLppCmpLogMap {
}
#[must_use]
/// Reference the headers for the map
/// Handle the headers for the map
pub fn headers(&self) -> &[AFLppCmpLogHeader] {
&self.headers
}
@ -462,7 +462,7 @@ impl AFLppCmpLogMap {
}
#[must_use]
/// Reference the values for the map
/// Handle the values for the map
pub fn values(&self) -> &AFLppCmpLogVals {
&self.vals
}

View File

@ -12,7 +12,7 @@ use libafl::{
Error, HasMetadata, HasNamedMetadata,
};
use libafl_bolts::{
tuples::{MatchNameRef, Reference},
tuples::{Handle, MatchNameRef},
Named,
};
@ -25,7 +25,7 @@ where
TE: UsesState,
{
tracer_executor: TE,
cmplog_observer_ref: Option<Reference<AFLppCmpLogObserver<'a, TE::State>>>,
cmplog_observer_ref: Option<Handle<AFLppCmpLogObserver<'a, TE::State>>>,
#[allow(clippy::type_complexity)]
phantom: PhantomData<(EM, TE, Z)>,
}
@ -151,7 +151,7 @@ where
/// With cmplog observer
pub fn with_cmplog_observer(
tracer_executor: TE,
obs_ref: Reference<AFLppCmpLogObserver<'a, TE::State>>,
obs_ref: Handle<AFLppCmpLogObserver<'a, TE::State>>,
) -> Self {
Self {
cmplog_observer_ref: Some(obs_ref),