Re: [PATCH] libbpf: Add friendly error prompt for missing .BTF section

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 25, 2022 at 10:54 PM Tianyi Liu <i.pear@xxxxxxxxxxx> wrote:
>
> Fresh users usually forget to turn on BTF generating flags compiling
> kernels, and will receive a confusing error "No such file or directory"
> (from return value ENOENT) with command "bpftool btf dump file vmlinux".
>
> Hope this can help them find the mistake.
>
> Signed-off-by: Tianyi Liu <i.pear@xxxxxxxxxxx>
> ---
>  tools/lib/bpf/btf.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 2d14f1a52..9fbae1f3d 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -990,6 +990,8 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
>         err = 0;
>
>         if (!btf_data) {
> +               pr_warn("Failed to get section %s from ELF %s, check CONFIG_DEBUG_INFO_BTF if compiling kernel\n",
> +                       BTF_ELF_SEC, path);

This is going to be very confusing for any user trying to load BTF
from some other ELF file. If we want to add such helpful suggestion
(and even then it's a bit of a hit and miss, as not every passed in
file is supposed to be vmlinux kernel image), it should be done in
bpftool proper.

>                 err = -ENOENT;
>                 goto done;
>         }
> --
> 2.37.3
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux