From c52f6421f21146ad4eb8d1add796eda3ddda4ccf Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Mon, 25 Oct 2021 09:04:09 -0300 Subject: [PATCH] btf: Rename btf_tag to btf_decl_tag Kernel commit ([1]) renamed btf_tag to btf_decl_tag for uapi btf.h and libbpf api's. The reason is a new clang attribute, btf_type_tag, is introduced ([2]). Renaming btf_tag to btf_decl_tag makes it easier to distinghish from btf_type_tag. I also pulled in latest libbpf repo since it contains renamed libbpf api function btf__add_decl_tag(). [1] https://lore.kernel.org/bpf/20211012164838.3345699-1-yhs@fb.com/ [2] https://reviews.llvm.org/D111199 Signed-off-by: Yonghong Song [ Minor fixups to cope with --skip_missing ] Signed-off-by: Arnaldo Carvalho de Melo --- btf_encoder.c | 16 ++++++++-------- dwarf_loader.c | 6 +++--- dwarves.h | 2 +- lib/bpf | 2 +- pahole.c | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/btf_encoder.c b/btf_encoder.c index 16e90c3..40f6aa3 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -142,7 +142,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", + [BTF_KIND_DECL_TAG] = "DECL_TAG", }; static const char *btf__printable_name(const struct btf *btf, uint32_t offset) @@ -646,20 +646,20 @@ static int32_t btf_encoder__add_datasec(struct btf_encoder *encoder, const char return id; } -static int32_t btf_encoder__add_tag(struct btf_encoder *encoder, const char *value, uint32_t type, - int component_idx) +static int32_t btf_encoder__add_decl_tag(struct btf_encoder *encoder, const char *value, uint32_t type, + int component_idx) { struct btf *btf = encoder->btf; const struct btf_type *t; int32_t id; - id = btf__add_tag(btf, value, type, component_idx); + id = btf__add_decl_tag(btf, value, type, component_idx); if (id > 0) { t = btf__type_by_id(btf, id); btf_encoder__log_type(encoder, t, false, true, "type_id=%u component_idx=%d", t->type, component_idx); } else { - btf__log_err(btf, BTF_KIND_TAG, value, true, "component_idx=%d Error emitting BTF type", + btf__log_err(btf, BTF_KIND_DECL_TAG, value, true, "component_idx=%d Error emitting BTF type", component_idx); } @@ -1272,7 +1272,7 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder, struct } list_for_each_entry(annot, &var->annots, node) { - int tag_type_id = btf_encoder__add_tag(encoder, annot->value, id, annot->component_idx); + int tag_type_id = btf_encoder__add_decl_tag(encoder, annot->value, id, annot->component_idx); if (tag_type_id < 0) { fprintf(stderr, "error: failed to encode tag '%s' to variable '%s' with component_idx %d\n", annot->value, name, annot->component_idx); @@ -1445,7 +1445,7 @@ int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu) btf_type_id = type_id_off + core_id; ns = tag__namespace(pos); list_for_each_entry(annot, &ns->annots, node) { - tag_type_id = btf_encoder__add_tag(encoder, annot->value, btf_type_id, annot->component_idx); + tag_type_id = btf_encoder__add_decl_tag(encoder, annot->value, btf_type_id, annot->component_idx); if (tag_type_id < 0) { fprintf(stderr, "error: failed to encode tag '%s' to %s '%s' with component_idx %d\n", annot->value, pos->tag == DW_TAG_structure_type ? "struct" : "union", @@ -1497,7 +1497,7 @@ int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu) } list_for_each_entry(annot, &fn->annots, node) { - tag_type_id = btf_encoder__add_tag(encoder, annot->value, btf_fn_id, annot->component_idx); + tag_type_id = btf_encoder__add_decl_tag(encoder, annot->value, btf_fn_id, annot->component_idx); if (tag_type_id < 0) { fprintf(stderr, "error: failed to encode tag '%s' to func %s with component_idx %d\n", annot->value, name, annot->component_idx); diff --git a/dwarf_loader.c b/dwarf_loader.c index bed0019..c5bda81 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -867,12 +867,12 @@ static int add_llvm_annotation(Dwarf_Die *die, int component_idx, struct conf_lo struct llvm_annotation *annot; const char *name; - if (conf->skip_encoding_btf_tag) + if (conf->skip_encoding_btf_decl_tag) return 0; - /* Only handle btf_tag annotation for now. */ + /* Only handle btf_decl_tag annotation for now. */ name = attr_string(die, DW_AT_name, conf); - if (strcmp(name, "btf_tag") != 0) + if (strcmp(name, "btf_decl_tag") != 0) return 0; annot = zalloc(sizeof(*annot)); diff --git a/dwarves.h b/dwarves.h index a43e432..0bc24eb 100644 --- a/dwarves.h +++ b/dwarves.h @@ -61,7 +61,7 @@ struct conf_load { bool ignore_inline_expansions; bool ignore_labels; bool ptr_table_stats; - bool skip_encoding_btf_tag; + bool skip_encoding_btf_decl_tag; bool skip_missing; uint8_t hashtable_bits; uint8_t max_hashtable_bits; diff --git a/lib/bpf b/lib/bpf index 92c1e61..f05791d 160000 --- a/lib/bpf +++ b/lib/bpf @@ -1 +1 @@ -Subproject commit 92c1e61a605410b16d6330fdd4a7a4e03add86d4 +Subproject commit f05791d8cfcbbf9092b4099b9d011bb72e241ef8 diff --git a/pahole.c b/pahole.c index 68e3c8a..f402df0 100644 --- a/pahole.c +++ b/pahole.c @@ -1124,7 +1124,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version; #define ARGP_sort_output 328 #define ARGP_hashbits 329 #define ARGP_devel_stats 330 -#define ARGP_skip_encoding_btf_tag 331 +#define ARGP_skip_encoding_btf_decl_tag 331 #define ARGP_skip_missing 332 static const struct argp_option pahole__options[] = { @@ -1497,8 +1497,8 @@ static const struct argp_option pahole__options[] = { .doc = "Print internal data structures stats", }, { - .name = "skip_encoding_btf_tag", - .key = ARGP_skip_encoding_btf_tag, + .name = "skip_encoding_btf_decl_tag", + .key = ARGP_skip_encoding_btf_decl_tag, .doc = "Do not encode TAGs in BTF." }, { @@ -1654,8 +1654,8 @@ static error_t pahole__options_parser(int key, char *arg, conf_load.hashtable_bits = atoi(arg); break; case ARGP_devel_stats: conf_load.ptr_table_stats = true; break; - case ARGP_skip_encoding_btf_tag: - conf_load.skip_encoding_btf_tag = true; break; + case ARGP_skip_encoding_btf_decl_tag: + conf_load.skip_encoding_btf_decl_tag = true; break; case ARGP_skip_missing: conf_load.skip_missing = true; break; default: