• Andrii Nakryiko's avatar
    bpftool: add ability to dump BTF types · c93cc690
    Andrii Nakryiko authored
    Add new `btf dump` sub-command to bpftool. It allows to dump
    human-readable low-level BTF types representation of BTF types. BTF can
    be retrieved from few different sources:
      - from BTF object by ID;
      - from PROG, if it has associated BTF;
      - from MAP, if it has associated BTF data; it's possible to narrow
        down types to either key type, value type, both, or all BTF types;
      - from ELF file (.BTF section).
    
    Output format mostly follows BPF verifier log format with few notable
    exceptions:
      - all the type/field/param/etc names are enclosed in single quotes to
        allow easier grepping and to stand out a little bit more;
      - FUNC_PROTO output follows STRUCT/UNION/ENUM format of having one
        line per each argument; this is more uniform and allows easy
        grepping, as opposed to succinct, but inconvenient format that BPF
        verifier log is using.
    
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Alexei Starovoitov <ast@fb.com>
    Cc: Yonghong Song <yhs@fb.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Acked-by: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    c93cc690
main.c 7.47 KB