aya-ebpf 0.2.1

A library for writing eBPF programs
Documentation
use aya_ebpf_bindings::bindings::PERF_MAX_STACK_DEPTH;

use crate::{
    bindings::bpf_map_type::BPF_MAP_TYPE_STACK_TRACE,
    maps::{MapDef, PinningType},
};

#[repr(transparent)]
pub struct StackTrace {
    def: MapDef,
}

impl super::private::Map for StackTrace {
    type Key = u32;
    type Value = [u64; PERF_MAX_STACK_DEPTH as usize];
}

impl StackTrace {
    map_constructors!(
        u32,
        [u64; PERF_MAX_STACK_DEPTH as usize],
        BPF_MAP_TYPE_STACK_TRACE
    );
}

impl crate::programs::tracing::sealed::StackTraceMap for StackTrace {
    fn as_ptr(&self) -> *mut core::ffi::c_void {
        self.def.as_ptr().cast()
    }
}