Skip to content

Libbpf eBPF function bpf_usdt_cookie

v0.8.0

The bpf_usdt_cookie function returns the cookie associated with the attach point.

Definition

__weak __hidden
long bpf_usdt_cookie(struct pt_regs *ctx)

Retrieve user-specified cookie value provided during attach as bpf_usdt_opts.usdt_cookie. This serves the same purpose as BPF cookie returned by bpf_get_attach_cookie. Libbpf's support for USDT is itself utilizing BPF cookies internally, so user can't use BPF cookie directly for USDT programs and has to use bpf_usdt_cookie API instead.

Usage

This function uses specifiers that describe the tracepoint. These specifiers live in maps, defined in usdt.bpf.h which should be populated by the loader, in particular the bpf_program__attach_usdt function.

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome