Struct FakeArch
pub struct FakeArch;Expand description
A simple, fake architecture for testing.
Trait Implementations§
§impl Arch for FakeArch
 
impl Arch for FakeArch
§const PAGE_BITS: usize = 12usize
 
const PAGE_BITS: usize = 12usize
The number of bits that are used in a page.
The page size is 
2**PAGE_BITS.
For example, for a page size of 4096 bytes PAGE_BITS would be 12.§const PC: Self::GpReg = {transmute(0x00): <arch::fake::FakeArch as arch::Arch>::GpReg}
 
const PC: Self::GpReg = {transmute(0x00): <arch::fake::FakeArch as arch::Arch>::GpReg}
The program counter register.
§const ZERO: Self::GpReg = {transmute(0x14): <arch::fake::FakeArch as arch::Arch>::GpReg}
 
const ZERO: Self::GpReg = {transmute(0x14): <arch::fake::FakeArch as arch::Arch>::GpReg}
The zero register.
If the architecture does not explicitly list a zero register, you can invent one.
§const INSTRUCTION_ALIGNMENT: usize = 1usize
 
const INSTRUCTION_ALIGNMENT: usize = 1usize
The alignment of the instructions. Must be a multiple of 2.
§type GpReg = FakeReg
 
type GpReg = FakeReg
The general-purpose register representation.
This should be equal to 
Self::Reg, or be a subset.
General-purpose registers must be integers (see crate::value::ValueType). Read more§fn reg(reg: Self::GpReg) -> Self::Reg
 
fn reg(reg: Self::GpReg) -> Self::Reg
Converts a general-purpose register into a generic register.
This must always succeed.
§fn iter_gpregs() -> impl Iterator<Item = Self::GpReg>
 
fn iter_gpregs() -> impl Iterator<Item = Self::GpReg>
Returns an iterator that iterates over all general-purpose registers.
The zero register must not be included, as it is not a real register.
§fn iter_regs() -> impl Iterator<Item = Self::Reg>
 
fn iter_regs() -> impl Iterator<Item = Self::Reg>
Returns an iterator that iterates over all registers.
The zero register must not be included, as it is not a real register.
§fn flagreg_to_flags(
    reg: FakeReg,
    start_byte: usize,
    end_byte: usize,
) -> &'static [Self::Flag]
 
fn flagreg_to_flags( reg: FakeReg, start_byte: usize, end_byte: usize, ) -> &'static [Self::Flag]
Returns the flags associated with the byte range in the flags register.
By convention, a flag register should contain one flag per byte.
§fn try_reg_to_gpreg(reg: Self::Reg) -> Option<Self::GpReg>
 
fn try_reg_to_gpreg(reg: Self::Reg) -> Option<Self::GpReg>
Converts a generic register into a general-purpose register.
If the generic register is not a general-purpose register, 
None is returned.§impl CpuState<FakeArch> for FakeState
 
impl CpuState<FakeArch> for FakeState
§type DiffMask = ()
 
type DiffMask = ()
The type of the difference mask used in 
CpuState::find_dataflows_masked. Read more§fn state_byte_to_reg(byte: StateByte) -> (<FakeArch as Arch>::Reg, usize)
 
fn state_byte_to_reg(byte: StateByte) -> (<FakeArch as Arch>::Reg, usize)
Converts a state byte to a register.
Inverse of 
CpuState::reg_to_state_byte.§fn reg_to_state_byte(reg: <FakeArch as Arch>::Reg, byte: usize) -> StateByte
 
fn reg_to_state_byte(reg: <FakeArch as Arch>::Reg, byte: usize) -> StateByte
Converts a (register, byte index) tuple to a state byte.
Inverse of 
CpuState::state_byte_to_reg.§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 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.
§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. Read more§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_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.§impl<'de> Deserialize<'de> for FakeArch
 
impl<'de> Deserialize<'de> for FakeArch
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl JsonSchema for FakeArch
 
impl JsonSchema for FakeArch
§fn schema_name() -> String
 
fn schema_name() -> String
The name of the generated JSON Schema. Read more
§fn schema_id() -> Cow<'static, str>
 
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
 
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
§fn is_referenceable() -> bool
 
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the 
$ref keyword. Read more§impl<F, M> Oracle<FakeArch> for FakeOracle<F, M>where
    F: Fn(&SystemState<FakeArch>) -> Result<SystemState<FakeArch>, OracleError>,
    M: Fn(&SystemState<FakeArch>) -> Result<Vec<Addr>, OracleError>,
 
