bpftool: Display ref_ctr_offset for uprobe link info
authorJiri Olsa <jolsa@kernel.org>
Fri, 9 May 2025 15:35:39 +0000 (17:35 +0200)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 9 May 2025 20:01:08 +0000 (13:01 -0700)
Adding support to display ref_ctr_offset in link output, like:

  # bpftool link
  ...
  42: perf_event  prog 174
          uprobe /proc/self/exe+0x102f13  cookie 3735928559  ref_ctr_offset 0x303a3fa
          bpf_cookie 3735928559
          pids test_progs(1820)

  # bpftool link -j | jq
  [
    ...
    {
      "id": 42,
       ...
      "ref_ctr_offset": 50500538,
    }
  ]

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250509153539.779599-4-jolsa@kernel.org
tools/bpf/bpftool/link.c

index 52fd2c9..3535afc 100644 (file)
@@ -380,6 +380,7 @@ show_perf_event_uprobe_json(struct bpf_link_info *info, json_writer_t *wtr)
                           u64_to_ptr(info->perf_event.uprobe.file_name));
        jsonw_uint_field(wtr, "offset", info->perf_event.uprobe.offset);
        jsonw_uint_field(wtr, "cookie", info->perf_event.uprobe.cookie);
+       jsonw_uint_field(wtr, "ref_ctr_offset", info->perf_event.uprobe.ref_ctr_offset);
 }
 
 static void
@@ -823,6 +824,8 @@ static void show_perf_event_uprobe_plain(struct bpf_link_info *info)
        printf("%s+%#x  ", buf, info->perf_event.uprobe.offset);
        if (info->perf_event.uprobe.cookie)
                printf("cookie %llu  ", info->perf_event.uprobe.cookie);
+       if (info->perf_event.uprobe.ref_ctr_offset)
+               printf("ref_ctr_offset 0x%llx  ", info->perf_event.uprobe.ref_ctr_offset);
 }
 
 static void show_perf_event_tracepoint_plain(struct bpf_link_info *info)