in reverie-ptrace/src/validation.rs [75:105]
fn init_perf_event_attr(
perf_attr_type: u32,
config: u64,
precise_ip: bool,
) -> perf::perf_event_attr {
let mut result = perf::perf_event_attr {
type_: perf_attr_type,
config,
..Default::default()
};
result.size = mem::size_of_val(&result) as u32;
result.set_exclude_guest(1);
result.set_exclude_kernel(1);
if precise_ip
&& CpuId::new()
.get_feature_info()
.map_or(false, |info| info.has_ds())
{
result.set_precise_ip(1);
// This prevents EINVAL when creating a counter with precise_ip enabled
result.__bindgen_anon_1.sample_period = PerfCounter::DISABLE_SAMPLE_PERIOD;
} else {
// This is the value used for the bug checks which are not originally designed to
// work with precise_ip
result.__bindgen_anon_1.sample_period = 0;
}
result
}