pub struct UProbe(/* private fields */);Expand description
User-space probe event.
Uprobes allow you to dynamically insert tracepoints within user-space processes. This allows you to gather metrics on how many times a function is called (e.g. malloc) or attach eBPF programs to run when the tracepoint is triggered.
There are two types of kprobes:
uprobes trigger when the relevant function is called (or, potentially, executed at an offset within that function).uretprobes trigger just before the relevant function returns.
To create a uprobe you will need to provide both a path to a binary and the offset within that binary at which you want to insert the probe. Discovering the offset that corresponds to a given function is up to you.
Implementations§
Source§impl UProbe
impl UProbe
Sourcepub fn new(retprobe: bool, path: CString, offset: u64) -> Result<Self>
pub fn new(retprobe: bool, path: CString, offset: u64) -> Result<Self>
Create a new uprobe from a path string and offset.
§Errors
This will attempt to read the kprobe PMU type from
/sys/bus/event_source. It will return an error if the uprobe PMU is
not available or the filesystem exposed by the kernel there is otherwise
unparseable.
Sourcepub fn probe(path: impl AsRef<Path>, offset: u64) -> Result<Self>
pub fn probe(path: impl AsRef<Path>, offset: u64) -> Result<Self>
Create a new uprobe from a path and an offset within that file.
§Errors
This will attempt to read the kprobe PMU type from
/sys/bus/event_source. It will return an error if the uprobe PMU is
not available or the filesystem exposed by the kernel there is otherwise
unparseable.
Sourcepub fn retprobe(path: impl AsRef<Path>, offset: u64) -> Result<Self>
pub fn retprobe(path: impl AsRef<Path>, offset: u64) -> Result<Self>
Create a new uretprobe from a path and an offset within that file.
§Errors
This will attempt to read the kprobe PMU type from
/sys/bus/event_source. It will return an error if the uprobe PMU is
not available or the filesystem exposed by the kernel there is otherwise
unparseable.