diff --git a/crates/libafl/src/executors/inprocess/stateful.rs b/crates/libafl/src/executors/inprocess/stateful.rs index f95d41e4cb..7a3056659a 100644 --- a/crates/libafl/src/executors/inprocess/stateful.rs +++ b/crates/libafl/src/executors/inprocess/stateful.rs @@ -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, HT) { self.inner.hooks() } /// The inprocess handlers (mutable) #[inline] + #[must_use] pub fn hooks_mut(&mut self) -> &mut (InProcessHooks, 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 HasInProcessHooks diff --git a/crates/libafl/src/executors/inprocess_fork/stateful.rs b/crates/libafl/src/executors/inprocess_fork/stateful.rs index 30293047f3..cb74846bae 100644 --- a/crates/libafl/src/executors/inprocess_fork/stateful.rs +++ b/crates/libafl/src/executors/inprocess_fork/stateful.rs @@ -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 HasObservers diff --git a/crates/libafl_qemu/src/executor.rs b/crates/libafl_qemu/src/executor.rs index 7b544a2402..768ba9c274 100644 --- a/crates/libafl_qemu/src/executor.rs +++ b/crates/libafl_qemu/src/executor.rs @@ -279,6 +279,7 @@ where }) } + #[must_use] pub fn inner(&self) -> &EmulatorInProcessExecutor { &self.inner } @@ -288,11 +289,19 @@ where BREAK_ON_TMOUT.store(true, Ordering::Release); } + #[must_use] pub fn inner_mut( &mut self, ) -> &mut EmulatorInProcessExecutor { &mut self.inner } + + /// Retrieve the emulator, consuming the executor. + #[inline] + #[must_use] + pub fn into_emulator(self) -> Emulator { + self.inner.into_state() + } } impl Executor @@ -432,24 +441,35 @@ where } #[allow(clippy::type_complexity)] + #[must_use] pub fn inner(&self) -> &QemuInProcessForkExecutor { &self.inner } #[allow(clippy::type_complexity)] + #[must_use] pub fn inner_mut( &mut self, ) -> &mut QemuInProcessForkExecutor { &mut self.inner } + #[must_use] pub fn emulator(&self) -> &Emulator { &self.inner.exposed_executor_state } + #[must_use] pub fn emulator_mut(&mut self) -> &Emulator { &mut self.inner.exposed_executor_state } + + /// Retrieve the emulator, consuming the executor. + #[inline] + #[must_use] + pub fn into_emulator(self) -> Emulator { + self.inner.into_state() + } } #[cfg(feature = "fork")]