pub struct Tracepoint { /* private fields */ }Expand description
Kernel tracepoint event.
Tracepoints allow you to dynamically insert breakpoints into specific hook points defined by the kernel. These can be used to count function executions or to attach eBPF programs that run during those breakpoints.
Tracepoints are similar to kprobes. The difference, however, is that tracepoints are stable and documented. On the other hand, kprobes can be inserted (almost) anywhere within the kernel whereas tracepoints are restricted to only the locations at which they have been defined.
Note that it is possible to create tracepoints from kprobes by using
perf probe.
Implementations§
Source§impl Tracepoint
impl Tracepoint
Sourcepub fn with_id(id: u64) -> Self
pub fn with_id(id: u64) -> Self
Create a tracepoint directly from its raw ID.
Usually you will have to look within debugfs to get this ID.
with_name is a helper to do this by looking
up the event ID in the debugfs instance mounted at /sys/kernel/debug.
Sourcepub fn with_name(name: impl AsRef<Path>) -> Result<Self>
pub fn with_name(name: impl AsRef<Path>) -> Result<Self>
Create a tracepoint by looking up its ID within /sys/kernel/debug.
Event names are listed under /sys/kernel/debug/tracing/events. All
this method does is read the file at
/sys/kernel/debug/tracing/events/<name>/id and use the contents of the
id file as the tracepoint id.
Note that /sys/kernel/debug is only accessible if running as root or
if the process has CAP_SYS_ADMIN.
§Example
Create a tracepoint event for the sched_switch tracepoint.
let tracepoint = Tracepoint::with_name("sched/sched_switch")?;Trait Implementations§
Source§impl Clone for Tracepoint
impl Clone for Tracepoint
Source§fn clone(&self) -> Tracepoint
fn clone(&self) -> Tracepoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Tracepoint
Source§impl Debug for Tracepoint
impl Debug for Tracepoint
Source§impl Event for Tracepoint
impl Event for Tracepoint
Source§fn update_attrs(self, attr: &mut perf_event_attr)
fn update_attrs(self, attr: &mut perf_event_attr)
perf_event_attr struct so that it will record the
requested event. Read moreSource§fn update_attrs_with_data(
self,
attr: &mut perf_event_attr,
) -> Option<Arc<dyn EventData>>
fn update_attrs_with_data( self, attr: &mut perf_event_attr, ) -> Option<Arc<dyn EventData>>
perf_event_attr struct so that it will record the
requested event. Read more