Struct aya::maps::stack_trace::StackTraceMap [−][src]
pub struct StackTraceMap<T> { /* fields omitted */ }
Expand description
A hash map of kernel or user space stack traces.
Stack trace maps can be used to store stack traces captured by eBPF programs, which can be
useful for profiling, to associate a trace to an event, etc. You can capture traces calling
stack_id = bpf_get_stackid(ctx, map, flags)
from eBPF, and then you can retrieve the traces
from their stack ids.
Examples
use aya::maps::StackTraceMap; use aya::util::kernel_symbols; use std::convert::TryFrom; let mut stack_traces = StackTraceMap::try_from(bpf.map("STACK_TRACES")?)?; // load kernel symbols from /proc/kallsyms let ksyms = kernel_symbols()?; // NOTE: you tipically send stack_ids from eBPF to user space using other maps let stack_id = 1234; let mut stack_trace = stack_traces.get(&stack_id, 0)?; // here we resolve symbol names using kernel symbols. If this was a user space stack (for // example captured from a uprobe), you'd have to load the symbols using some other mechanism // (eg loading the target binary debuginfo) for frame in stack_trace.resolve(&ksyms).frames() { println!( "{:#x} {}", frame.ip, frame .symbol_name .as_ref() .unwrap_or(&"[unknown symbol name]".to_owned()) ); }
Implementations
Returns the stack trace with the given stack_id.
Errors
Returns MapError::KeyNotFound
if there is no stack trace with the
given stack_id
, or MapError::SyscallError
if bpf_map_lookup_elem
fails.
An iterator visiting all (stack_id
, stack_trace
) pairs in arbitrary order. The
iterator item type is Result<(u32, StackTrace), MapError>
.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for StackTraceMap<T> where
T: RefUnwindSafe,
impl<T> Send for StackTraceMap<T> where
T: Send,
impl<T> Sync for StackTraceMap<T> where
T: Sync,
impl<T> Unpin for StackTraceMap<T> where
T: Unpin,
impl<T> UnwindSafe for StackTraceMap<T> where
T: UnwindSafe,