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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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