2023-10-25 21:25 UTC+0100 ~ Jiri Olsa > Adding support to display details for uprobe_multi links, > both plain: > > # bpftool link -p > ... > 24: uprobe_multi prog 126 > uprobe.multi path /home/jolsa/bpf/test_progs func_cnt 3 pid 4143 > offset ref_ctr_offset cookies > 0xd1f88 0xf5d5a8 0xdead > 0xd1f8f 0xf5d5aa 0xbeef > 0xd1f96 0xf5d5ac 0xcafe > > and json: > > # bpftool link -p | jq > [{ > ... > },{ > "id": 24, > "type": "uprobe_multi", > "prog_id": 126, > "retprobe": false, > "path": "/home/jolsa/bpf/test_progs", > "func_cnt": 3, > "pid": 4143, > "funcs": [{ > "offset": 860040, > "ref_ctr_offset": 16111016, > "cookie": 57005 > },{ > "offset": 860047, > "ref_ctr_offset": 16111018, > "cookie": 48879 > },{ > "offset": 860054, > "ref_ctr_offset": 16111020, > "cookie": 51966 > } > ] > } > ] > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > --- > tools/bpf/bpftool/link.c | 102 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 100 insertions(+), 2 deletions(-) > > diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c > index a1528cde81ab..21c7e4f038c4 100644 > --- a/tools/bpf/bpftool/link.c > +++ b/tools/bpf/bpftool/link.c > @@ -889,6 +952,39 @@ static int do_show_link(int fd) > goto again; > } > } > + if (info.type == BPF_LINK_TYPE_UPROBE_MULTI && > + !info.uprobe_multi.offsets) { > + count = info.uprobe_multi.count; > + if (count) { > + offsets = calloc(count, sizeof(__u64)); > + if (!offsets) { > + p_err("mem alloc failed"); > + close(fd); > + return -ENOMEM; > + } > + info.uprobe_multi.offsets = ptr_to_u64(offsets); > + ref_ctr_offsets = calloc(count, sizeof(__u64)); > + if (!ref_ctr_offsets) { > + p_err("mem alloc failed"); > + free(offsets); > + close(fd); > + return -ENOMEM; > + } > + info.uprobe_multi.ref_ctr_offsets = ptr_to_u64(ref_ctr_offsets); > + cookies = calloc(count, sizeof(__u64)); > + if (!cookies) { > + p_err("mem alloc failed"); > + free(cookies); > + free(offsets); > + close(fd); > + return -ENOMEM; > + } > + info.uprobe_multi.cookies = ptr_to_u64(cookies); > + info.uprobe_multi.path = ptr_to_u64(path_buf); > + info.uprobe_multi.path_max = sizeof(path_buf); It seems we're not using "info.uprobe_multi.path_max" after setting it, although there's no harm in retrieving the value so OK. Reviewed-by: Quentin Monnet <quentin@xxxxxxxxxxxxx>