Skip to content
Open
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
11 changes: 11 additions & 0 deletions crates/libafl/src/executors/inprocess/stateful.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,27 +285,38 @@ where

/// Retrieve the harness function.
#[inline]
#[must_use]
pub fn harness(&self) -> &H {
self.harness_fn.borrow()
}

/// Retrieve the harness function for a mutable reference.
#[inline]
#[must_use]
pub fn harness_mut(&mut self) -> &mut H {
self.harness_fn.borrow_mut()
}

/// The inprocess handlers
#[inline]
#[must_use]
pub fn hooks(&self) -> &(InProcessHooks<I, S>, HT) {
self.inner.hooks()
}

/// The inprocess handlers (mutable)
#[inline]
#[must_use]
pub fn hooks_mut(&mut self) -> &mut (InProcessHooks<I, S>, HT) {
self.inner.hooks_mut()
}

/// Retrieve the state, consuming the executor.
#[inline]
#[must_use]
pub fn into_state(self) -> ES {
self.exposed_executor_state
}
}

impl<EM, ES, H, HB, HT, I, OT, S, Z> HasInProcessHooks<I, S>
Expand Down
7 changes: 7 additions & 0 deletions crates/libafl/src/executors/inprocess_fork/stateful.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ where
pub fn harness_mut(&mut self) -> &mut H {
&mut self.harness_fn
}

/// Retrieve the state, consuming the executor.
#[inline]
#[must_use]
pub fn into_state(self) -> ES {
self.exposed_executor_state
}
}

impl<H, HT, I, OT, S, SP, EM, ES, Z> HasObservers
Expand Down
20 changes: 20 additions & 0 deletions crates/libafl_qemu/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ where
})
}

#[must_use]
pub fn inner(&self) -> &EmulatorInProcessExecutor<C, CM, ED, EM, ET, H, I, OT, S, SM, Z> {
&self.inner
}
Expand All @@ -288,11 +289,19 @@ where
BREAK_ON_TMOUT.store(true, Ordering::Release);
}

#[must_use]
pub fn inner_mut(
&mut self,
) -> &mut EmulatorInProcessExecutor<C, CM, ED, EM, ET, H, I, OT, S, SM, Z> {
&mut self.inner
}

/// Retrieve the emulator, consuming the executor.
#[inline]
#[must_use]
pub fn into_emulator(self) -> Emulator<C, CM, ED, ET, I, S, SM> {
self.inner.into_state()
}
}

impl<C, CM, ED, EM, ET, H, I, OT, S, SM, Z> Executor<EM, I, S, Z>
Expand Down Expand Up @@ -432,24 +441,35 @@ where
}

#[allow(clippy::type_complexity)]
#[must_use]
pub fn inner(&self) -> &QemuInProcessForkExecutor<C, CM, ED, EM, ET, H, I, OT, S, SM, SP, Z> {
&self.inner
}

#[allow(clippy::type_complexity)]
#[must_use]
pub fn inner_mut(
&mut self,
) -> &mut QemuInProcessForkExecutor<C, CM, ED, EM, ET, H, I, OT, S, SM, SP, Z> {
&mut self.inner
}

#[must_use]
pub fn emulator(&self) -> &Emulator<C, CM, ED, ET, I, S, SM> {
&self.inner.exposed_executor_state
}

#[must_use]
pub fn emulator_mut(&mut self) -> &Emulator<C, CM, ED, ET, I, S, SM> {
&mut self.inner.exposed_executor_state
}

/// Retrieve the emulator, consuming the executor.
#[inline]
#[must_use]
pub fn into_emulator(self) -> Emulator<C, CM, ED, ET, I, S, SM> {
self.inner.into_state()
}
}

#[cfg(feature = "fork")]
Expand Down
Loading