Struct redbpf::UProbe [−][src]
pub struct UProbe { /* fields omitted */ }
Expand description
Type to work with uprobes
or uretprobes
.
Implementations
Attach the uprobe
or uretprobe
.
Attach the probe to the function fn_name
defined in the library or
binary at path
. If an offset
is given, the probe will be attached at
that byte offset inside the function. If fn_name
is None
, then
offset
is treated as an absolute address.
If a pid
is passed, only the corresponding process is traced.
Example
use redbpf::Module;
let mut module = Module::parse(&std::fs::read("file.elf").unwrap()).unwrap();
for uprobe in module.uprobes_mut() {
uprobe.attach_uprobe(Some(&uprobe.name()), 0, "/lib/x86_64-linux-gnu/libc-2.30.so", None).unwrap();
}
Detach the uprobe
or uretprobe
This method is not needed to be called manually because all attachment
points are detached and closed automatically when UProbe
is
dropped. But this method provides a feature for detaching a bpf program
from uprobe event selectively.
Example
use redbpf::Module;
let mut module = Module::parse(&std::fs::read("file.elf").unwrap()).unwrap();
let uprobe = module.uprobe_mut("count_strlen").expect("bpf program not found");
uprobe.attach_uprobe(Some(&uprobe.name()), 0, "/lib/x86_64-linux-gnu/libc-2.30.so", None).unwrap();
// do some stuff...
uprobe.detach_uprobe(Some(&uprobe.name()), 0, "/lib/x86_64-linux-gnu/libc-2.30.so", None);
Auto Trait Implementations
impl RefUnwindSafe for UProbe
impl UnwindSafe for UProbe
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