aya: small doc fixes

pull/1/head
Alessandro Decina 4 years ago
parent 79f1b385a5
commit 0b3e532d7a

@ -32,6 +32,7 @@ pub(crate) const PERF_EVENT_IOC_ENABLE: c_int = AYA_PERF_EVENT_IOC_ENABLE;
pub(crate) const PERF_EVENT_IOC_DISABLE: c_int = AYA_PERF_EVENT_IOC_DISABLE;
pub(crate) const PERF_EVENT_IOC_SET_BPF: c_int = AYA_PERF_EVENT_IOC_SET_BPF;
/// Marker trait for types that can safely be converted to and from byte slices.
pub unsafe trait Pod: Copy + 'static {}
macro_rules! unsafe_impl_pod {
@ -91,7 +92,7 @@ impl Bpf {
/// Load eBPF bytecode.
///
/// Parses the object code contained in `data` and initializes the [maps](crate::maps) defined
/// in it. If `target_btf` is `Some` and `data` includes BTF debug info, [BTF](Btf) relocations
/// in it. If `target_btf` is not `None` and `data` includes BTF debug info, [BTF](Btf) relocations
/// are applied as well.
///
/// # Examples

@ -32,11 +32,14 @@ use crate::{
/// let prog_2: &KProbe = bpf.program("example_prog_2")?.try_into()?;
///
/// let flags = 0;
///
/// // bpf_tail_call(JUMP_TABLE, 0) will jump to prog_0
/// prog_array.set(0, prog_0, flags);
/// // bpf_tail_call(JUMP_TABLE, 0) will jump to prog_1
///
/// // bpf_tail_call(JUMP_TABLE, 1) will jump to prog_1
/// prog_array.set(1, prog_1, flags);
/// // bpf_tail_call(JUMP_TABLE, 0) will jump to prog_2
///
/// // bpf_tail_call(JUMP_TABLE, 2) will jump to prog_2
/// prog_array.set(2, prog_2, flags);
/// # Ok::<(), aya::BpfError>(())
/// ```

@ -11,11 +11,9 @@ use crate::{
Pod,
};
/// A hash map stored inside the kernel, in which both user-space and eBPF programs can insert and
/// lookup values from.
/// A hash map that can be shared between eBPF programs and user space.
///
/// The types of the keys and values must be plain old data (POD), meaning that they
/// must be safely convertible to and from byte slices.
/// It is required that both keys and values implement the [`Pod`] trait.
///
/// # Example
///

@ -48,7 +48,7 @@ impl KProbe {
///
/// Attaches the probe to the given function name inside the kernel. If
/// `offset` is non-zero, it is added to the address of the target
/// function. If `pid` is `Some()`, the program executes only when the
/// function. If `pid` is not `None`, the program executes only when the
/// target function is triggered by the given `pid`.
///
/// If the program is a `kprobe`, it is attached to the *start* address of the target function.

@ -66,7 +66,7 @@ impl UProbe {
///
/// Attaches the uprobe to the function `fn_name` defined in the `target`.
/// If `offset` is non-zero, it is added to the address of the target
/// function. If `pid` is `Some()`, the program executes only when the target
/// function. If `pid` is not `None`, the program executes only when the target
/// function is executed by the given `pid`.
///
/// The `target` argument can be an absolute path to a binary or library, or

Loading…
Cancel
Save