-
need to get user stack and transfer to user-space code. found none BPF_MAP_TYPE_STACK_TRACE examples. any one has some examples? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Okay, got it working for me now, so here's an outline of how to use ebpf kernel spaceDefine a map of type typedef u64 stack[100];
struct {
__uint(type, BPF_MAP_TYPE_STACK_TRACE);
__type(key, u32);
__type(value, stack);
__uint(max_entries, 1 << 14);
} stacks SEC(".maps"); You'll probably want to have some To collect a stack backtrace, simply call user spaceSay, in user space you got a ips := make([]uint64, 100)
err := objs.Stacks.Lookup(event.Stackid, ips) If there was no error, then |
Beta Was this translation helpful? Give feedback.
Okay, got it working for me now, so here's an outline of how to use
BPF_MAP_TYPE_STACK_TRACE
, for the benefit of others coming to this question.ebpf kernel space
Define a map of type
BPF_MAP_TYPE_STACK_TRACE
, with the key being au32
we later get frombpf_get_stackid()
, and the value being a fixed-size array ofu64
(the instruction pointers, or "ips"):You'll probably want to have some
BPF_MAP_TYPE_RINGBUF
for sending events to user space with some event-specific data and including au32
as the stack ID/key …