|
|
@ -1,5 +1,5 @@
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
|
ffi::{c_int, c_void},
|
|
|
|
ffi::c_void,
|
|
|
|
io, mem,
|
|
|
|
io, mem,
|
|
|
|
os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
|
|
|
|
os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
|
|
|
|
ptr, slice,
|
|
|
|
ptr, slice,
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
|
|
|
perf_event_header, perf_event_mmap_page,
|
|
|
|
perf_event_header, perf_event_mmap_page,
|
|
|
|
perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE},
|
|
|
|
perf_event_type::{PERF_RECORD_LOST, PERF_RECORD_SAMPLE},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sys::{perf_event_ioctl, perf_event_open_bpf, SysResult},
|
|
|
|
sys::{mmap, perf_event_ioctl, perf_event_open_bpf, SysResult},
|
|
|
|
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
|
|
|
|
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -282,25 +282,6 @@ impl Drop for PerfBuffer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(test, allow(unused_variables))]
|
|
|
|
|
|
|
|
unsafe fn mmap(
|
|
|
|
|
|
|
|
addr: *mut c_void,
|
|
|
|
|
|
|
|
len: usize,
|
|
|
|
|
|
|
|
prot: c_int,
|
|
|
|
|
|
|
|
flags: c_int,
|
|
|
|
|
|
|
|
fd: BorrowedFd<'_>,
|
|
|
|
|
|
|
|
offset: libc::off_t,
|
|
|
|
|
|
|
|
) -> *mut c_void {
|
|
|
|
|
|
|
|
#[cfg(not(test))]
|
|
|
|
|
|
|
|
return libc::mmap(addr, len, prot, flags, fd.as_raw_fd(), offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
|
|
use crate::sys::TEST_MMAP_RET;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
|
|
TEST_MMAP_RET.with(|ret| *ret.borrow())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
#[repr(C)]
|
|
|
|
struct Sample {
|
|
|
|
struct Sample {
|
|
|
|