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

Method initialize_vm

icicle-cortexm/src/lib.rs:497–520  ·  view source on GitHub ↗
(
        &mut self,
        _config: &icicle_fuzzing::FuzzConfig,
        vm: &mut icicle_vm::Vm,
    )

Source from the content-addressed store, hash-verified

495 }
496
497 fn initialize_vm(
498 &mut self,
499 _config: &icicle_fuzzing::FuzzConfig,
500 vm: &mut icicle_vm::Vm,
501 ) -> anyhow::Result<()> {
502 // @fixme: this is needed to set the `vm` ptr inside of the `uc_engine` struct that is used
503 // in the C APIs. This usage breaks Rust's aliasing rules, so should be fixed.
504 self.ctx.as_mut().unwrap().get_mut().vm = vm;
505
506 // Force thumb mode.
507 let pc = vm.cpu.read_pc();
508 vm.cpu.write_pc(pc & !0b1);
509 vm.cpu.set_isa_mode(1);
510 vm.cpu.exception.clear();
511
512 vm.env.as_mut_any().downcast_mut::<FuzzwareEnvironment>().unwrap().init(&mut vm.cpu);
513
514 if icicle_fuzzing::parse_bool_env("USE_HALT_PATCHER")?.unwrap_or(false) {
515 icicle_vm::cpu::lifter::register_halt_patcher(&mut vm.lifter);
516 }
517
518 // @todo? run until the first time the input is read
519 Ok(())
520 }
521
522 fn exit_string(&self, exit: VmExit) -> String {
523 if self.fuzzware_exit == fuzzware::uc_err::UC_ERR_OK {

Callers 5

newMethod · 0.80
find_input_for_testsFunction · 0.80
save_block_coverageFunction · 0.80
replayFunction · 0.80
analyze_crashesFunction · 0.80

Calls 4

get_mutMethod · 0.80
as_mut_anyMethod · 0.80
clearMethod · 0.45
initMethod · 0.45

Tested by 1

find_input_for_testsFunction · 0.64