From: Yonghong Song <yhs@fb.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
<dwarves@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>, <bpf@vger.kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH dwarves v2 1/2] dwarf_loader: support typedef DW_TAG_LLVM_annotation
Date: Tue, 2 Nov 2021 16:35:05 -0700 [thread overview]
Message-ID: <20211102233505.1025198-1-yhs@fb.com> (raw)
In-Reply-To: <20211102233500.1024582-1-yhs@fb.com>
llvm commit ([1]) added support for btf_decl_tag attribute
with typedef declaration. Eventually, DW_TAG_LLVM_annotation
tag may appear inside dwarf typedef declaration tag.
kernel support for typedef BTF_KIND_DECL_TAG support
is introduced in [2]. There is no additional libbpf
change needed as the previous libbpf BTF_KIND_DECL_TAG
support is generic enough to cover new typedef use
cases.
This patch added parsing of DW_TAG_LLVM_annotation
for dwarf typedef decl.
$ cat t.c
$ clang -O2 -g -c t.c
$ llvm-dwarfdump --debug-info t.o
......
0x00000033: DW_TAG_typedef
DW_AT_type (0x00000051 "structure ")
DW_AT_name ("__t")
DW_AT_decl_file ("/home/yhs/t.c")
DW_AT_decl_line (3)
0x0000003e: DW_TAG_LLVM_annotation
DW_AT_name ("btf_decl_tag")
DW_AT_const_value ("tag1")
0x00000047: DW_TAG_LLVM_annotation
DW_AT_name ("btf_decl_tag")
DW_AT_const_value ("tag2")
0x00000050: NULL
Previously, pahole will issue a warning if typedef tag
contains any child tag. I removed this warning since
it is not true any more. Note that dwarf standard doesn't
prevent typedef decl tag from having nested tags.
In the future if we need to process any tag inside
typedef tag, we can just add code to process it.
[1] https://reviews.llvm.org/D110127
[2] https://lore.kernel.org/bpf/20211021195628.4018847-1-yhs@fb.com
Signed-off-by: Yonghong Song <yhs@fb.com>
---
dwarf_loader.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/dwarf_loader.c b/dwarf_loader.c
index c5bda81..f748bd7 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -1296,11 +1296,8 @@ static struct tag *die__create_new_typedef(Dwarf_Die *die, struct cu *cu, struct
if (tdef == NULL)
return NULL;
- if (dwarf_haschildren(die)) {
- struct dwarf_tag *dtag = tdef->namespace.tag.priv;
- fprintf(stderr, "%s: DW_TAG_typedef %llx WITH children!\n",
- __func__, (unsigned long long)dtag->id);
- }
+ if (add_child_llvm_annotations(die, -1, conf, &tdef->namespace.annots))
+ return NULL;
return &tdef->namespace.tag;
}
--
2.30.2
next prev parent reply other threads:[~2021-11-02 23:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-02 23:35 [PATCH dwarves v2 0/2] btf: support typedef DW_TAG_LLVM_annotation Yonghong Song
2021-11-02 23:35 ` Yonghong Song [this message]
2021-11-02 23:35 ` [PATCH dwarves v2 2/2] btf_encoder: generate BTF_KIND_DECL_TAGs for typedef btf_decl_tag attributes Yonghong Song
2021-11-03 0:11 ` [PATCH dwarves v2 0/2] btf: support typedef DW_TAG_LLVM_annotation Andrii Nakryiko
2021-11-10 5:23 ` Yonghong Song
2021-11-11 17:46 ` Arnaldo Carvalho de Melo
2021-11-11 18:07 ` Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211102233505.1025198-1-yhs@fb.com \
--to=yhs@fb.com \
--cc=andrii@kernel.org \
--cc=arnaldo.melo@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dwarves@vger.kernel.org \
--cc=kernel-team@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).