public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Faust <david.faust@oracle.com>
To: gcc-patches@gcc.gnu.org
Cc: jose.marchesi@oracle.com, yhs@fb.com
Subject: [PATCH 9/9] testsuite: add debug annotation tests
Date: Tue,  7 Jun 2022 14:43:42 -0700	[thread overview]
Message-ID: <20220607214342.19463-10-david.faust@oracle.com> (raw)
In-Reply-To: <20220607214342.19463-1-david.faust@oracle.com>

This patch adds tests for debug annotations, in BTF and in DWARF.

gcc/testsuite/

	* gcc.dg/debug/btf/btf-decltag-func.c: New test.
	* gcc.dg/debug/btf/btf-decltag-sou.c: Likewise.
	* gcc.dg/debug/btf/btf-decltag-typedef.c: Likewise.
	* gcc.dg/debug/btf/btf-typetag-1.c: Likewise.
	* gcc.dg/debug/dwarf2/annotation-1.c: Likewise.
	* gcc.dg/debug/dwarf2/annotation-2.c: Likewise.
	* gcc.dg/debug/dwarf2/annotation-3.c: Likewise.
	* gcc.dg/debug/dwarf2/annotation-4.c: Likewise.
---
 .../gcc.dg/debug/btf/btf-decltag-func.c       | 18 ++++++++++
 .../gcc.dg/debug/btf/btf-decltag-sou.c        | 34 +++++++++++++++++++
 .../gcc.dg/debug/btf/btf-decltag-typedef.c    | 15 ++++++++
 .../gcc.dg/debug/btf/btf-typetag-1.c          | 20 +++++++++++
 .../gcc.dg/debug/dwarf2/annotation-1.c        | 20 +++++++++++
 .../gcc.dg/debug/dwarf2/annotation-2.c        | 17 ++++++++++
 .../gcc.dg/debug/dwarf2/annotation-3.c        | 20 +++++++++++
 .../gcc.dg/debug/dwarf2/annotation-4.c        | 34 +++++++++++++++++++
 8 files changed, 178 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-typedef.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-typetag-1.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-2.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-3.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-4.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..b2d6820cf23
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c
@@ -0,0 +1,18 @@
+
+/* { dg-do compile )  */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { 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 } } */
+
+#define __tag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __tag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __tag3 __attribute__((debug_annotate_decl("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);
+  }
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..bb125b53ce7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c
@@ -0,0 +1,34 @@
+
+/* { dg-do compile )  */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x11000000\[\t \]+\[^\n\]*btt_info" 16 } } */
+/* { 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" 6 } } */
+
+#define __tag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __tag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __tag3 __attribute__((debug_annotate_decl("decl-tag-3")))
+
+struct t {
+  int a;
+  long b __tag3;
+  char c __tag2 __tag3;
+} __tag1 __tag2;
+
+struct t my_t __tag1 __tag3;
+
+
+union u {
+  char one __tag1 __tag2;
+  short two;
+  int three __tag1;
+  long four __tag1 __tag2 __tag3;
+  long long five __tag2;
+} __tag3;
+
+union u my_u __tag2;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-typedef.c b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-typedef.c
new file mode 100644
index 00000000000..6a44aaf9623
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-decltag-typedef.c
@@ -0,0 +1,15 @@
+/* { dg-do compile )  */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x11000000\[\t \]+\[^\n\]*btt_info" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xffffffff\[\t \]+\[^\n\]*decltag_compidx" 3 } } */
+
+#define __tag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __tag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __tag3 __attribute__((debug_annotate_decl("decl-tag-3")))
+
+struct s { int a; } __tag1;
+
+typedef struct s * sptr __tag2;
+
+sptr my_sptr __tag3;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-typetag-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-typetag-1.c
new file mode 100644
index 00000000000..0d046265b7a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-typetag-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile )  */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x12000000\[\t \]+\[^\n\]*btt_info" 4 } } */
+
+#define __tag1 __attribute__((debug_annotate_type("tag1")))
+#define __tag2 __attribute__((debug_annotate_type("tag2")))
+#define __tag3 __attribute__((debug_annotate_type("tag3")))
+
+int __tag1 * x;
+const int __tag2 * y;
+
+struct a;
+
+struct b
+{
+  struct a __tag2 __tag3 * inner_a;
+};
+
+struct b my_b;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c
new file mode 100644
index 00000000000..f6f305c2739
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -dA" } */
+#define __decltag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __decltag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __decltag3 __attribute__((debug_annotate_decl("decl-tag-3")))
+
+struct S {
+  int a __decltag2 __decltag3;
+  int b __decltag1;
+} __decltag1 __decltag2;
+
+struct S my_S __decltag3;
+
+/* Verify that we get the expected DW_TAG_GNU_annotation DIEs for each tag.
+   Note: one more TAG in debug abbrev.  */
+/* { dg-final { scan-assembler-times " DW_TAG_GNU_annotation" 7 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"debug_annotate_decl\"" 6 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-1\"" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-2\"" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-3\"" 2 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-2.c
new file mode 100644
index 00000000000..04628fb1b81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-2.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -dA" } */
+#define __typetag1 __attribute__((debug_annotate_type("type-tag-1")))
+#define __typetag2 __attribute__((debug_annotate_type("type-tag-2")))
+#define __typetag3 __attribute__((debug_annotate_type("type-tag-3")))
+int __typetag1 * x;
+
+char * __typetag1 buf;
+
+int * __typetag1 * __typetag2 __typetag3 g;
+
+/* Verify we get the expected annotation dies. Note +1 TAG in debug abbrev.  */
+/* { dg-final { scan-assembler-times " DW_TAG_GNU_annotation" 6 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"debug_annotate_type\"" 5 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-1\"" 3 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-2\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-3\"" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-3.c
new file mode 100644
index 00000000000..0548cd52d6d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-3.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -dA" } */
+#define __decltag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __decltag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __decltag3 __attribute__((debug_annotate_decl("decl-tag-3")))
+
+extern int foo (char a, int b) __decltag1 __decltag3;
+
+int bar (int x)
+{
+  return foo ('a', x);
+}
+
+/* Verify that we get the expected DW_TAG_GNU_annotation DIEs for each tag.
+   Note: one more TAG in debug abbrev.  */
+/* { dg-final { scan-assembler-times " DW_TAG_GNU_annotation" 3 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"debug_annotate_decl\"" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-1\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-2\"" 0 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-3\"" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-4.c
new file mode 100644
index 00000000000..9d2b3ad5c00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-4.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -dA" } */
+#define __decltag1 __attribute__((debug_annotate_decl("decl-tag-1")))
+#define __decltag2 __attribute__((debug_annotate_decl("decl-tag-2")))
+#define __decltag3 __attribute__((debug_annotate_decl("decl-tag-3")))
+
+#define __typetag1 __attribute__((debug_annotate_type("type-tag-1")))
+#define __typetag2 __attribute__((debug_annotate_type("type-tag-2")))
+#define __typetag3 __attribute__((debug_annotate_type("type-tag-3")))
+
+/* Note the decl tags on these parameters will not be recorded... */
+
+extern int foo (int * __typetag1 x __decltag1,
+		char * __typetag3 c __decltag1 __decltag2);
+
+
+/* ... but here they will be.  */
+
+int bar (int * x __decltag1 __decltag3, char **buf __decltag2 __decltag3)
+{
+  return foo (x, buf[0]);
+}
+
+/* Verify that we get the expected DW_TAG_GNU_annotation DIEs for each tag.
+   Note: one more TAG in debug abbrev.  */
+/* { dg-final { scan-assembler-times " DW_TAG_GNU_annotation" 7 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"debug_annotate_decl\"" 4 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-1\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-2\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"decl-tag-3\"" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_name: \"debug_annotate_type\"" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-1\"" 1 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-2\"" 0 } } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value: \"type-tag-3\"" 1 } } */
-- 
2.36.1


  parent reply	other threads:[~2022-06-07 21:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 21:43 [PATCH 0/9] Add debug_annotate attributes David Faust
2022-06-07 21:43 ` [PATCH 1/9] dwarf: add dw_get_die_parent function David Faust
2022-06-13 10:13   ` Richard Biener
2022-06-07 21:43 ` [PATCH 2/9] include: Add new definitions David Faust
2022-06-07 21:43 ` [PATCH 3/9] c-family: Add debug_annotate attribute handlers David Faust
2022-06-07 21:43 ` [PATCH 4/9] dwarf: generate annotation DIEs David Faust
2022-06-07 21:43 ` [PATCH 5/9] ctfc: pass through debug annotations to BTF David Faust
2022-06-07 21:43 ` [PATCH 6/9] dwarf2ctf: convert annotation DIEs to CTF types David Faust
2022-06-07 21:43 ` [PATCH 7/9] btf: output decl_tag and type_tag records David Faust
2022-06-07 21:43 ` [PATCH 8/9] doc: document new attributes David Faust
2022-06-07 21:43 ` David Faust [this message]
2022-06-15  5:53 ` [PATCH 0/9] Add debug_annotate attributes Yonghong Song
2022-06-15 20:57   ` David Faust
2022-06-15 22:56     ` Yonghong Song
2022-06-17 17:18       ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} WAS: " Jose E. Marchesi
2022-06-20 17:06         ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type, decl} " Yonghong Song
2022-06-21 16:12           ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} " Jose E. Marchesi
2022-06-24 18:01             ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type, decl} " Yonghong Song
2022-07-07 20:24               ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} " Jose E. Marchesi
2022-07-13  4:23                 ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type, decl} " Yonghong Song
2022-07-14 15:09                   ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} " Jose E. Marchesi
2022-07-15  1:20                     ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type, decl} " Yonghong Song
2022-07-15 14:17                       ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} " Jose E. Marchesi
2022-07-15 16:48                         ` kernel sparse annotations vs. compiler attributes and debug_annotate_{type, decl} " Yonghong Song
2022-11-01 22:29       ` 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=20220607214342.19463-10-david.faust@oracle.com \
    --to=david.faust@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jose.marchesi@oracle.com \
    --cc=yhs@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 read-only IMAP folder(s) and NNTP newsgroup(s).