[gdb/testsuite] Fix FAILs due to PR gcc/101452
authorTom de Vries <tdevries@suse.de>
Wed, 21 Jul 2021 12:19:51 +0000 (14:19 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 21 Jul 2021 12:19:51 +0000 (14:19 +0200)
commit8f5d31b8d1f80fd9fff4cef4acc4491a0d83fbed
tree2a1753443ecec5d67967192782ee031389a6cfff
parent0057a7ee0d963eb9aee5cdfb9d6da5279bc8caf9
[gdb/testsuite] Fix FAILs due to PR gcc/101452

When running test-case gdb.base/ptype-offsets.exp with gcc-11 (with -gdwarf-5
default) or gcc-10 with target board unix/gdb:debug_flags=-gdwarf-5 we run
into this regression:
...
 (gdb) ptype/o static_member^M
 /* offset      |    size */  type = struct static_member {^M
-                               static static_member Empty;^M
 /*      0      |       4 */    int abc;^M
 ^M
                                /* total size (bytes):    4 */^M
                              }^M
-(gdb) PASS: gdb.base/ptype-offsets.exp: ptype/o static_member
+(gdb) FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member
...

This is caused by missing debug info, which I filed as gcc PR101452 - "[debug,
dwarf-5] undefined static member removed by
-feliminate-unused-debug-symbols".

It's not clear yet whether this is a bug or a feature, but work around this in
the test-cases by:
- defining the static member
- adding additional_flags=-fno-eliminate-unused-debug-types.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-07-20  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gcc_major_version): New proc.
* gdb.base/ptype-offsets.cc: Define static member static_member::Empty.
* gdb.cp/templates.exp: Define static member using -DGCC_BUG.
* gdb.cp/m-static.exp: Add
additional_flags=-fno-eliminate-unused-debug-types.
* gdb.cp/pr-574.exp: Same.
* gdb.cp/pr9167.exp: Same.
gdb/testsuite/gdb.base/ptype-offsets.cc
gdb/testsuite/gdb.cp/m-static.exp
gdb/testsuite/gdb.cp/pr-574.exp
gdb/testsuite/gdb.cp/pr9167.exp
gdb/testsuite/gdb.cp/templates.exp
gdb/testsuite/lib/gdb.exp