Skip to content

Libbpf userspace function bpf_program__attach_usdt

0.8.0

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 attach
  • pid: Process ID to attach the uprobe to, 0 for self (own process), -1 for all processes
  • binary_path: Path to binary that contains provided USDT probe
  • usdt_provider: USDT provider name
  • usdt_name: USDT probe name
  • opts: 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;
};

0.8.0

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