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>.

An iterator visiting all the stack_ids in arbitrary order. The iterator element type is Result<u32, MapError>.

Trait Implementations

Formats the value using the given formatter. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.