|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
//! Kernel space probes.
|
|
|
|
|
use libc::pid_t;
|
|
|
|
|
use std::io;
|
|
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
|
@ -33,7 +32,7 @@ use crate::{
|
|
|
|
|
///
|
|
|
|
|
/// let program: &mut KProbe = bpf.program_mut("intercept_wakeups")?.try_into()?;
|
|
|
|
|
/// program.load()?;
|
|
|
|
|
/// program.attach("try_to_wake_up", 0, None)?;
|
|
|
|
|
/// program.attach("try_to_wake_up", 0)?;
|
|
|
|
|
/// # Ok::<(), aya::BpfError>(())
|
|
|
|
|
/// ```
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
@ -66,19 +65,13 @@ impl KProbe {
|
|
|
|
|
///
|
|
|
|
|
/// Attaches the probe to the given function name inside the kernel. If
|
|
|
|
|
/// `offset` is non-zero, it is added to the address of the target
|
|
|
|
|
/// function. If `pid` is not `None`, the program executes only when the
|
|
|
|
|
/// target function is triggered by the given `pid`.
|
|
|
|
|
/// function.
|
|
|
|
|
///
|
|
|
|
|
/// If the program is a `kprobe`, it is attached to the *start* address of the target function.
|
|
|
|
|
/// Conversely if the program is a `kretprobe`, it is attached to the return address of the
|
|
|
|
|
/// target function.
|
|
|
|
|
pub fn attach(
|
|
|
|
|
&mut self,
|
|
|
|
|
fn_name: &str,
|
|
|
|
|
offset: u64,
|
|
|
|
|
pid: Option<pid_t>,
|
|
|
|
|
) -> Result<LinkRef, ProgramError> {
|
|
|
|
|
attach(&mut self.data, self.kind, fn_name, offset, pid)
|
|
|
|
|
pub fn attach(&mut self, fn_name: &str, offset: u64) -> Result<LinkRef, ProgramError> {
|
|
|
|
|
attach(&mut self.data, self.kind, fn_name, offset, None)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|