Skip to content

libbpf: add raw BTF type dumping

Andrii Nakryiko bpf netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4libbpf: make btf_dump work with modifiable BTFtools/lib/bpf/btf.c tools/lib/bpf/btf_dump.c tools/lib/bpf/libbpf_internal.h+65 -220 replies
2/4libbpf: add raw dumping of BTF typestools/lib/bpf/btf.h tools/lib/bpf/btf_dump.c tools/lib/bpf/libbpf.map+176 -00 replies
3/4selftests/bpf: add checking of raw type dump in BTF writer APIs selfteststools/testing/selftests/bpf/prog_tests/btf_write.c+64 -30 replies
4/4selftests/bpf: test "incremental" btf_dump in C formattools/testing/selftests/bpf/prog_tests/btf_dump.c+105 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/4] libbpf: add raw BTF type dumping

Add btf_dump__dump_type_raw() API that emits human-readable low-level BTF type information, same as bpftool output. bpftool is not switched to this API because bpftool still needs to perform all the same BTF type processing logic to do JSON output, so benefits are pretty much zero.

Raw BTF type output is extremely useful when debugging issues with BTF. It's also handy to be able to do that in selftests. Raw BTF type output doesn't hide any information like BTF-to-C conversion might (e.g., not emitting BTF_KIND_FUNC, BTF_KIND_VAR and BTF_KIND_DATASEC), so is the most robust way to look at BTF data without going all the way to deciphering binary BTF info.

Also, now that BTF can be extended with write APIs, teach btf_dump to work with such modifiable BTFs, including the BTF-to-C convertion APIs. A self-test to validate such incremental BTF-to-C conversion is added in patch #4.

Andrii Nakryiko (4):
libbpf: make btf_dump work with modifiable BTF
libbpf: add raw dumping of BTF types
selftests/bpf: add checking of raw type dump in BTF writer APIs
selftests
selftests/bpf: test "incremental" btf_dump in C format

 tools/lib/bpf/btf.c                           |  17 ++
 tools/lib/bpf/btf.h                           |   1 +
 tools/lib/bpf/btf_dump.c                      | 243 ++++++++++++++++--
 tools/lib/bpf/libbpf.map                      |   1 +
 tools/lib/bpf/libbpf_internal.h               |   1 +
 .../selftests/bpf/prog_tests/btf_dump.c       | 105 ++++++++
 .../selftests/bpf/prog_tests/btf_write.c      |  67 ++++-
 7 files changed, 410 insertions(+), 25 deletions(-)
Signature · 1 line
2.24.1