Libbpf userspace function bpf_program__attach_usdt
Is just like bpf_program__attach_uprobe_opts
except it covers USDT (User-space Statically Defined Tracepoint) attachment, instead of attaching to user-space function entry or exit.
Definition
struct bpf_link * bpf_program__attach_usdt(const struct bpf_program *prog, pid_t pid, const char *binary_path, const char *usdt_provider, const char *usdt_name, const struct bpf_usdt_opts *opts);
Parameters
prog
: BPF program to attachpid
: Process ID to attach the uprobe to,0
for self (own process),-1
for all processesbinary_path
: Path to binary that contains provided USDT probeusdt_provider
: USDT provider nameusdt_name
: USDT probe nameopts
: Options for altering program attachment
Return
Reference to the newly created BPF link; or NULL
is returned on error, error code is stored in errno
struct bpf_usdt_opts
struct bpf_usdt_opts {
/* size of this struct, for forward/backward compatibility */
size_t sz;
__u64 usdt_cookie;
size_t :0;
};
usdt_cookie
Custom user-provided value fetchable through bpf_get_attach_cookie
. This allows you to write one program, load it once, and then attach it to multiple perf events with different bpf_cookie
values, allowing the program to detect which event it is attached to.
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome