More docs and less pub types (#646)
* more docs * nits * fixes * win fix * fmt
This commit is contained in:
parent
b7650f7683
commit
fa839bb08d
@ -27,9 +27,7 @@ use libafl::{
|
||||
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
|
||||
mutators::token_mutations::Tokens,
|
||||
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
|
||||
schedulers::{
|
||||
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, StdWeightedScheduler,
|
||||
},
|
||||
schedulers::{IndexesLenTimeMinimizerScheduler, StdWeightedScheduler},
|
||||
stages::{calibrate::CalibrationStage, power::StdPowerMutationalStage},
|
||||
state::{HasCorpus, HasMetadata, StdState},
|
||||
Error,
|
||||
|
@ -384,15 +384,18 @@ impl InProcessHandlers {
|
||||
|
||||
/// The global state of the in-process harness.
|
||||
#[derive(Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct InProcessExecutorHandlerData {
|
||||
pub state_ptr: *mut c_void,
|
||||
pub event_mgr_ptr: *mut c_void,
|
||||
pub fuzzer_ptr: *mut c_void,
|
||||
pub executor_ptr: *const c_void,
|
||||
pub(crate) struct InProcessExecutorHandlerData {
|
||||
state_ptr: *mut c_void,
|
||||
event_mgr_ptr: *mut c_void,
|
||||
fuzzer_ptr: *mut c_void,
|
||||
executor_ptr: *const c_void,
|
||||
pub current_input_ptr: *const c_void,
|
||||
pub crash_handler: *const c_void,
|
||||
pub timeout_handler: *const c_void,
|
||||
/// The timeout handler
|
||||
#[allow(unused)] // for no_std
|
||||
crash_handler: *const c_void,
|
||||
/// The timeout handler
|
||||
#[allow(unused)] // for no_std
|
||||
timeout_handler: *const c_void,
|
||||
#[cfg(windows)]
|
||||
pub tp_timer: *mut c_void,
|
||||
#[cfg(windows)]
|
||||
@ -446,7 +449,7 @@ impl InProcessExecutorHandlerData {
|
||||
}
|
||||
|
||||
/// Exception handling needs some nasty unsafe.
|
||||
pub static mut GLOBAL_STATE: InProcessExecutorHandlerData = InProcessExecutorHandlerData {
|
||||
pub(crate) static mut GLOBAL_STATE: InProcessExecutorHandlerData = InProcessExecutorHandlerData {
|
||||
/// The state ptr for signal handling
|
||||
state_ptr: ptr::null_mut(),
|
||||
/// The event manager ptr for signal handling
|
||||
@ -527,7 +530,7 @@ mod unix_signal_handler {
|
||||
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
|
||||
};
|
||||
|
||||
pub type HandlerFuncPtr =
|
||||
pub(crate) type HandlerFuncPtr =
|
||||
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessExecutorHandlerData);
|
||||
|
||||
/// A handler that does nothing.
|
||||
@ -649,7 +652,7 @@ mod unix_signal_handler {
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn inproc_timeout_handler<E, EM, I, OF, OT, S, Z>(
|
||||
pub(crate) unsafe fn inproc_timeout_handler<E, EM, I, OF, OT, S, Z>(
|
||||
_signal: Signal,
|
||||
_info: siginfo_t,
|
||||
_context: &mut ucontext_t,
|
||||
@ -729,7 +732,7 @@ mod unix_signal_handler {
|
||||
/// Will be used for signal handling.
|
||||
/// It will store the current State to shmem, then exit.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||
pub(crate) unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||
signal: Signal,
|
||||
_info: siginfo_t,
|
||||
_context: &mut ucontext_t,
|
||||
@ -880,7 +883,8 @@ mod windows_exception_handler {
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
use windows::Win32::System::Threading::ExitProcess;
|
||||
|
||||
pub type HandlerFuncPtr = unsafe fn(*mut EXCEPTION_POINTERS, &mut InProcessExecutorHandlerData);
|
||||
pub(crate) type HandlerFuncPtr =
|
||||
unsafe fn(*mut EXCEPTION_POINTERS, &mut InProcessExecutorHandlerData);
|
||||
|
||||
/*pub unsafe fn nop_handler(
|
||||
_code: ExceptionCode,
|
||||
@ -1104,7 +1108,7 @@ mod windows_exception_handler {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||
pub(crate) unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||
exception_pointers: *mut EXCEPTION_POINTERS,
|
||||
data: &mut InProcessExecutorHandlerData,
|
||||
) where
|
||||
@ -1244,7 +1248,7 @@ mod windows_exception_handler {
|
||||
|
||||
/// The signature of the crash handler function
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub type ForkHandlerFuncPtr =
|
||||
pub(crate) type ForkHandlerFuncPtr =
|
||||
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessForkExecutorGlobalData);
|
||||
|
||||
/// The inmem fork executor's handlers.
|
||||
@ -1306,7 +1310,7 @@ impl InChildProcessHandlers {
|
||||
/// The global state of the in-process-fork harness.
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
#[derive(Debug)]
|
||||
pub struct InProcessForkExecutorGlobalData {
|
||||
pub(crate) struct InProcessForkExecutorGlobalData {
|
||||
/// Stores a pointer to the fork executor struct
|
||||
pub executor_ptr: *const c_void,
|
||||
/// Stores a pointer to the state
|
||||
@ -1349,7 +1353,7 @@ impl InProcessForkExecutorGlobalData {
|
||||
|
||||
/// a static variable storing the global state
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub static mut FORK_EXECUTOR_GLOBAL_DATA: InProcessForkExecutorGlobalData =
|
||||
pub(crate) static mut FORK_EXECUTOR_GLOBAL_DATA: InProcessForkExecutorGlobalData =
|
||||
InProcessForkExecutorGlobalData {
|
||||
executor_ptr: ptr::null(),
|
||||
crash_handler: ptr::null(),
|
||||
@ -1591,7 +1595,7 @@ pub mod child_signal_handlers {
|
||||
/// The function should only be called from a child crash handler.
|
||||
/// It will dereference the `data` pointer and assume it's valid.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn child_crash_handler<E, I, OT, S>(
|
||||
pub(crate) unsafe fn child_crash_handler<E, I, OT, S>(
|
||||
_signal: Signal,
|
||||
_info: siginfo_t,
|
||||
_context: &mut ucontext_t,
|
||||
|
@ -68,8 +68,8 @@ where
|
||||
|
||||
/// The metadata used for `gramatron`
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct GramatronIdxMapMetadata {
|
||||
/// The map containing a vec for each terminal
|
||||
pub map: HashMap<usize, Vec<usize>>,
|
||||
}
|
||||
|
||||
|
@ -129,14 +129,19 @@ impl SchedulerMetadata {
|
||||
}
|
||||
|
||||
/// The power schedule to use
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PowerSchedule {
|
||||
/// The `explore" power schedule
|
||||
EXPLORE,
|
||||
/// The `exploit` power schedule
|
||||
EXPLOIT,
|
||||
/// The `fast` power schedule
|
||||
FAST,
|
||||
/// The `coe` power schedule
|
||||
COE,
|
||||
/// The `lin` power schedule
|
||||
LIN,
|
||||
/// The `quad` power schedule
|
||||
QUAD,
|
||||
}
|
||||
|
||||
|
@ -27,20 +27,31 @@ use crate::asan::errors::{AsanError, AsanErrors};
|
||||
|
||||
/// An allocator wrapper with binary-only address sanitization
|
||||
#[derive(Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct Allocator {
|
||||
/// The fuzzer options
|
||||
#[allow(dead_code)]
|
||||
options: FuzzerOptions,
|
||||
/// The page size
|
||||
page_size: usize,
|
||||
/// The shadow offsets
|
||||
shadow_offset: usize,
|
||||
/// The shadow bit
|
||||
shadow_bit: usize,
|
||||
/// If the shadow is pre-allocated
|
||||
pre_allocated_shadow: bool,
|
||||
/// All tracked allocations
|
||||
allocations: HashMap<usize, AllocationMetadata>,
|
||||
/// The shadow memory pages
|
||||
shadow_pages: RangeSet<usize>,
|
||||
/// A list of allocations
|
||||
allocation_queue: BTreeMap<usize, Vec<AllocationMetadata>>,
|
||||
/// The size of the largest allocation
|
||||
largest_allocation: usize,
|
||||
/// The total size of all allocations combined
|
||||
total_allocation_size: usize,
|
||||
/// The base address of the shadow memory
|
||||
base_mapping_addr: usize,
|
||||
/// The current mapping address
|
||||
current_mapping_addr: usize,
|
||||
}
|
||||
|
||||
@ -57,14 +68,20 @@ macro_rules! map_to_shadow {
|
||||
|
||||
/// Metadata for an allocation
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct AllocationMetadata {
|
||||
/// The address of the allocation
|
||||
pub address: usize,
|
||||
/// The size of the allocation
|
||||
pub size: usize,
|
||||
/// The actual allocated size, including metadata
|
||||
pub actual_size: usize,
|
||||
/// A backtrace to the allocation location
|
||||
pub allocation_site_backtrace: Option<Backtrace>,
|
||||
/// A backtrace to the location where this memory has been released
|
||||
pub release_site_backtrace: Option<Backtrace>,
|
||||
/// If the allocation has been freed
|
||||
pub freed: bool,
|
||||
/// If the allocation was done with a size of 0
|
||||
pub is_malloc_zero: bool,
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user