From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7824) id 89E8D3853809; Fri, 7 Oct 2022 18:34:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89E8D3853809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665167696; bh=wbT5Z2x464hIkCzoPA4jLmEN6xp3wEM1weNPZG55+4I=; h=From:To:Subject:Date:From; b=eEQnhmrkOzNs518Rd9S5GMiBzbFV+17Lc3TLBFGDD9odTpa6AWk3dP0jUb/ggS3mr t3oPfjbi0AQ8KI45mP1C6h4/UCm8GJyt7tiqL/9cZIrx0Wtwd9o/aofGXoVROb+gEY TNUz2Yq3biajXSdpilxy8dzZnaow/q1NtFj8b8No= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: David Faust To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/dfaust/heads/btf-type-tag-new-rebase)] testsuite: Add tests for BTF tags X-Act-Checkin: gcc X-Git-Author: David Faust X-Git-Refname: refs/users/dfaust/heads/btf-type-tag-new-rebase X-Git-Oldrev: 1affad2e1f5a2d7a9c5cbc970ca252140465273c X-Git-Newrev: 976ee6b4b945769e21c015b71a2f3d7ee53b5912 Message-Id: <20221007183456.89E8D3853809@sourceware.org> Date: Fri, 7 Oct 2022 18:34:56 +0000 (GMT) List-Id: https://gcc.gnu.org/g:976ee6b4b945769e21c015b71a2f3d7ee53b5912 commit 976ee6b4b945769e21c015b71a2f3d7ee53b5912 Author: David Faust Date: Wed Mar 2 15:14:41 2022 -0800 testsuite: Add tests for BTF tags This commit adds tests for the tags, in BTF and in DWARF. gcc/teststuite/ * 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. Diff: --- gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c | 18 ++++++++++++ gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c | 34 ++++++++++++++++++++++ .../gcc.dg/debug/btf/btf-decltag-typedef.c | 15 ++++++++++ gcc/testsuite/gcc.dg/debug/btf/btf-typetag-1.c | 20 +++++++++++++ gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c | 29 ++++++++++++++++++ 5 files changed, 116 insertions(+) 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..aa2c31aaa32 --- /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__((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); + } 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..be89d0d32de --- /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__((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; +} __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..75be876f949 --- /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__((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 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..4b05663385f --- /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__((btf_type_tag("tag1"))) +#define __tag2 __attribute__((btf_type_tag("tag2"))) +#define __tag3 __attribute__((btf_type_tag("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..543cf771f92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/annotation-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-gbtf -gdwarf -dA" } */ +#define __typetag1 __attribute__((btf_type_tag("type-tag-1"))) +#define __typetag2 __attribute__((btf_type_tag("type-tag-2"))) +#define __typetag3 __attribute__((btf_type_tag("type-tag-3"))) + +#define __decltag1 __attribute__((btf_decl_tag("decl-tag-1"))) +#define __decltag2 __attribute__((btf_decl_tag("decl-tag-2"))) +#define __decltag3 __attribute__((btf_decl_tag("decl-tag-3"))) + +struct S { + int a __decltag2 __decltag3; + int b __decltag1; +} __decltag1 __decltag2; + +struct S my_S __decltag3; + +long __typetag1 __typetag2 * 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" 9 } } */ +/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 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 } } */ +/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 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\"" 1 } } */