Skip to main content

CoverageMap

Struct CoverageMap 

Source
pub struct CoverageMap { /* private fields */ }
Expand description

Per-address execution + write metadata harvested over the lifetime of one (or more) interpreter runs.

The map is always-on inside the Mmu; callers that don’t want coverage data simply ignore it. Cost is two hash operations per executed instruction and one per memory write, which is dwarfed by the rest of the interpreter.

Implementations§

Source§

impl CoverageMap

Source

pub fn clear(&mut self)

Drop everything. Useful between runs when the caller wants per-export coverage instead of cumulative.

Source

pub fn record_exec(&mut self, eip: u32, _insn_size: u8)

Record an instruction fetch at eip. The first byte of every dispatched instruction lands here exactly once per occurrence — multiple hits at the same address share the set entry. insn_size lets the analyzer infer per- instruction coverage spans without re-decoding; today only the first byte is recorded (size hint is reserved for a future per-instruction-span variant).

Source

pub fn record_write(&mut self, addr: u32, size: u32)

Record a guest memory write. size is the access width in bytes (1/2/4/8). Each address tracks the maximum width seen so the recorded write spans cover the widest store that touched the byte.

Source

pub fn executed_addresses(&self) -> impl Iterator<Item = u32> + '_

Iterator over every executed address.

Source

pub fn executed_count(&self) -> usize

Total number of distinct executed addresses.

Source

pub fn written_addresses(&self) -> impl Iterator<Item = u32> + '_

Iterator over every written address. Re-yielding for each byte covered by a wider write means a single 4-byte mov [addr], eax produces 4 entries.

Source

pub fn is_self_modifying(&self, addr: u32) -> bool

True when addr was both written and later executed (in this map’s lifetime). Detection is conservative — the same address being written and executed out of order still trips the check, since the static decompiler treats either ordering as suspect.

Source

pub fn self_modifying_addresses(&self) -> impl Iterator<Item = u32> + '_

Every address that was both written and executed.

Source

pub fn executed_ranges(&self) -> Vec<Range<u32>>

Collapse the executed-address set into contiguous [start, end) ranges (end is exclusive). Two consecutive addresses count as contiguous; gaps of any size start a new range. Useful for spotting unaligned code chunks the static function discovery missed.

Trait Implementations§

Source§

impl Clone for CoverageMap

Source§

fn clone(&self) -> CoverageMap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for CoverageMap

Source§

fn default() -> CoverageMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.