Add DWARF5 variants of assembly scan tests that use DW_FORM_implicit_const

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.

gcc/testsuite/ChangeLog:

	* gcc.dg/debug/dwarf2/inline2.c: Add -gdwarf-2.
	* g++.dg/debug/dwarf2/inline-var-1.C: Likewise.
	* gcc.dg/debug/dwarf2/pr41445-5.c: Likewise.
	* gcc.dg/debug/dwarf2/pr41445-6.c: Likewise.
	* gcc.dg/debug/dwarf2/inline6.c: New variant with -gdwarf-5.
	* g++.dg/debug/dwarf2/inline-var-3.C: Likewise.
	* gcc.dg/debug/dwarf2/pr41445-7.c: Likewise.
	* gcc.dg/debug/dwarf2/pr41445-8.c: Likewise.
This commit is contained in:
Mark Wielaard 2020-08-23 16:21:08 +02:00
parent ee7aa7e7b9
commit 71e3d1970c
8 changed files with 131 additions and 4 deletions

View file

@ -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* } } }

View file

@ -0,0 +1,29 @@
// DWARF5 variant of inline-var-1.C
// { dg-do compile { target c++17 } }
// { dg-options "-O -gdwarf-5 -dA -gno-strict-dwarf -fno-eliminate-unused-debug-symbols" }
// { dg-require-weak "" }
// { 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* } } }
// { dg-final { scan-assembler-times " DW_AT_\[^\n\r]*linkage_name" 7 { xfail *-*-aix* } } }
inline int a;
struct S
{
static inline double b = 4.0;
static constexpr int c = 2;
static constexpr inline char d = 3;
} s;
template <int N>
inline int e = N;
int &f = e<2>;
template <int N>
struct T
{
static inline double g = 4.0;
static constexpr int h = 2;
static inline constexpr char i = 3;
};
T<5> t;

View file

@ -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:

View file

@ -0,0 +1,69 @@
/* DWARF5 variant of inline2.
Origin: PR debug/37801
Abstract instances (DW_TAG_subroutines having the DW_AT_inline attribute)
of second and first were having a DW_TAG_lexical_block DIE wrongly
representing the inlined calls to third (in second) and to
second (in first). At the same time, main didn't have children
DW_TAG_inlined_subroutine DIEs representing the inlined calls to
first, second and third.
The ideal goal here is to test that we have no superfluous
DW_TAG_lexical_block DIE anymore, that abstract instances DIEs have
no descendant DIE with a DW_AT_abstract_origin attribute, and that main has
properly nested DW_TAG_inlined_subroutine DIEs for third, second and first.
*/
/* 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:
- One for each subroutine inlined into main, that's 3.
- One for earch subroutine inline into the out of line instances
of third, second and first. */
/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 6 } } */
/* We should have no DW_TAG_lexical_block DIEs, all inline instances
should have the first subblock elided to match the abstract instance
layout. */
/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */
/* 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 " DW_AT_inline \\(0x3\\)" 3 } } */
volatile int *a;
inline void
third (int arg3)
{
int var3 = arg3;
a[0] = var3;
}
inline void
second (int arg2)
{
int var2 = arg2;
third (var2+1);
}
inline void
first (int arg1)
{
int var1 = arg1;
second (var1+1);
}
int
main ()
{
int some_int = 1;
first (some_int);
return 0;
}

View file

@ -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)

View file

@ -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"

View file

@ -0,0 +1,16 @@
/* 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-5 -O0 -dA -fno-merge-debug-strings" } */
#define A(x) vari x
#define vari(x)
#define B , varj
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\]*\[^\\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)\\)" } } */

View file

@ -0,0 +1,11 @@
/* PR preprocessor/41445 DWARF5 variant*/
/* { dg-do compile } */
/* { 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\]*\[^\\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)\\)" } } */