mirror of https://github.com/aya-rs/aya
bpf: add support for tracepoint program (#29)
This patch add initial support for tracepoint program type. Hope you enjoy. Signed-off-by: Tw <wei.tan@intel.com>pull/31/head
parent
d996a88de4
commit
55ba0538f2
@ -0,0 +1,22 @@
|
|||||||
|
use crate::{helpers::bpf_probe_read, BpfContext};
|
||||||
|
use core::ffi::c_void;
|
||||||
|
|
||||||
|
pub struct TracePointContext {
|
||||||
|
ctx: *mut c_void,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TracePointContext {
|
||||||
|
pub fn new(ctx: *mut c_void) -> TracePointContext {
|
||||||
|
TracePointContext { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn read_at<T>(&self, offset: usize) -> Result<T, i64> {
|
||||||
|
bpf_probe_read(self.ctx.add(offset) as *const T)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BpfContext for TracePointContext {
|
||||||
|
fn as_ptr(&self) -> *mut c_void {
|
||||||
|
self.ctx
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue