add option to track a particular AllocId (does nothing yet)
This commit is contained in:
parent
63925169c1
commit
d82d701360
@ -29,16 +29,7 @@ fn after_analysis<'tcx>(
|
||||
tcx.entry_fn(LOCAL_CRATE).expect("no main or start function found");
|
||||
|
||||
self.bencher.iter(|| {
|
||||
let config = miri::MiriConfig {
|
||||
validate: true,
|
||||
stacked_borrows: true,
|
||||
communicate: false,
|
||||
ignore_leaks: false,
|
||||
excluded_env_vars: vec![],
|
||||
args: vec![],
|
||||
seed: None,
|
||||
tracked_pointer_tag: None,
|
||||
};
|
||||
let config = miri::MiriConfig::default();
|
||||
eval_main(tcx, entry_def_id, config);
|
||||
});
|
||||
});
|
||||
|
@ -46,16 +46,7 @@ fn visit_item(&mut self, i: &'hir hir::Item) {
|
||||
.iter()
|
||||
.any(|attr| attr.check_name(rustc_span::symbol::sym::test))
|
||||
{
|
||||
let config = MiriConfig {
|
||||
validate: true,
|
||||
stacked_borrows: true,
|
||||
communicate: false,
|
||||
ignore_leaks: false,
|
||||
excluded_env_vars: vec![],
|
||||
args: vec![],
|
||||
seed: None,
|
||||
tracked_pointer_tag: None,
|
||||
};
|
||||
let config = MiriConfig::default();
|
||||
let did = self.0.hir().body_owner_def_id(body_id);
|
||||
println!("running test: {}", self.0.def_path_debug_str(did));
|
||||
miri::eval_main(self.0, did, config);
|
||||
@ -68,16 +59,7 @@ fn visit_impl_item(&mut self, _impl_item: &'hir hir::ImplItem) {}
|
||||
}
|
||||
tcx.hir().krate().visit_all_item_likes(&mut Visitor(tcx));
|
||||
} else if let Some((entry_def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
|
||||
let config = MiriConfig {
|
||||
validate: true,
|
||||
stacked_borrows: true,
|
||||
communicate: false,
|
||||
ignore_leaks: false,
|
||||
excluded_env_vars: vec![],
|
||||
args: vec![],
|
||||
seed: None,
|
||||
tracked_pointer_tag: None,
|
||||
};
|
||||
let config = MiriConfig::default();
|
||||
miri::eval_main(tcx, entry_def_id, config);
|
||||
|
||||
compiler.session().abort_if_errors();
|
||||
|
@ -135,6 +135,7 @@ fn main() {
|
||||
let mut ignore_leaks = false;
|
||||
let mut seed: Option<u64> = None;
|
||||
let mut tracked_pointer_tag: Option<miri::PtrId> = None;
|
||||
let mut tracked_alloc_id: Option<miri::AllocId> = None;
|
||||
let mut rustc_args = vec![];
|
||||
let mut miri_args = vec![];
|
||||
let mut after_dashdash = false;
|
||||
@ -206,6 +207,17 @@ fn main() {
|
||||
panic!("-Zmiri-track-pointer-tag must be a nonzero id");
|
||||
}
|
||||
}
|
||||
arg if arg.starts_with("-Zmiri-track-alloc-id=") => {
|
||||
let id: u64 = match arg.trim_start_matches("-Zmiri-track-alloc-id=").parse()
|
||||
{
|
||||
Ok(id) => id,
|
||||
Err(err) => panic!(
|
||||
"-Zmiri-track-alloc-id requires a valid `u64` as the argument: {}",
|
||||
err
|
||||
),
|
||||
};
|
||||
tracked_alloc_id = Some(miri::AllocId(id));
|
||||
}
|
||||
_ => {
|
||||
rustc_args.push(arg);
|
||||
}
|
||||
@ -240,6 +252,7 @@ fn main() {
|
||||
seed,
|
||||
args: miri_args,
|
||||
tracked_pointer_tag,
|
||||
tracked_alloc_id,
|
||||
};
|
||||
rustc_driver::install_ice_hook();
|
||||
let result = rustc_driver::catch_fatal_errors(move || {
|
||||
|
19
src/eval.rs
19
src/eval.rs
@ -30,6 +30,24 @@ pub struct MiriConfig {
|
||||
pub seed: Option<u64>,
|
||||
/// The stacked borrow id to report about
|
||||
pub tracked_pointer_tag: Option<PtrId>,
|
||||
/// The allocation id to report about.
|
||||
pub tracked_alloc_id: Option<AllocId>,
|
||||
}
|
||||
|
||||
impl Default for MiriConfig {
|
||||
fn default() -> MiriConfig {
|
||||
MiriConfig {
|
||||
validate: true,
|
||||
stacked_borrows: true,
|
||||
communicate: false,
|
||||
ignore_leaks: false,
|
||||
excluded_env_vars: vec![],
|
||||
args: vec![],
|
||||
seed: None,
|
||||
tracked_pointer_tag: None,
|
||||
tracked_alloc_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Details of premature program termination.
|
||||
@ -55,6 +73,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
|
||||
StdRng::seed_from_u64(config.seed.unwrap_or(0)),
|
||||
config.stacked_borrows,
|
||||
config.tracked_pointer_tag,
|
||||
config.tracked_alloc_id,
|
||||
),
|
||||
);
|
||||
// Complete initialization.
|
||||
|
@ -75,15 +75,19 @@ pub struct MemoryExtra {
|
||||
pub intptrcast: intptrcast::MemoryExtra,
|
||||
|
||||
/// Mapping extern static names to their canonical allocation.
|
||||
pub(crate) extern_statics: FxHashMap<Symbol, AllocId>,
|
||||
extern_statics: FxHashMap<Symbol, AllocId>,
|
||||
|
||||
/// The random number generator used for resolving non-determinism.
|
||||
/// Needs to be queried by ptr_to_int, hence needs interior mutability.
|
||||
pub(crate) rng: RefCell<StdRng>,
|
||||
|
||||
/// An allocation ID to report when it is being allocated
|
||||
/// (helps for debugging memory leaks).
|
||||
tracked_alloc_id: Option<AllocId>,
|
||||
}
|
||||
|
||||
impl MemoryExtra {
|
||||
pub fn new(rng: StdRng, stacked_borrows: bool, tracked_pointer_tag: Option<PtrId>) -> Self {
|
||||
pub fn new(rng: StdRng, stacked_borrows: bool, tracked_pointer_tag: Option<PtrId>, tracked_alloc_id: Option<AllocId>) -> Self {
|
||||
let stacked_borrows = if stacked_borrows {
|
||||
Some(Rc::new(RefCell::new(stacked_borrows::GlobalState::new(tracked_pointer_tag))))
|
||||
} else {
|
||||
@ -94,6 +98,7 @@ pub fn new(rng: StdRng, stacked_borrows: bool, tracked_pointer_tag: Option<PtrId
|
||||
intptrcast: Default::default(),
|
||||
extern_statics: FxHashMap::default(),
|
||||
rng: RefCell::new(rng),
|
||||
tracked_alloc_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user