kernel-hacking-2024-linux-s.../tools/bpf/bpftool
Mykyta Yatsenko 94133cf24b bpftool: Introduce btf c dump sorting
Sort bpftool c dump output; aiming to simplify vmlinux.h diffing and
forcing more natural type definitions ordering.

Definitions are sorted first by their BTF kind ranks, then by their base
type name and by their own name.

Type ranks

Assign ranks to btf kinds (defined in function btf_type_rank) to set
next order:
1. Anonymous enums/enums64
2. Named enums/enums64
3. Trivial types typedefs (ints, then floats)
4. Structs/Unions
5. Function prototypes
6. Forward declarations

Type rank is set to maximum for unnamed reference types, structs and
unions to avoid emitting those types early. They will be emitted as
part of the type chain starting with named type.

Lexicographical ordering

Each type is assigned a sort_name and own_name.
sort_name is the resolved name of the final base type for reference
types (typedef, pointer, array etc). Sorting by sort_name allows to
group typedefs of the same base type. sort_name for non-reference type
is the same as own_name. own_name is a direct name of particular type,
is used as final sorting step.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240514131221.20585-1-yatsenko@meta.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2024-05-18 10:46:16 -07:00
..
bash-completion bpftool: Introduce btf c dump sorting 2024-05-18 10:46:16 -07:00
Documentation bpftool: Introduce btf c dump sorting 2024-05-18 10:46:16 -07:00
skeleton bpftool: Fix missing pids during link show 2024-03-14 13:37:43 -07:00
.gitignore
btf.c bpftool: Introduce btf c dump sorting 2024-05-18 10:46:16 -07:00
btf_dumper.c
cfg.c
cfg.h
cgroup.c
common.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
feature.c bpf: improve error message for unsupported helper 2024-03-28 18:30:53 -07:00
gen.c bpftool: Use __typeof__() instead of typeof() in BPF skeleton 2024-04-02 16:20:49 +02:00
iter.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
jit_disasm.c
json_writer.c
json_writer.h
link.c bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP 2024-04-10 19:52:25 -07:00
main.c
main.h bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
Makefile bpftool, selftests/hid/bpf: Fix 29 clang warnings 2024-05-06 14:39:36 -07:00
map.c
map_perf_ring.c
net.c
netlink_dumper.c
netlink_dumper.h
perf.c
pids.c bpftool: Enable libbpf logs when loading pid_iter in debug mode 2024-03-19 23:12:22 -07:00
prog.c bpftool: Fix typo in error message 2024-04-12 18:19:09 +02:00
struct_ops.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
tracelog.c
xlated_dumper.c
xlated_dumper.h