linux/tools/bpf/bpftool/Documentation
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
..
bpftool-btf.rst bpftool: Introduce btf c dump sorting 2024-05-18 10:46:16 -07:00
bpftool-cgroup.rst bpftool: Update documentation where progs/maps can be passed by name 2024-04-16 17:58:25 +02:00
bpftool-feature.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-gen.rst bpftool: Clean-up typos, punctuation, list formatting in docs 2024-04-02 15:50:23 +02:00
bpftool-iter.rst bpftool: Clean-up typos, punctuation, list formatting in docs 2024-04-02 15:50:23 +02:00
bpftool-link.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-map.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-net.rst bpftool: Update documentation where progs/maps can be passed by name 2024-04-16 17:58:25 +02:00
bpftool-perf.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-prog.rst bpftool: Update documentation where progs/maps can be passed by name 2024-04-16 17:58:25 +02:00
bpftool-struct_ops.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool.rst bpftool: Use simpler indentation in source rST for documentation 2024-04-02 15:50:23 +02:00
common_options.rst bpftool: Use simpler indentation in source rST for documentation 2024-04-02 15:50:23 +02:00
Makefile bpftool: Use simpler indentation in source rST for documentation 2024-04-02 15:50:23 +02:00
substitutions.rst bpftool: remove support of --legacy option for bpftool 2022-11-20 16:17:46 -08:00