Commit 41258289 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann

bpftool: Print function linkage in BTF dump

Add printing out BTF_KIND_FUNC's linkage.
Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20200124054317.2459436-1-andriin@fb.com
parent 03506297
...@@ -77,6 +77,20 @@ static const char *btf_var_linkage_str(__u32 linkage) ...@@ -77,6 +77,20 @@ static const char *btf_var_linkage_str(__u32 linkage)
} }
} }
static const char *btf_func_linkage_str(const struct btf_type *t)
{
switch (btf_vlen(t)) {
case BTF_FUNC_STATIC:
return "static";
case BTF_FUNC_GLOBAL:
return "global";
case BTF_FUNC_EXTERN:
return "extern";
default:
return "(unknown)";
}
}
static const char *btf_str(const struct btf *btf, __u32 off) static const char *btf_str(const struct btf *btf, __u32 off)
{ {
if (!off) if (!off)
...@@ -231,12 +245,17 @@ static int dump_btf_type(const struct btf *btf, __u32 id, ...@@ -231,12 +245,17 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
printf(" fwd_kind=%s", fwd_kind); printf(" fwd_kind=%s", fwd_kind);
break; break;
} }
case BTF_KIND_FUNC: case BTF_KIND_FUNC: {
if (json_output) const char *linkage = btf_func_linkage_str(t);
if (json_output) {
jsonw_uint_field(w, "type_id", t->type); jsonw_uint_field(w, "type_id", t->type);
else jsonw_string_field(w, "linkage", linkage);
printf(" type_id=%u", t->type); } else {
printf(" type_id=%u linkage=%s", t->type, linkage);
}
break; break;
}
case BTF_KIND_FUNC_PROTO: { case BTF_KIND_FUNC_PROTO: {
const struct btf_param *p = (const void *)(t + 1); const struct btf_param *p = (const void *)(t + 1);
__u16 vlen = BTF_INFO_VLEN(t->info); __u16 vlen = BTF_INFO_VLEN(t->info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment