[PATCH bpf-next 4/9] bpftool: add support for BTF_KIND_TAG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



added bpftool support to dump BTF_KIND_TAG information.
The new bpftool will be used in later patches to dump
btf in the test bpf program object file.

Signed-off-by: Yonghong Song <yhs@xxxxxx>
---
 tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index f7e5ff3586c9..89c17ea62d8e 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
 	[BTF_KIND_VAR]		= "VAR",
 	[BTF_KIND_DATASEC]	= "DATASEC",
 	[BTF_KIND_FLOAT]	= "FLOAT",
+	[BTF_KIND_TAG]		= "TAG",
 };
 
 struct btf_attach_table {
@@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
 			printf(" size=%u", t->size);
 		break;
 	}
+	case BTF_KIND_TAG: {
+		const struct btf_tag *tag = (const void *)(t + 1);
+
+
+		if (json_output) {
+			jsonw_uint_field(w, "type_id", t->type);
+			if (btf_kflag(t))
+				jsonw_int_field(w, "comp_id", -1);
+			else
+				jsonw_uint_field(w, "comp_id", tag->comp_id);
+		} else if (btf_kflag(t)) {
+			printf(" type_id=%u, comp_id=-1", t->type);
+		} else {
+			printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id);
+		}
+		break;
+	}
 	default:
 		break;
 	}
-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux