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

Function reg_read

icicle-cortexm/src/unicorn_api.rs:154–176  ·  view source on GitHub ↗
(ctx: *mut c_void, regid: c_int, value: *mut c_void)

Source from the content-addressed store, hash-verified

152
153#[inline]
154pub unsafe extern "C" fn reg_read(ctx: *mut c_void, regid: c_int, value: *mut c_void) -> uc_err {
155 let ctx = &mut *ctx.cast::<Context>();
156
157 match regid as uc_arm_reg::Type {
158 uc_arm_reg::UC_ARM_REG_XPSR => {
159 let xpsr_reg = *ctx.uc_vars.get(regid as usize).unwrap_or_else(|| invalid_reg(regid));
160 let vm = unsafe { &mut *ctx.vm };
161 *value.cast::<u32>() = vm.cpu.read_reg(xpsr_reg) as u32;
162 }
163 uc_arm_reg::UC_ARM_REG_PC => {
164 let vm = unsafe { &mut *ctx.vm };
165 *value.cast::<u32>() = vm.cpu.read_pc() as u32;
166 }
167 _ => {
168 let data = ctx.get_reg_slice(regid).unwrap_or_else(|| invalid_reg(regid));
169 match data.try_into().ok() {
170 Some(data) => *value.cast::<u32>() = u32::from_ne_bytes(data),
171 None => copy_data_cold(data, value),
172 }
173 }
174 };
175 UC_ERR_OK
176}
177
178#[cold]
179unsafe fn copy_data_cold(data: &[u8], value: *mut std::ffi::c_void) {

Callers 1

reg_read_batchFunction · 0.85

Calls 4

invalid_regFunction · 0.85
copy_data_coldFunction · 0.85
get_reg_sliceMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected