MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / emu_stop

Function emu_stop

icicle-cortexm/src/unicorn_api.rs:128–145  ·  view source on GitHub ↗
(ctx: *mut c_void, exit: uc_err)

Source from the content-addressed store, hash-verified

126}
127
128pub unsafe extern "C" fn emu_stop(ctx: *mut c_void, exit: uc_err) -> uc_err {
129 tracing::debug!("emu_stop({})", fuzzware::uc_error_str(exit));
130 let ctx = &mut *ctx.cast::<Context>();
131 let vm = unsafe { &mut *ctx.vm };
132
133 // We might end up with an "uninitalized read" if this stop was requested as part of handling a
134 // MMIO access, so instead we store the exit code in `fuzzware_exit`.
135 vm.cpu.exception.code = ExceptionCode::Environment as u32;
136 vm.cpu.exception.value = 1;
137
138 if vm.env_mut::<FuzzwareEnvironment>().unwrap().fuzzware_exit.is_some() {
139 // Avoid handling duplicate calls to emu_stop.
140 return UC_ERR_OK;
141 }
142 vm.env_mut::<FuzzwareEnvironment>().unwrap().fuzzware_exit = Some(exit);
143
144 UC_ERR_OK
145}
146
147#[cold]
148#[inline(never)]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected