Struct cwe_checker_lib::analysis::pointer_inference::object::AbstractObject
source · pub struct AbstractObject { /* private fields */ }
Expand description
An abstract object contains all knowledge tracked about a particular memory object.
In some cases one abstract object can represent more than one actual memory object. This happens for e.g. several memory objects allocated into an array, since we cannot represent every object separately without knowing the exact number of objects (which may be runtime dependent).
To allow cheap cloning of abstract objects, the actual data is wrapped in an Arc
.
Examples of memory objects:
- The stack frame of a function
- A memory object allocated on the heap
Implementations§
source§impl AbstractObject
impl AbstractObject
sourcepub fn get_referenced_ids_overapproximation(
&self
) -> &BTreeSet<AbstractIdentifier>
pub fn get_referenced_ids_overapproximation( &self ) -> &BTreeSet<AbstractIdentifier>
Get all abstract IDs that the object may contain pointers to. This yields an overapproximation of possible pointer targets.
sourcepub fn get_referenced_ids_underapproximation(
&self
) -> BTreeSet<AbstractIdentifier>
pub fn get_referenced_ids_underapproximation( &self ) -> BTreeSet<AbstractIdentifier>
Get all abstract IDs for which the object contains pointers to. This yields an underapproximation of pointer targets, since the object may contain pointers that could not be tracked by the analysis.
sourcepub fn remove_ids(&mut self, ids_to_remove: &BTreeSet<AbstractIdentifier>)
pub fn remove_ids(&mut self, ids_to_remove: &BTreeSet<AbstractIdentifier>)
Remove the provided IDs from the target lists of all pointers in the memory object. Also remove them from the pointer_targets list.
If this operation would produce an empty value, it replaces it with a Top
value instead.
sourcepub fn replace_ids(
&mut self,
replacement_map: &BTreeMap<AbstractIdentifier, Data>
)
pub fn replace_ids( &mut self, replacement_map: &BTreeMap<AbstractIdentifier, Data> )
Replace all abstract IDs in self
with the values given by the replacement map.
IDs not contained as keys in the replacement map are replaced by Top
values.
source§impl AbstractObject
impl AbstractObject
sourcepub fn get_value(&self, offset: Bitvector, bytesize: ByteSize) -> Data
pub fn get_value(&self, offset: Bitvector, bytesize: ByteSize) -> Data
Read the value at the given offset of the given size inside the memory region.
sourcepub fn set_value(
&mut self,
value: Data,
offset: &ValueDomain
) -> Result<(), Error>
pub fn set_value( &mut self, value: Data, offset: &ValueDomain ) -> Result<(), Error>
Write a value at the given offset to the memory region.
If the abstract object is not unique (i.e. may represent more than one actual object), merge the old value at the given offset with the new value.
sourcepub fn merge_value(&mut self, value: Data, offset: &ValueDomain)
pub fn merge_value(&mut self, value: Data, offset: &ValueDomain)
Merge value
at position offset
with the value currently saved at that position.
sourcepub fn assume_arbitrary_writes(
&mut self,
additional_targets: &BTreeSet<AbstractIdentifier>
)
pub fn assume_arbitrary_writes( &mut self, additional_targets: &BTreeSet<AbstractIdentifier> )
Marks all memory as Top
and adds the additional_targets
to the pointer targets.
Represents the effect of unknown write instructions to the object
which may include writing pointers to targets from the additional_targets
set to the object.
source§impl AbstractObject
impl AbstractObject
sourcepub fn new(
type_: Option<ObjectType>,
address_bytesize: ByteSize
) -> AbstractObject
pub fn new( type_: Option<ObjectType>, address_bytesize: ByteSize ) -> AbstractObject
Create a new abstract object with given object type and address bytesize.
sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
Returns false
if the abstract object may represent more than one object,
e.g. for arrays of objects.
sourcepub fn mark_as_not_unique(&mut self)
pub fn mark_as_not_unique(&mut self)
Mark the abstract object as possibly representing more than one actual memory object.
sourcepub fn mark_as_unique(&mut self)
pub fn mark_as_unique(&mut self)
Mark the abstract object as unique, i.e. it represents exactly one memory object.
sourcepub fn get_object_type(&self) -> Option<ObjectType>
pub fn get_object_type(&self) -> Option<ObjectType>
Get the type of the memory object.
sourcepub fn set_object_type(&mut self, object_type: Option<ObjectType>)
pub fn set_object_type(&mut self, object_type: Option<ObjectType>)
Set the type of the memory object.
sourcepub fn overwrite_with(
&mut self,
other: &AbstractObject,
offset_other: &ValueDomain
)
pub fn overwrite_with( &mut self, other: &AbstractObject, offset_other: &ValueDomain )
Overwrite the values in self
with those in other
under the assumption that the zero offset in other
corresponds to the offset offset_other
in self
.
If self
is not a unique memory object or if offset_other
is not a precisely known offset,
then the function tries to merge self
and other
,
since we do not exactly know which values of self
were overwritten by other
.
All values of self
are marked as possibly overwritten, i.e. Top
,
but they are only deleted if they intersect a non-Top
value of other
.
This approximates the fact that we currently do not track exactly which indices
in other
were overwritten with a Top
element and which indices simply were not
accessed at all in other
.
sourcepub fn add_offset_to_all_indices(&mut self, offset: &ValueDomain)
pub fn add_offset_to_all_indices(&mut self, offset: &ValueDomain)
Add an offset to all values contained in the abstract object.
sourcepub fn get_mem_region(&self) -> &MemRegion<Data>
pub fn get_mem_region(&self) -> &MemRegion<Data>
Get the memory region abstract domain associated to the memory object.
sourcepub fn overwrite_mem_region(&mut self, new_memory_region: MemRegion<Data>)
pub fn overwrite_mem_region(&mut self, new_memory_region: MemRegion<Data>)
Overwrite the memory region abstract domain associated to the memory object. Note that this function does not update the list of known pointer targets accordingly!
sourcepub fn add_ids_to_pointer_targets(
&mut self,
ids_to_add: BTreeSet<AbstractIdentifier>
)
pub fn add_ids_to_pointer_targets( &mut self, ids_to_add: BTreeSet<AbstractIdentifier> )
Add IDs to the list of pointer targets for the memory object.
source§impl AbstractObject
impl AbstractObject
sourcepub fn to_json_compact(&self) -> Value
pub fn to_json_compact(&self) -> Value
Get a more compact json-representation of the abstract object. Intended for pretty printing, not useable for serialization/deserialization.
Trait Implementations§
source§impl AbstractDomain for AbstractObject
impl AbstractDomain for AbstractObject
source§impl Clone for AbstractObject
impl Clone for AbstractObject
source§fn clone(&self) -> AbstractObject
fn clone(&self) -> AbstractObject
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AbstractObject
impl Debug for AbstractObject
source§impl<'de> Deserialize<'de> for AbstractObject
impl<'de> Deserialize<'de> for AbstractObject
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 PartialEq for AbstractObject
impl PartialEq for AbstractObject
source§fn eq(&self, other: &AbstractObject) -> bool
fn eq(&self, other: &AbstractObject) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for AbstractObject
impl Serialize for AbstractObject
impl Eq for AbstractObject
impl StructuralEq for AbstractObject
impl StructuralPartialEq for AbstractObject
Auto Trait Implementations§
impl RefUnwindSafe for AbstractObject
impl Send for AbstractObject
impl Sync for AbstractObject
impl Unpin for AbstractObject
impl UnwindSafe for AbstractObject
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.