Struct redbpf::KProbe [−][src]
pub struct KProbe { /* fields omitted */ }
Expand description
Type to work with kprobes
or kretprobes
.
Implementations
Attach the kprobe
or kretprobe
.
Attach the probe to the function fn_name
inside the kernel. If offset
is given, the probe will be attached at that byte offset inside the
function.
Example
use redbpf::Module;
let mut module = Module::parse(&std::fs::read("file.elf").unwrap()).unwrap();
for kprobe in module.kprobes_mut() {
kprobe.attach_kprobe(&kprobe.name(), 0).unwrap();
}
Detach the kprobe
or kretprobe
This method is not needed to be called manually because all attachment
points are detached and closed automatically when KProbe
is
dropped. But this method provides a feature for detaching a bpf program
from kprobe event selectively.
Example
use redbpf::Module;
let mut module = Module::parse(&std::fs::read("file.elf").unwrap()).unwrap();
for kprobe in module.kprobes_mut() {
kprobe.attach_kprobe(&kprobe.name(), 0).unwrap();
// do some stuff...
kprobe.detach_kprobe(&kprobe.name(), 0).unwrap();
}
Auto Trait Implementations
impl RefUnwindSafe for KProbe
impl UnwindSafe for KProbe
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more