interpret/allocation: get_range on ProvenanceMap
This commit is contained in:
parent
6ba0ce4094
commit
7046ce89c6
2 changed files with 14 additions and 8 deletions
|
|
@ -120,6 +120,17 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets the provenances of all bytes (including from pointers) in a range.
|
||||
pub fn get_range(
|
||||
&self,
|
||||
cx: &impl HasDataLayout,
|
||||
range: AllocRange,
|
||||
) -> impl Iterator<Item = Prov> {
|
||||
let ptr_provs = self.range_ptrs_get(range, cx).iter().map(|(_, p)| *p);
|
||||
let byte_provs = self.range_bytes_get(range).iter().map(|(_, (p, _))| *p);
|
||||
ptr_provs.chain(byte_provs)
|
||||
}
|
||||
|
||||
/// Attempt to merge per-byte provenance back into ptr chunks, if the right fragments
|
||||
/// sit next to each other. Return `false` is that is not possible due to partial pointers.
|
||||
pub fn merge_bytes(&mut self, cx: &impl HasDataLayout) -> bool {
|
||||
|
|
|
|||
|
|
@ -242,14 +242,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
|
||||
match evt {
|
||||
AccessEvent::Read(_) => {
|
||||
// FIXME: ProvenanceMap should have something like get_range().
|
||||
let p_map = alloc.provenance();
|
||||
for idx in overlap {
|
||||
// If a provenance was read by the foreign code, expose it.
|
||||
if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this)
|
||||
{
|
||||
this.expose_provenance(prov)?;
|
||||
}
|
||||
// If a provenance was read by the foreign code, expose it.
|
||||
for prov in alloc.provenance().get_range(this, overlap.into()) {
|
||||
this.expose_provenance(prov)?;
|
||||
}
|
||||
}
|
||||
AccessEvent::Write(_, certain) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue