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