Struct cwe_checker_lib::abstract_domain::MemRegion
source · 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>
impl<T: AbstractDomain + SizedDomain + HasTop + Debug> MemRegion<T>
sourcepub fn get_address_bytesize(&self) -> ByteSize
pub fn get_address_bytesize(&self) -> ByteSize
Get the bytesize of pointers for the address space that the memory region belongs to.
sourcepub fn insert_at_byte_index(&mut self, value: T, position: i64)
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.
sourcepub fn get(&self, position: Bitvector, size_in_bytes: ByteSize) -> T
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()
.
sourcepub fn get_unsized(&self, position: Bitvector) -> Option<T>
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.
sourcepub fn remove(&mut self, position: Bitvector, size_in_bytes: Bitvector)
pub fn remove(&mut self, position: Bitvector, size_in_bytes: Bitvector)
Remove all elements intersecting the provided interval.
sourcepub fn merge_write_top(&mut self, position: Bitvector, size: ByteSize)
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
.
sourcepub fn mark_interval_values_as_top(
&mut self,
start: i64,
end: i64,
elem_size: ByteSize
)
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).
sourcepub fn mark_all_values_as_top(&mut self)
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
sourcepub fn add_offset_to_all_indices(&mut self, offset: i64)
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.
sourcepub fn iter(&self) -> Iter<'_, i64, T>
pub fn iter(&self) -> Iter<'_, i64, T>
Get an iterator over all elements together with their offset into the memory region.
sourcepub fn values(&self) -> Values<'_, i64, T>
pub fn values(&self) -> Values<'_, i64, T>
Get an iterator over all values in the memory region
sourcepub fn entry_map(&self) -> &BTreeMap<i64, T>
pub fn entry_map(&self) -> &BTreeMap<i64, T>
Get the map of all elements including their offset into the memory region.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_, i64, T>
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()
.
sourcepub fn clear_top_values(&mut self)
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>
impl<T: AbstractDomain + SizedDomain + HasTop + Debug> AbstractDomain for MemRegion<T>
source§impl<T: Clone + AbstractDomain + SizedDomain + HasTop + Debug> Clone for MemRegion<T>
impl<T: Clone + AbstractDomain + SizedDomain + HasTop + Debug> Clone for MemRegion<T>
source§impl<T: Debug + AbstractDomain + SizedDomain + HasTop + Debug> Debug for MemRegion<T>
impl<T: Debug + AbstractDomain + SizedDomain + HasTop + Debug> Debug for MemRegion<T>
source§impl<'de, T> Deserialize<'de> for MemRegion<T>
impl<'de, T> Deserialize<'de> for MemRegion<T>
source§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>,
source§impl<T: AbstractDomain + SizedDomain + HasTop + Debug> HasTop for MemRegion<T>
impl<T: AbstractDomain + SizedDomain + HasTop + Debug> HasTop for MemRegion<T>
source§impl<T: Hash + AbstractDomain + SizedDomain + HasTop + Debug> Hash for MemRegion<T>
impl<T: Hash + AbstractDomain + SizedDomain + HasTop + Debug> Hash for MemRegion<T>
source§impl<T: PartialEq + AbstractDomain + SizedDomain + HasTop + Debug> PartialEq for MemRegion<T>
impl<T: PartialEq + AbstractDomain + SizedDomain + HasTop + Debug> PartialEq for MemRegion<T>
source§impl<T> ToJsonCompact for MemRegion<T>
impl<T> ToJsonCompact for MemRegion<T>
source§fn to_json_compact(&self) -> Value
fn to_json_compact(&self) -> Value
self
that is
suitable for debugging purposes. Read moresource§fn print_compact_json(&self)
fn print_compact_json(&self)
Self
for debugging purposes.impl<T: Eq + AbstractDomain + SizedDomain + HasTop + Debug> Eq for MemRegion<T>
impl<T: AbstractDomain + SizedDomain + HasTop + Debug> StructuralEq for MemRegion<T>
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>
impl<T> Sync for MemRegion<T>
impl<T> Unpin for MemRegion<T>
impl<T> UnwindSafe for MemRegion<T>where
T: RefUnwindSafe,
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
§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
§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
key
and return true
if they are equal.