Functional detach of debugfs probes.

pull/108/head
Dan Everton 3 years ago
parent a4faabcf93
commit 42c9737d47
No known key found for this signature in database
GPG Key ID: 2AF33A2B189A11B3

@ -42,6 +42,24 @@ impl Drop for PerfLink {
} }
pub(crate) fn perf_attach(data: &mut ProgramData, fd: RawFd) -> Result<LinkRef, ProgramError> { pub(crate) fn perf_attach(data: &mut ProgramData, fd: RawFd) -> Result<LinkRef, ProgramError> {
perf_attach_either(data, fd, None, None)
}
pub(crate) fn perf_attach_debugfs(
data: &mut ProgramData,
fd: RawFd,
probe_kind: ProbeKind,
event_alias: String,
) -> Result<LinkRef, ProgramError> {
perf_attach_either(data, fd, Some(probe_kind), Some(event_alias))
}
fn perf_attach_either(
data: &mut ProgramData,
fd: RawFd,
probe_kind: Option<ProbeKind>,
event_alias: Option<String>,
) -> Result<LinkRef, ProgramError> {
let prog_fd = data.fd_or_err()?; let prog_fd = data.fd_or_err()?;
perf_event_ioctl(fd, PERF_EVENT_IOC_SET_BPF, prog_fd).map_err(|(_, io_error)| { perf_event_ioctl(fd, PERF_EVENT_IOC_SET_BPF, prog_fd).map_err(|(_, io_error)| {
ProgramError::SyscallError { ProgramError::SyscallError {
@ -58,22 +76,7 @@ pub(crate) fn perf_attach(data: &mut ProgramData, fd: RawFd) -> Result<LinkRef,
Ok(data.link(PerfLink { Ok(data.link(PerfLink {
perf_fd: Some(fd), perf_fd: Some(fd),
probe_kind: None, probe_kind,
event_alias: None, event_alias,
}))
}
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),
probe_kind: Some(probe_kind),
event_alias: Some(event_alias),
})) }))
} }

@ -234,8 +234,10 @@ fn delete_in_sys_kernel_debug_tracing_events(
.open(events_file_name) .open(events_file_name)
.map_err(|e| (events_file_name.to_string(), e))?; .map_err(|e| (events_file_name.to_string(), e))?;
let rm = format!("-:{}", event_alias);
events_file events_file
.write_fmt(format_args!("-:{}", event_alias)) .write_all(rm.as_bytes())
.map_err(|e| (events_file_name.to_string(), e))?; .map_err(|e| (events_file_name.to_string(), e))?;
Ok(()) Ok(())

Loading…
Cancel
Save