|
|
|
@ -2,8 +2,9 @@ use libc::close;
|
|
|
|
|
use std::os::unix::io::RawFd;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
sys::perf_event_ioctl, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, PERF_EVENT_IOC_SET_BPF,
|
|
|
|
|
programs::ProbeKind, programs::probe::detach_debug_fs
|
|
|
|
|
programs::{probe::detach_debug_fs, ProbeKind},
|
|
|
|
|
sys::perf_event_ioctl,
|
|
|
|
|
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, PERF_EVENT_IOC_SET_BPF,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use super::{Link, LinkRef, ProgramData, ProgramError};
|
|
|
|
@ -62,20 +63,13 @@ pub(crate) fn perf_attach(data: &mut ProgramData, fd: RawFd) -> Result<LinkRef,
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn perf_attach_debugfs(data: &mut ProgramData, fd: RawFd, probe_kind: ProbeKind, event_alias: String) -> Result<LinkRef, ProgramError> {
|
|
|
|
|
let prog_fd = data.fd_or_err()?;
|
|
|
|
|
perf_event_ioctl(fd, PERF_EVENT_IOC_SET_BPF, prog_fd).map_err(|(_, io_error)| {
|
|
|
|
|
ProgramError::SyscallError {
|
|
|
|
|
call: "PERF_EVENT_IOC_SET_BPF".to_owned(),
|
|
|
|
|
io_error,
|
|
|
|
|
}
|
|
|
|
|
})?;
|
|
|
|
|
perf_event_ioctl(fd, PERF_EVENT_IOC_ENABLE, 0).map_err(|(_, io_error)| {
|
|
|
|
|
ProgramError::SyscallError {
|
|
|
|
|
call: "PERF_EVENT_IOC_ENABLE".to_owned(),
|
|
|
|
|
io_error,
|
|
|
|
|
}
|
|
|
|
|
})?;
|
|
|
|
|
pub(crate) fn perf_attach_debugfs(
|
|
|
|
|
data: &mut ProgramData,
|
|
|
|
|
fd: RawFd,
|
|
|
|
|
probe_kind: ProbeKind,
|
|
|
|
|
event_alias: String,
|
|
|
|
|
) -> Result<LinkRef, ProgramError> {
|
|
|
|
|
perf_attach(data, fd)?;
|
|
|
|
|
|
|
|
|
|
Ok(data.link(PerfLink {
|
|
|
|
|
perf_fd: Some(fd),
|
|
|
|
|