Skip to content

Libbpf eBPF function bpf_usdt_arg

v0.8.0

The bpf_usdt_arg function is used to get a USDT argument from the process.

Definition

__weak __hidden
int bpf_usdt_arg(struct pt_regs *ctx, __u64 arg_num, long *res)

Fetch USDT argument #arg_num (zero-indexed) and put its value into *res. Returns 0 on success; negative error, otherwise. On error *res is guaranteed to be set to zero.

Usage

The bpf_usdt_arg function extracts a USDT argument from the process. Unlike arguments to a function which follow an ABI, the arguments to a tracepoint can live anywhere in the process. The tracepoint describes them using GAS(GNU assembler) operands. This macro allows you to define your programs as these arguments were actually passed to the program like normal arguments.

This function uses specifiers that describe where to find a given argument. 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