diff options
author | Eduard Zingerman <eddyz87@gmail.com> | 2023-03-15 01:04:13 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-03-28 11:57:58 -0300 |
commit | 40ebd8b9e3312d0a3c3949b98c05d5e7ede95e4a (patch) | |
tree | e9546d0c4d2c50d4e828daeae42e37157585d2c4 | |
parent | 4d17096076b2351fab2fec1f4084981414b07502 (diff) | |
download | pahole-40ebd8b9e3312d0a3c3949b98c05d5e7ede95e4a.tar.gz |
fprintf: Correct names for types with btf_type_tag attribute
The following example contains a structure field annotated with
btf_type_tag attribute:
#define __tag1 __attribute__((btf_type_tag("tag1")))
struct st {
int __tag1 *a;
} g;
It is not printed correctly by `pahole -F dwarf` command:
$ clang -g -c test.c -o test.o
pahole -F dwarf test.o
struct st {
tag1 * a; /* 0 8 */
...
};
Note the type for variable `a`: `tag1` is printed instead of `int`.
This commit teaches `type__fprintf()` and `__tag_name()` logic to skip
`DW_TAG_LLVM_annotation` objects that are used to encode type tags.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Faust <david.faust@oracle.com>
Cc: Jose Marchesi <jose.marchesi@oracle.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Link: https://lore.kernel.org/r/20230314230417.1507266-2-eddyz87@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves_fprintf.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index e8399e7b..1e6147a8 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -572,6 +572,7 @@ static const char *__tag__name(const struct tag *tag, const struct cu *cu, case DW_TAG_restrict_type: case DW_TAG_atomic_type: case DW_TAG_unspecified_type: + case DW_TAG_LLVM_annotation: type = cu__type(cu, tag->type); if (type == NULL && tag->type != 0) tag__id_not_found_snprintf(bf, len, tag->type); @@ -786,6 +787,10 @@ next_type: n = tag__has_type_loop(type, ptype, NULL, 0, fp); if (n) return printed + n; + if (ptype->tag == DW_TAG_LLVM_annotation) { + type = ptype; + goto next_type; + } if (ptype->tag == DW_TAG_subroutine_type) { printed += ftype__fprintf(tag__ftype(ptype), cu, name, 0, 1, @@ -880,6 +885,14 @@ print_modifier: { else printed += enumeration__fprintf(type, &tconf, fp); break; + case DW_TAG_LLVM_annotation: { + struct tag *ttype = cu__type(cu, type->type); + if (ttype) { + type = ttype; + goto next_type; + } + goto out_type_not_found; + } } out: if (type_expanded) |