pub struct MemRegion<T: AbstractDomain + SizedDomain + HasTop + Debug> { /* private fields */ }
Expand description

A memory region is an abstract domain representing a continuous region of memory, e.g. the stack frame of a function.

This implementation can only save values of one abstract domain type, which must implement the HasByteSize and HasTop domains, and it can only track values with a known offset, i.e. it cannot handle arrays of any kind. Offsets are internally saved as signed integers, which allows negative offsets, e.g. for downward growing stack frames.

An empty memory region means that nothing is known about the values at any offset inside the region. Thus an empty memory region actually represents the Top element of its abstract domain.

To allow cheap cloning of a MemRegion, the actual data is wrapped inside an Arc.

Implementations§

source§

impl<T: AbstractDomain + SizedDomain + HasTop + Debug> MemRegion<T>

source

pub fn new(address_bytesize: ByteSize) -> MemRegion<T>

Create a new, empty memory region.

source

pub fn get_address_bytesize(&self) -> ByteSize

Get the bytesize of pointers for the address space that the memory region belongs to.

source

pub fn add(&mut self, value: T, position: Bitvector)

Add a value to the memory region.

source

pub fn insert_at_byte_index(&mut self, value: T, position: i64)

Insert a value into the memory region at the given position. The position is the index (in bytes) in the memory region.

source

pub fn get(&self, position: Bitvector, size_in_bytes: ByteSize) -> T

Get the value at the given position. If there is no value at the position or the size of the element is not the same as the provided size, return T::new_top().

source

pub fn get_unsized(&self, position: Bitvector) -> Option<T>

Get the value at the given position regardless of the value size. Return None if there is no value at that position in the memory region.

source

pub fn remove(&mut self, position: Bitvector, size_in_bytes: Bitvector)

Remove all elements intersecting the provided interval.

source

pub fn merge_write_top(&mut self, position: Bitvector, size: ByteSize)

If the MemRegion contains an element at the given position and with the given size then merge it with a Top element. Else clear all values intersecting the range from position to position + size.

source

pub fn mark_interval_values_as_top( &mut self, start: i64, end: i64, elem_size: ByteSize )

Emulate a write operation of a value to an unknown offset in the range between start and end by merging all values in the range with Top (as we don’t exactly know which values are overwritten).

source

pub fn mark_all_values_as_top(&mut self)

Emulate a write operation to an unknown offset by merging all values with Top to indicate that they may have been overwritten

source

pub fn add_offset_to_all_indices(&mut self, offset: i64)

Add the given offset to the indices of all values contained in the memory region.

source

pub fn iter(&self) -> Iter<'_, i64, T>

Get an iterator over all elements together with their offset into the memory region.

source

pub fn values(&self) -> Values<'_, i64, T>

Get an iterator over all values in the memory region

source

pub fn entry_map(&self) -> &BTreeMap<i64, T>

Get the map of all elements including their offset into the memory region.

source

pub fn values_mut(&mut self) -> ValuesMut<'_, i64, T>

Get an iterator over all values in the memory region for in-place manipulation. Note that one can changes values to Top using the iterator. These values should be removed from the memory region using clear_top_values().

source

pub fn clear_top_values(&mut self)

Remove all values representing the Top element from the internal value store, as these should not be saved in the internal representation.

Trait Implementations§

source§

impl<T: AbstractDomain + SizedDomain + HasTop + Debug> AbstractDomain for MemRegion<T>

source§

fn merge(&self, other: &Self) -> Self

Short-circuting the MemRegionData::merge function if self==other, to prevent unneccessary cloning.

source§

fn is_top(&self) -> bool

The Top element is represented by an empty memory region.

source§

fn merge_with(&mut self, other: &Self) -> &mut Self

Returns an upper bound (with respect to the partial order on the domain) for the two inputs self and other. Read more
source§

impl<T: Clone + AbstractDomain + SizedDomain + HasTop + Debug> Clone for MemRegion<T>

source§

fn clone(&self) -> MemRegion<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug + AbstractDomain + SizedDomain + HasTop + Debug> Debug for MemRegion<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, T> Deserialize<'de> for MemRegion<T>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: AbstractDomain + SizedDomain + HasTop + Debug> HasTop for MemRegion<T>

source§

fn top(&self) -> Self

Return a new, empty memory region with the same address bytesize as self, representing the Top element of the abstract domain.

source§

impl<T: Hash + AbstractDomain + SizedDomain + HasTop + Debug> Hash for MemRegion<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq + AbstractDomain + SizedDomain + HasTop + Debug> PartialEq for MemRegion<T>

source§

fn eq(&self, other: &MemRegion<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for MemRegion<T>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> ToJsonCompact for MemRegion<T>

source§

fn to_json_compact(&self) -> Value

Returns a json representation of values of type self that is suitable for debugging purposes. Read more
source§

fn print_compact_json(&self)

Print values of type Self for debugging purposes.
source§

impl<T: Eq + AbstractDomain + SizedDomain + HasTop + Debug> Eq for MemRegion<T>

source§

impl<T: AbstractDomain + SizedDomain + HasTop + Debug> StructuralEq for MemRegion<T>

source§

impl<T: AbstractDomain + SizedDomain + HasTop + Debug> StructuralPartialEq for MemRegion<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for MemRegion<T>
where T: RefUnwindSafe,

§

impl<T> Send for MemRegion<T>
where T: Send + Sync,

§

impl<T> Sync for MemRegion<T>
where T: Send + Sync,

§

impl<T> Unpin for MemRegion<T>

§

impl<T> UnwindSafe for MemRegion<T>
where T: RefUnwindSafe,

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

§

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>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,