Add track_stability option to CalibrationStage (#781)
* add * Update gramatron.rs * Update emu.rs * try * clp
This commit is contained in:
parent
7f7e0ee6ac
commit
7aadf31246
@ -79,6 +79,7 @@ crate::impl_serdeany!(GramatronIdxMapMetadata);
|
||||
impl GramatronIdxMapMetadata {
|
||||
/// Creates a new [`struct@GramatronIdxMapMetadata`].
|
||||
#[must_use]
|
||||
#[allow(clippy::or_fun_call)]
|
||||
pub fn new(input: &GramatronInput) -> Self {
|
||||
let mut map = HashMap::default();
|
||||
for i in 0..input.terminals().len() {
|
||||
|
@ -73,6 +73,7 @@ where
|
||||
map_observer_name: String,
|
||||
map_name: String,
|
||||
stage_max: usize,
|
||||
track_stability: bool,
|
||||
phantom: PhantomData<(I, O, OT, S)>,
|
||||
}
|
||||
|
||||
@ -142,12 +143,13 @@ where
|
||||
.ok_or_else(|| Error::key_not_found("MapObserver not found".to_string()))?
|
||||
.to_vec();
|
||||
|
||||
let mut unstable_entries: Vec<usize> = vec![];
|
||||
let map_len: usize = map_first.len();
|
||||
// Run CAL_STAGE_START - 1 times, increase by 2 for every time a new
|
||||
// run is found to be unstable, with CAL_STAGE_MAX total runs.
|
||||
let mut i = 1;
|
||||
let mut has_errors = false;
|
||||
let mut unstable_entries: Vec<usize> = vec![];
|
||||
let map_len: usize = map_first.len();
|
||||
|
||||
while i < iter {
|
||||
let input = state
|
||||
.corpus()
|
||||
@ -182,6 +184,7 @@ where
|
||||
.observers_mut()
|
||||
.post_exec_all(state, &input, &exit_kind)?;
|
||||
|
||||
if self.track_stability {
|
||||
let map = &executor
|
||||
.observers()
|
||||
.match_name::<O>(&self.map_observer_name)
|
||||
@ -212,6 +215,7 @@ where
|
||||
if !unstable_entries.is_empty() && iter < CAL_STAGE_MAX {
|
||||
iter += 2;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
@ -302,6 +306,26 @@ where
|
||||
map_observer_name: map_feedback.observer_name().to_string(),
|
||||
map_name: map_feedback.name().to_string(),
|
||||
stage_max: CAL_STAGE_START,
|
||||
track_stability: true,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new [`CalibrationStage`], but without checking stability.
|
||||
#[must_use]
|
||||
pub fn ignore_stability<N, R>(map_feedback: &MapFeedback<I, N, O, R, S, O::Entry>) -> Self
|
||||
where
|
||||
O::Entry:
|
||||
PartialEq + Default + Copy + 'static + Serialize + serde::de::DeserializeOwned + Debug,
|
||||
R: Reducer<O::Entry>,
|
||||
for<'it> O: AsIter<'it, Item = O::Entry>,
|
||||
N: IsNovel<O::Entry>,
|
||||
{
|
||||
Self {
|
||||
map_observer_name: map_feedback.observer_name().to_string(),
|
||||
map_name: map_feedback.name().to_string(),
|
||||
stage_max: CAL_STAGE_START,
|
||||
track_stability: false,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -433,11 +433,7 @@ extern "C" fn gdb_cmd(buf: *const u8, len: usize, data: *const ()) -> i32 {
|
||||
let closure = &mut *(data as *mut Box<dyn for<'r> FnMut(&Emulator, &'r str) -> bool>);
|
||||
let cmd = std::str::from_utf8_unchecked(std::slice::from_raw_parts(buf, len));
|
||||
let emu = Emulator::new_empty();
|
||||
if closure(&emu, cmd) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
i32::from(closure(&emu, cmd))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user