From: David Faust <david.faust@oracle.com>
To: gcc-patches@gcc.gnu.org
Cc: jose.marchesi@oracle.com, yhs@meta.com
Subject: [PATCH 8/9] testsuite: add tests for BTF decl tags
Date: Tue, 11 Jul 2023 14:57:15 -0700 [thread overview]
Message-ID: <20230711215716.12980-9-david.faust@oracle.com> (raw)
In-Reply-To: <20230711215716.12980-1-david.faust@oracle.com>
This patch adds tests for the btf_decl_tag attribute, in both DWARF
and BTF.
gcc/testsuite/
* gcc.dg/debug/btf/btf-decltag-func.c: New test.
* gcc.dg/debug/btf/btf-decltag-sou.c: New test.
* gcc.dg/debug/btf/btf-decltag-var.c: New test.
* gcc.dg/debug/dwarf2/annotation-decl-1.c: New test.
* gcc.dg/debug/dwarf2/annotation-decl-2.c: New test.
* gcc.dg/debug/dwarf2/annotation-decl-3.c: New test.
---
.../gcc.dg/debug/btf/btf-decltag-func.c | 21 ++++++++++++
.../gcc.dg/debug/btf/btf-decltag-sou.c | 33 +++++++++++++++++++
.../gcc.dg/debug/btf/btf-decltag-var.c | 19 +++++++++++
.../gcc.dg/debug/dwarf2/annotation-decl-1.c | 9 +++++
.../gcc.dg/debug/dwarf2/annotation-decl-2.c | 18 ++++++++++
.../gcc.dg/debug/dwarf2/annotation-decl-3.c | 17 ++++++++++
6 files changed, 117 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c
create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c
create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c
new file mode 100644
index 00000000000..12a5eff9ac7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+#define __tag1 __attribute__((btf_decl_tag("decl-tag-1")))
+#define __tag2 __attribute__((btf_decl_tag("decl-tag-2")))
+#define __tag3 __attribute__((btf_decl_tag("decl-tag-3")))
+
+extern int bar (int __tag1, int __tag2) __tag3;
+
+int __tag1 __tag2 foo (int arg1, int *arg2 __tag2)
+ {
+ return bar (arg1 + 1, *arg2 + 2);
+ }
+
+/* { dg-final { scan-assembler-times "\[\t \]0x11000000\[\t \]+\[^\n\]*btt_info" 4 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xffffffff\[\t \]+\[^\n\]*decltag_compidx" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*decltag_compidx" 1 } } */
+
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG 'decl-tag-1'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_FUNC" 1 } } */
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG 'decl-tag-2'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_FUNC" 2 } } */
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG 'decl-tag-3'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_FUNC" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c
new file mode 100644
index 00000000000..13c9f075b1e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c
@@ -0,0 +1,33 @@
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x11000000\[\t \]+\[^\n\]*btt_info" 13 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*decltag_compidx" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*decltag_compidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*decltag_compidx" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*decltag_compidx" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*decltag_compidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xffffffff\[\t \]+\[^\n\]*decltag_compidx" 3 } } */
+
+#define __tag1 __attribute__((btf_decl_tag("decl-tag-1")))
+#define __tag2 __attribute__((btf_decl_tag("decl-tag-2")))
+#define __tag3 __attribute__((btf_decl_tag("decl-tag-3")))
+
+struct t {
+ int a;
+ long b __tag3;
+ char c __tag2 __tag3;
+};
+
+struct t my_t __tag1 __tag2;
+
+union u {
+ char one __tag1 __tag2;
+ short two;
+ int three __tag1;
+ long four __tag1 __tag2 __tag3;
+ long long five __tag2;
+};
+
+union u my_u __tag3;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c
new file mode 100644
index 00000000000..563e8838f1a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+unsigned long u __attribute__((btf_decl_tag ("__u")));
+
+const int * c __attribute__((btf_decl_tag ("__c"), btf_decl_tag ("devicemem")));
+
+struct st
+{
+ int a;
+ char c;
+};
+
+struct st my_st __attribute__((btf_decl_tag ("__my_st")));
+
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG '__u'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_VAR 'u'" 1 } } */
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG '__c'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_VAR 'c'" 1 } } */
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG 'devicemem'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_VAR 'c'" 1 } } */
+/* { dg-final { scan-assembler-times " BTF_KIND_DECL_TAG '__my_st'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_VAR 'my_st'" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c
new file mode 100644
index 00000000000..d5af2188098
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c
@@ -0,0 +1,9 @@
+/* Test simple generation of decl tag annotations. */
+/* { dg-do compile } */
+/* { dg-options "-O0 -gdwarf -dA" } */
+
+int *p __attribute__((btf_decl_tag ("p_decl")));
+
+/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"p_decl\"" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c
new file mode 100644
index 00000000000..10f2dbc5def
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c
@@ -0,0 +1,18 @@
+/* Test generation of decl tag annotation DIEs for structs. */
+/* { dg-do compile } */
+/* { dg-options "-O0 -gdwarf -dA" } */
+
+struct st {
+ int a __attribute__((btf_decl_tag("__st_a")));
+ char b;
+ int *c __attribute__((btf_decl_tag("__st_c_1"), btf_decl_tag("__st_c_2")));
+};
+
+struct st my_st __attribute__((btf_decl_tag ("__my_st")));
+
+/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 4 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 4 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__st_a\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__st_c_1\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__st_c_2\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__my_st\"" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c
new file mode 100644
index 00000000000..e006548fa25
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c
@@ -0,0 +1,17 @@
+/* Test generation of decl tag annotation DIEs for functions and func args. */
+/* { dg-do compile } */
+/* { dg-options "-O0 -gdwarf -dA" } */
+
+extern int bar (int, int) __attribute__((btf_decl_tag ("__bar_func")));
+
+int __attribute__((btf_decl_tag ("__foo_func")))
+foo (int arg1, int *arg2 __attribute__((btf_decl_tag ("__foo_arg2"))))
+{
+ return bar (arg1 + 1, *arg2 + 2);
+}
+
+/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 3 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 3 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__foo_func\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__foo_arg2\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__bar_func\"" 1 } } */
--
2.40.1
next prev parent reply other threads:[~2023-07-11 21:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 21:57 [PATCH 0/9] Add btf_decl_tag C attribute David Faust
2023-07-11 21:57 ` [PATCH 1/9] c-family: add btf_decl_tag attribute David Faust
2023-07-11 21:57 ` [PATCH 2/9] include: add BTF decl tag defines David Faust
2023-07-11 21:57 ` [PATCH 3/9] dwarf: create annotation DIEs for decl tags David Faust
2023-07-11 21:57 ` [PATCH 4/9] dwarf: expose get_die_parent David Faust
2023-07-11 21:57 ` [PATCH 5/9] ctf: add support to pass through BTF tags David Faust
2023-07-11 21:57 ` [PATCH 6/9] dwarf2ctf: convert annotation DIEs to CTF types David Faust
2023-07-11 21:57 ` [PATCH 7/9] btf: create and output BTF_KIND_DECL_TAG types David Faust
2023-07-11 21:57 ` David Faust [this message]
2023-07-11 21:57 ` [PATCH 9/9] doc: document btf_decl_tag attribute David Faust
2023-07-12 7:38 ` [PATCH 0/9] Add btf_decl_tag C attribute Richard Biener
2023-07-12 12:43 ` Jose E. Marchesi
2023-07-12 13:21 ` Richard Biener
2023-07-12 13:49 ` Jose E. Marchesi
2023-07-12 19:33 ` David Faust
2023-07-24 15:56 ` David Faust
2023-08-09 21:05 ` [PING 2][PATCH " David Faust
2023-09-11 21:39 ` [PING][PATCH " David Faust
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=20230711215716.12980-9-david.faust@oracle.com \
--to=david.faust@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jose.marchesi@oracle.com \
--cc=yhs@meta.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 read-only IMAP folder(s) and NNTP newsgroup(s).