On Tue Sep 1, 2026 at 9:57 AM PDT, Alan Maguire wrote:
> In raw mode ensure we can dump new BTF kinds in normal/json format.
>
> Signed-off-by: Alan Maguire <[email protected]>
> ---
>  tools/bpf/bpftool/btf.c | 85 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)
>
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index bca0a3982f09..4d8991c99b48 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -51,6 +51,9 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
>       [BTF_KIND_DECL_TAG]     = "DECL_TAG",
>       [BTF_KIND_TYPE_TAG]     = "TYPE_TAG",
>       [BTF_KIND_ENUM64]       = "ENUM64",
> +     [BTF_KIND_LOC_PARAM]    = "LOC_PARAM",
> +     [BTF_KIND_LOC_PROTO]    = "LOC_PROTO",
> +     [BTF_KIND_LOCSEC]       = "LOCSEC",
>  };
>  
>  struct sort_datum {
> @@ -415,6 +418,88 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
>               }
>               break;
>       }
> +     case BTF_KIND_LOC_PARAM: {
> +             const struct btf_loc_param *p = btf_loc_param(t);
> +             __u32 *v = (__u32 *)(p + 1);
> +             __u32 i, vlen = btf_vlen(t);
> +
> +             if (json_output) {
> +                     jsonw_uint_field(w, "size", t->size);
> +                     jsonw_uint_field(w, "flags", p->flags);
> +                     jsonw_uint_field(w, "vlen", vlen);
> +                     jsonw_name(w, "values");
> +                     jsonw_start_array(w);
> +             } else {
> +                     printf(" size=%u flags=0x%x vlen=%u", t->size, 
> p->flags, vlen);
> +             }
> +             for (i = 0; i < vlen; i++, v++) {
> +                     if (json_output) {
> +                             jsonw_start_object(w);
> +                             jsonw_uint_field(w, "value", *v);
> +                             jsonw_end_object(w);
> +                     } else {
> +                             printf("\n\t value=%u", *v);
> +                     }

raw dump into json is fine, but please switch
to pretty-print normal output that humans can read.
Print function name, argument name and registers/stack where args are held.

Reply via email to