diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/debug')
4 files changed, 148 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c b/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c new file mode 100644 index 0000000..3f19559 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c @@ -0,0 +1,61 @@ +/* Test that -gprune-btf does not prune at typedefs.  */ + +/* { dg-do compile } */ +/* { dg-options "-gbtf -gprune-btf -dA" } */ + +/* We must have the full definitions of td1 and td3.  Neither are pruned. +   td2 will be skipped entirely, only because the only reference to +   it is through struct inner, which is pruned because inner itself +   is only used as a pointer member. + +   In general, we must never get an anonymous FWD; the only FWD in this +   case will be for 'inner' */ + +/* Exactly 1 FWD for inner and no anonymous FWD.  */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_FWD" 1 } } */ +/* { dg-final { scan-assembler-not   "TYPE \[0-9\]+ BTF_KIND_FWD ''" } } */ +/* { dg-final { scan-assembler       " BTF_KIND_FWD 'inner'" } } */ + +/* One anonymous struct for td1 and one anonymous union for td3.  */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_STRUCT ''" 1 } } */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_UNION ''" 1 } } */ + +/* The two remaining typedefs.  */ +/* { dg-final { scan-assembler " BTF_KIND_TYPEDEF 'td1'" } } */ +/* { dg-final { scan-assembler " BTF_KIND_TYPEDEF 'td3'" } } */ + +typedef struct { +  int x; +  char c; +} td1; + +typedef struct { +  long l; +  char b[4]; +} td2; + +typedef union { +  long l; +  unsigned short s[2]; +} td3; + +struct inner { +  char a; +  td2 *ptd; +  long z; +}; + +struct A { +  td1 *pt; +  struct inner *in; +  unsigned long l[4]; +}; + +struct A foo; + +struct B { +  int x; +  td3 **ppptd3; +}; + +struct B bar; diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c new file mode 100644 index 0000000..6fdcdc6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c @@ -0,0 +1,28 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple +   times with different decl_tags.  PR122248.  */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) +#define __tag4 __attribute__((btf_decl_tag ("tag4"))) + +int foo __tag1; +int foo __tag2; + +/* Result: foo has __tag1 and __tag2.  */ + +int bar __tag3; +int bar; + +/* Result: bar has __tag3.  */ + +int baz; +int baz __tag4; + +/* Result: baz has __tag4.  */ + +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 4 } } */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 4 } } */ + diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c new file mode 100644 index 0000000..c7cb60c --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c @@ -0,0 +1,35 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple +   times with different decl_tags.  PR122248.  */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) + +struct S +{ +  int x; +  char c; +}; + +extern struct S foo __tag1; +struct S foo __tag2; + +/* Result: non-completing variable DIE for 'foo' has tag1, and the +   completing DIE (with AT_specification) for 'foo' has tag2 -> tag1.  */ + +extern int a __tag3; +int a; + +/* Result: non-completing variable DIE for a has tag3, and the +   completing DIE (with AT_specification) for 'a' also refers to tag3.  */ + +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 3 } } */ + +/* 5 AT_GNU annotations: +   - foo -> tag1 +   - foo -> tag2 -> tag1 +   - a -> tag3 +   - a -> tag3 */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 5 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c new file mode 100644 index 0000000..dd89d11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c @@ -0,0 +1,24 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple +   times with different decl_tags.  PR122248.  */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) + +__tag1 +extern int +do_thing (int); + +__tag2 +__tag3 +int +do_thing (int x) +{ +  return x * x; +} + +/* Result: do_thing has all 3 tags.  */ +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 3 } } */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 3 } } */  | 
