libbpf: Add some details for BTF parsing failures
authorIan Rogers <irogers@google.com>
Thu, 25 Jan 2024 23:18:40 +0000 (15:18 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 30 Jan 2024 00:42:42 +0000 (16:42 -0800)
commitf2e4040c82d3fddd11fa7c64e8f810e6f9cb7460
treef413ae5bdb8800f9612a875e827cc811bd3639b9
parentaecaa3ed48c3ae74c06f5e8ef0746b69c62397f1
libbpf: Add some details for BTF parsing failures

As CONFIG_DEBUG_INFO_BTF is default off the existing "failed to find
valid kernel BTF" message makes diagnosing the kernel build issue somewhat
cryptic. Add a little more detail with the hope of helping users.

Before:
```
libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3
```

After not accessible:
```
libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled?
libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3
```

After not readable:
```
libbpf: failed to read kernel BTF from (/sys/kernel/btf/vmlinux): -1
```

Closes: https://lore.kernel.org/bpf/CAP-5=fU+DN_+Y=Y4gtELUsJxKNDDCOvJzPHvjUVaUoeFAzNnig@mail.gmail.com/
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240125231840.1647951-1-irogers@google.com
tools/lib/bpf/btf.c