提交 afb9fb5e 编写于 作者: I Ilya Leoshkevich 提交者: Zheng Zengkai

tools/bpftool: Add BTF_KIND_FLOAT support

mainline inclusion
from mainline-5.13-rc1
commit 737e0f91
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5Q927
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=737e0f919a8d2a313618d8ac67d50e8223bc5d74

-------------------------------------------------

Only dumping support needs to be adjusted, the code structure follows
that of BTF_KIND_INT. Example plain and JSON outputs:

    [4] FLOAT 'float' size=4
    {"id":4,"kind":"FLOAT","name":"float","size":4}
Signed-off-by: NIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Acked-by: NYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210226202256.116518-5-iii@linux.ibm.com
(cherry picked from commit 737e0f91)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>

Conflicts:
	tools/bpf/bpftool/btf.c
上级 a0d76b8d
...@@ -36,6 +36,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { ...@@ -36,6 +36,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
[BTF_KIND_FUNC_PROTO] = "FUNC_PROTO", [BTF_KIND_FUNC_PROTO] = "FUNC_PROTO",
[BTF_KIND_VAR] = "VAR", [BTF_KIND_VAR] = "VAR",
[BTF_KIND_DATASEC] = "DATASEC", [BTF_KIND_DATASEC] = "DATASEC",
[BTF_KIND_FLOAT] = "FLOAT",
[BTF_KIND_DECL_TAG] = "DECL_TAG", [BTF_KIND_DECL_TAG] = "DECL_TAG",
[BTF_KIND_TYPE_TAG] = "TYPE_TAG", [BTF_KIND_TYPE_TAG] = "TYPE_TAG",
}; };
...@@ -330,6 +331,13 @@ static int dump_btf_type(const struct btf *btf, __u32 id, ...@@ -330,6 +331,13 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
jsonw_end_array(w); jsonw_end_array(w);
break; break;
} }
case BTF_KIND_FLOAT: {
if (json_output)
jsonw_uint_field(w, "size", t->size);
else
printf(" size=%u", t->size);
break;
}
case BTF_KIND_DECL_TAG: { case BTF_KIND_DECL_TAG: {
const struct btf_decl_tag *tag = (const void *)(t + 1); const struct btf_decl_tag *tag = (const void *)(t + 1);
......
...@@ -598,6 +598,7 @@ static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id, ...@@ -598,6 +598,7 @@ static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id,
switch (BTF_INFO_KIND(t->info)) { switch (BTF_INFO_KIND(t->info)) {
case BTF_KIND_INT: case BTF_KIND_INT:
case BTF_KIND_TYPEDEF: case BTF_KIND_TYPEDEF:
case BTF_KIND_FLOAT:
BTF_PRINT_ARG("%s ", btf__name_by_offset(btf, t->name_off)); BTF_PRINT_ARG("%s ", btf__name_by_offset(btf, t->name_off));
break; break;
case BTF_KIND_STRUCT: case BTF_KIND_STRUCT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册