On Mon, Aug 24, 2020 at 02:56:56PM +0200, Mark Wielaard wrote: > Some DWARF tests scan the assembly output looking for constant values. > When using DWARF5 those constants might use DW_FORM_implicit_const, > which are output (in the comments) after the attribute instead of > before. To make sure these tests work introduce a -gdwarf-5 variant > of these tests and explicitly use -gdwarf-2 for the original.
I just wonder if we want to use -gdwarf-2 rather than -gdwarf-4 in the original, -gdwarf-5 has been the default for a couple of years and thus that is what those testshave been compiled with. Also not sure about the -dwarf5 suffixes, couldn't we say just use pr41445-{7,8}.c, inline-var-2.C or inline3.c (or whatever next number with the same prefix is still unused)? > --- > .../dwarf2/{inline-var-1.C => inline-var-1-dwarf5.C} | 6 ++++-- > gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C | 2 +- > .../gcc.dg/debug/dwarf2/{inline2.c => inline2-dwarf5.c} | 7 ++++--- > gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c | 4 +++- > .../debug/dwarf2/{pr41445-5.c => pr41445-5-dwarf5.c} | 8 ++++---- > gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c | 2 +- > .../debug/dwarf2/{pr41445-6.c => pr41445-6-dwarf5.c} | 8 ++++---- > gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c | 2 +- > 8 files changed, 22 insertions(+), 17 deletions(-) > copy gcc/testsuite/g++.dg/debug/dwarf2/{inline-var-1.C => > inline-var-1-dwarf5.C} (76%) > copy gcc/testsuite/gcc.dg/debug/dwarf2/{inline2.c => inline2-dwarf5.c} (88%) > copy gcc/testsuite/gcc.dg/debug/dwarf2/{pr41445-5.c => pr41445-5-dwarf5.c} > (73%) > copy gcc/testsuite/gcc.dg/debug/dwarf2/{pr41445-6.c => pr41445-6-dwarf5.c} > (68%) > > diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1-dwarf5.C > similarity index 76% > copy from gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > copy to gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1-dwarf5.C > index 3b1c913edfca..52ed5b6912fd 100644 > --- a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > +++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1-dwarf5.C > @@ -1,7 +1,9 @@ > +// DWARF5 variant of inline-var-1.C > // { dg-do compile { target c++17 } } > -// { dg-options "-O -g -dA -gno-strict-dwarf > -fno-eliminate-unused-debug-symbols" } > +// { dg-options "-O -gdwarf-5 -dA -gno-strict-dwarf > -fno-eliminate-unused-debug-symbols" } > // { dg-require-weak "" } > -// { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 6 { xfail > *-*-aix* } } } > +// { dg-final { scan-assembler-times " DW_AT_inline \\(0x3\\)" 2 { xfail > *-*-aix* } } } > +// { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 4 { xfail > *-*-aix* } } } > // { dg-final { scan-assembler-times "0x1\[^\n\r]* DW_AT_inline" 2 { xfail > *-*-aix* } } } > // { dg-final { scan-assembler-times " DW_AT_declaration" 6 { xfail *-*-aix* > } } } > // { dg-final { scan-assembler-times " DW_AT_specification" 6 { xfail > *-*-aix* } } } > diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > index 3b1c913edfca..9a88e28cbe0f 100644 > --- a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > +++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C > @@ -1,5 +1,5 @@ > // { dg-do compile { target c++17 } } > -// { dg-options "-O -g -dA -gno-strict-dwarf > -fno-eliminate-unused-debug-symbols" } > +// { dg-options "-O -gdwarf-2 -dA -gno-strict-dwarf > -fno-eliminate-unused-debug-symbols" } > // { dg-require-weak "" } > // { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 6 { xfail > *-*-aix* } } } > // { dg-final { scan-assembler-times "0x1\[^\n\r]* DW_AT_inline" 2 { xfail > *-*-aix* } } } > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2-dwarf5.c > similarity index 88% > copy from gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > copy to gcc/testsuite/gcc.dg/debug/dwarf2/inline2-dwarf5.c > index 7e019a6c06a0..03013f11bca8 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2-dwarf5.c > @@ -1,4 +1,4 @@ > -/* Contributed by Dodji Seketeli <do...@redhat.com> > +/* DWARF5 variant of inline2. > Origin: PR debug/37801 > > Abstract instances (DW_TAG_subroutines having the DW_AT_inline attribute) > @@ -14,7 +14,8 @@ > properly nested DW_TAG_inlined_subroutine DIEs for third, second and first. > */ > > -/* { dg-options "-O -g3 -gdwarf -dA -fgnu89-inline" } */ > +/* Explicitly use dwarf-5 which uses DW_FORM_implicit_const. */ > +/* { dg-options "-O -g3 -gdwarf-5 -dA -fgnu89-inline" } */ > /* { dg-do compile } */ > > /* There are 6 inlined subroutines: > @@ -32,7 +33,7 @@ > /* There are 3 DW_AT_inline attributes: one per abstract inline instance. > The value of the attribute must be 0x3, meaning the function was > actually inlined. */ > -/* { dg-final { scan-assembler-times "(?:byte|data1)\[^\n\]*0x3\[^\n\]* > DW_AT_inline" 3 } } */ > +/* { dg-final { scan-assembler-times " DW_AT_inline \\(0x3\\)" 3 } } */ > > volatile int *a; > > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > index 7e019a6c06a0..9c36450ae2de 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c > @@ -14,7 +14,9 @@ > properly nested DW_TAG_inlined_subroutine DIEs for third, second and first. > */ > > -/* { dg-options "-O -g3 -gdwarf -dA -fgnu89-inline" } */ > +/* Explicitly use dwarf-2 because dwarf-5 might use DW_FORM_implicit_const > + which is hard to scan for. */ > +/* { dg-options "-O -g3 -gdwarf-2 -dA -fgnu89-inline" } */ > /* { dg-do compile } */ > > /* There are 6 inlined subroutines: > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5-dwarf5.c > similarity index 73% > copy from gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > copy to gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5-dwarf5.c > index d646f5983b30..0e0de822d806 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5-dwarf5.c > @@ -1,8 +1,8 @@ > -/* PR preprocessor/41445 */ > +/* PR preprocessor/41445 DWARF5 variant */ > /* Test that token after multi-line function-like macro use > gets correct locus even when preprocessing separately. */ > /* { dg-do compile } */ > -/* { dg-options "-save-temps -gdwarf -O0 -dA -fno-merge-debug-strings" } */ > +/* { dg-options "-save-temps -gdwarf-5 -O0 -dA -fno-merge-debug-strings" } */ > > #define A(x) vari x > #define vari(x) > @@ -12,5 +12,5 @@ int A(B) ; > /* We want to check that both vari and varj have the same line > number. */ > > -/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" > } } */ > -/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" > } } */ > +/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line > \\((0xa|10)\\)" } } */ > +/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line > \\((0xa|10)\\)" } } */ > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > index d646f5983b30..80300ec22e87 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c > @@ -2,7 +2,7 @@ > /* Test that token after multi-line function-like macro use > gets correct locus even when preprocessing separately. */ > /* { dg-do compile } */ > -/* { dg-options "-save-temps -gdwarf -O0 -dA -fno-merge-debug-strings" } */ > +/* { dg-options "-save-temps -gdwarf-2 -O0 -dA -fno-merge-debug-strings" } */ > > #define A(x) vari x > #define vari(x) > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6-dwarf5.c > similarity index 68% > copy from gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > copy to gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6-dwarf5.c > index 340cb3835307..3a6eeb530968 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6-dwarf5.c > @@ -1,11 +1,11 @@ > -/* PR preprocessor/41445 */ > +/* PR preprocessor/41445 DWARF5 variant*/ > /* { dg-do compile } */ > -/* { dg-options "-gdwarf -O0 -dA -fno-merge-debug-strings" } */ > +/* { dg-options "-gdwarf-5 -O0 -dA -fno-merge-debug-strings" } */ > > #include "pr41445-5.c" > > /* We want to check that both vari and varj have the same line > number. */ > > -/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)?\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" > } } */ > -/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" > } } */ > +/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line > \\((0xa|10)\\)" } } */ > +/* { dg-final { scan-assembler > "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line > \\((0xa|10)\\)" } } */ > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > index 340cb3835307..fbf033758b6b 100644 > --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c > @@ -1,6 +1,6 @@ > /* PR preprocessor/41445 */ > /* { dg-do compile } */ > -/* { dg-options "-gdwarf -O0 -dA -fno-merge-debug-strings" } */ > +/* { dg-options "-gdwarf-2 -O0 -dA -fno-merge-debug-strings" } */ > > #include "pr41445-5.c" > > -- > 2.18.4 Jakub