Trait CpuState
pub trait CpuState<A: Arch>: Default {
type DiffMask: Clone + Default + Debug;
Show 18 methods
// Required methods
fn gpreg(&self, reg: A::GpReg) -> u64;
fn set_gpreg(&mut self, reg: A::GpReg, value: u64);
fn reg(&self, reg: A::Reg) -> Value<'_>;
fn modify_reg<F: FnOnce(MutValue<'_>)>(&mut self, reg: A::Reg, update: F);
fn flag(&self, flag: A::Flag) -> bool;
fn set_flag(&mut self, flag: A::Flag, value: bool);
fn size() -> usize;
fn state_byte_to_reg(byte: StateByte) -> (A::Reg, usize);
fn reg_to_state_byte(reg: A::Reg, byte: usize) -> StateByte;
fn create_diff_mask<I: Iterator<Item = StateByte>>(
items: I,
) -> Self::DiffMask;
// Provided methods
fn create<R: FnMut(A::Reg, MutValue<'_>)>(regval: R) -> Self { ... }
fn default_with_pc(pc: u64) -> Self { ... }
fn get_state_byte(&self, byte: StateByte) -> u8 { ... }
fn set_state_byte(&mut self, byte: StateByte, value: u8) { ... }
fn state_bytes_unequal(&self, dest: StateByte, other: &Self) -> bool { ... }
fn state_bytes_equal(&self, dest: StateByte, other: &Self) -> bool { ... }
fn find_differences<F: FnMut(StateByte)>(&self, other: &Self, found: &mut F) { ... }
fn find_dataflows_masked<F: FnMut(StateByte)>(
b: SystemStateIoPair<'_, A>,
a: SystemStateIoPair<'_, A>,
dest_diff_mask: &Self::DiffMask,
diff_mask: &Self::DiffMask,
found: &mut F,
) { ... }
}
Expand description
Represents a CPU state.
Required Associated Types§
type DiffMask: Clone + Default + Debug
type DiffMask: Clone + Default + Debug
The type of the difference mask used in CpuState::find_dataflows_masked
.
An optional optimization. Set to ()
if not used.
Required Methods§
fn modify_reg<F: FnOnce(MutValue<'_>)>(&mut self, reg: A::Reg, update: F)
fn modify_reg<F: FnOnce(MutValue<'_>)>(&mut self, reg: A::Reg, update: F)
Modifies the value of reg
using update function update
.
The update function receives a crate::value::MutValue
, which can be used to update the value of the register.
fn state_byte_to_reg(byte: StateByte) -> (A::Reg, usize)
fn state_byte_to_reg(byte: StateByte) -> (A::Reg, usize)
Converts a state byte to a register.
Inverse of CpuState::reg_to_state_byte
.
fn reg_to_state_byte(reg: A::Reg, byte: usize) -> StateByte
fn reg_to_state_byte(reg: A::Reg, byte: usize) -> StateByte
Converts a (register, byte index) tuple to a state byte.
Inverse of CpuState::state_byte_to_reg
.
fn create_diff_mask<I: Iterator<Item = StateByte>>(items: I) -> Self::DiffMask
fn create_diff_mask<I: Iterator<Item = StateByte>>(items: I) -> Self::DiffMask
Creates a mask of state bytes whose differences can be ignored.
Provided Methods§
fn create<R: FnMut(A::Reg, MutValue<'_>)>(regval: R) -> Self
fn create<R: FnMut(A::Reg, MutValue<'_>)>(regval: R) -> Self
Creates a new CPU state using regval
to determine the values of the registers.
Implementation is optional.
The default implementation calls CpuState::modify_reg
on each register to initialize them.
fn default_with_pc(pc: u64) -> Self
fn default_with_pc(pc: u64) -> Self
Creates a default state with the program counter set to pc
.
fn get_state_byte(&self, byte: StateByte) -> u8
fn get_state_byte(&self, byte: StateByte) -> u8
Returns the value of the byte byte
in the CPU state.
fn set_state_byte(&mut self, byte: StateByte, value: u8)
fn set_state_byte(&mut self, byte: StateByte, value: u8)
Sets the value of the byte byte
in the CPU state.
fn state_bytes_unequal(&self, dest: StateByte, other: &Self) -> bool
fn state_bytes_unequal(&self, dest: StateByte, other: &Self) -> bool
Returns true if the value of the specified state byte in self
is not equal to the value in other
.
fn state_bytes_equal(&self, dest: StateByte, other: &Self) -> bool
fn state_bytes_equal(&self, dest: StateByte, other: &Self) -> bool
Returns true if the value of the specified state byte in self
is equal to the value in other
.
fn find_differences<F: FnMut(StateByte)>(&self, other: &Self, found: &mut F)
fn find_differences<F: FnMut(StateByte)>(&self, other: &Self, found: &mut F)
Enumerates over all differences between the two state pairs.
Calls found
for each state byte that differs between self
and other
.
The call order is unspecified.
fn find_dataflows_masked<F: FnMut(StateByte)>(
b: SystemStateIoPair<'_, A>,
a: SystemStateIoPair<'_, A>,
dest_diff_mask: &Self::DiffMask,
diff_mask: &Self::DiffMask,
found: &mut F,
)
fn find_dataflows_masked<F: FnMut(StateByte)>( b: SystemStateIoPair<'_, A>, a: SystemStateIoPair<'_, A>, dest_diff_mask: &Self::DiffMask, diff_mask: &Self::DiffMask, found: &mut F, )
Enumerates over all differences between the two state pairs.
Calls found
for each state byte that differs between self
and other
.
diff_mask
is a hint of differences that can be ignored.
Therefore, this function may call found
even for state bytes that can be ignored according to diff_mask
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.