make the new option actually do something

This commit is contained in:
Ralf Jung 2020-03-06 09:11:41 +01:00
parent d82d701360
commit ade4c4e733
3 changed files with 11 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use crate::*;
/// Miri specific diagnostics
pub enum NonHaltingDiagnostic {
PoppedTrackedPointerTag(Item),
CreatedAlloc(AllocId),
}
/// Emit a custom diagnostic without going through the miri-engine machinery
@ -97,9 +98,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let this = self.eval_context_ref();
DIAGNOSTICS.with(|diagnostics| {
for e in diagnostics.borrow_mut().drain(..) {
use NonHaltingDiagnostic::*;
let msg = match e {
NonHaltingDiagnostic::PoppedTrackedPointerTag(item) =>
PoppedTrackedPointerTag(item) =>
format!("popped tracked tag for item {:?}", item),
CreatedAlloc(AllocId(id)) =>
format!("created allocation with id {}", id),
};
report_msg(this, msg, false);
}

View file

@ -334,6 +334,10 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
alloc: Cow<'b, Allocation>,
kind: Option<MemoryKind<Self::MemoryKinds>>,
) -> (Cow<'b, Allocation<Self::PointerTag, Self::AllocExtra>>, Self::PointerTag) {
if Some(id) == memory_extra.tracked_alloc_id {
register_diagnostic(NonHaltingDiagnostic::CreatedAlloc(id));
}
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
let alloc = alloc.into_owned();
let (stacks, base_tag) =