bpftool: Use bpf_obj_get_info_by_fd directly
authorDave Marchevsky <davemarchevsky@fb.com>
Mon, 1 Nov 2021 22:43:55 +0000 (15:43 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 3 Nov 2021 18:25:32 +0000 (11:25 -0700)
commitc59765cfd193382b00454b1a4424cb78d4c065e2
treec08e469e99d51288789eedaf3e2400f4663de90a
parent60f270753960291895cdd07d360c4e09c56c4596
bpftool: Use bpf_obj_get_info_by_fd directly

To prepare for impending deprecation of libbpf's
bpf_program__get_prog_info_linear, migrate uses of this function to use
bpf_obj_get_info_by_fd.

Since the profile_target_name and dump_prog_id_as_func_ptr helpers were
only looking at the first func_info, avoid grabbing the rest to save a
malloc. For do_dump, add a more full-featured helper, but avoid
free/realloc of buffer when possible for multi-prog dumps.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20211101224357.2651181-3-davemarchevsky@fb.com
tools/bpf/bpftool/btf_dumper.c
tools/bpf/bpftool/prog.c