impl<F, M> Oracle<FakeArch> for FakeOracle<F, M>where
    F: Fn(&SystemState<FakeArch>) -> Result<SystemState<FakeArch>, OracleError>,
    M: Fn(&SystemState<FakeArch>) -> Result<Vec<Addr>, OracleError>,
§const UNRELIABLE_INSTRUCTION_FETCH_ERRORS: bool = false
 
const UNRELIABLE_INSTRUCTION_FETCH_ERRORS: bool = false
Set to true if the instruction fetch errors are unreliable.
§type MappableArea = AnyArea
 
type MappableArea = AnyArea
The memory addresses that can be mapped by this oracle.
§fn mappable_area(&self) -> Self::MappableArea
 
fn mappable_area(&self) -> Self::MappableArea
Returns the memory addresses that can be mapped by this oracle.
§fn observe(
    &mut self,
    before: &SystemState<FakeArch>,
) -> Result<SystemState<FakeArch>, OracleError>
 
fn observe( &mut self, before: &SystemState<FakeArch>, ) -> Result<SystemState<FakeArch>, OracleError>
Observes the output state after executing a single instruction in the 
before state.§fn scan_memory_accesses(
    &mut self,
    before: &SystemState<FakeArch>,
) -> Result<Vec<Addr>, OracleError>
 
fn scan_memory_accesses( &mut self, before: &SystemState<FakeArch>, ) -> Result<Vec<Addr>, OracleError>
Uses debugging registers to determine all memory addresses accessed by the instruction.
If this is not supported, returns an empty 
Vec.§fn debug_dump(&mut self)
 
fn debug_dump(&mut self)
Prints debugging information about the oracle.
§fn batch_observe_iter<'a, S: AsSystemState<FakeArch> + 'a, I: IntoIterator<Item = S> + 'a>(
    &'a mut self,
    states: I,
) -> impl Iterator<Item = Observation<S, FakeArch>>
 
fn batch_observe_iter<'a, S: AsSystemState<FakeArch> + 'a, I: IntoIterator<Item = S> + 'a>( &'a mut self, states: I, ) -> impl Iterator<Item = Observation<S, FakeArch>>
Performs many observations in one go.
Behaves idential to 
Self::observe, but is much more efficient.§fn batch_observe_gpreg_only_iter<'a, S: AsSystemState<FakeArch> + 'a, I: IntoIterator<Item = S> + 'a>(
    &'a mut self,
    states: I,
) -> impl Iterator<Item = Observation<S, FakeArch>>
 
fn batch_observe_gpreg_only_iter<'a, S: AsSystemState<FakeArch> + 'a, I: IntoIterator<Item = S> + 'a>( &'a mut self, states: I, ) -> impl Iterator<Item = Observation<S, FakeArch>>
Performs many observations in one go.
Only reads and writes the general-purpose registers.
Other registers may have arbitrary values.
§fn random_mappable_page(&self, rng: &mut impl Rng) -> Page<A>
 
fn random_mappable_page(&self, rng: &mut impl Rng) -> Page<A>
Returns a random mappable page.
§fn observe_carefully(
    &mut self,
    before: &SystemState<A>,
) -> Result<SystemState<A>, OracleError>
 
fn observe_carefully( &mut self, before: &SystemState<A>, ) -> Result<SystemState<A>, OracleError>
Observes the output state after executing a single instruction in the 
before state.
If possible, uses debugging registers to exhaustively check the exact memory locations that are accessed.
Returns a memory access error if a memory is accessed that is not set in before. Read more§fn batch_observe<'a, const N: usize, S: AsSystemState<A> + 'a>(
    &mut self,
    states: [S; N],
) -> [Observation<S, A>; N]
 
fn batch_observe<'a, const N: usize, S: AsSystemState<A> + 'a>( &mut self, states: [S; N], ) -> [Observation<S, A>; N]
Performs many observations in one go.
Behaves idential to 
Self::observe, but is much more efficient.§impl Ord for FakeArch
 
impl Ord for FakeArch
§impl PartialOrd for FakeArch
 
impl PartialOrd for FakeArch
impl Copy for FakeArch
impl Eq for FakeArch
impl StructuralPartialEq for FakeArch
Auto Trait Implementations§
impl Freeze for FakeArch
impl RefUnwindSafe for FakeArch
impl Send for FakeArch
impl Sync for FakeArch
impl Unpin for FakeArch
impl UnwindSafe for FakeArch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Identity for Twhere
    T: ?Sized,
 
impl<T> Identity for Twhere
    T: ?Sized,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more