[gdb/testsuite] Fix FAILs due to PR gcc/101452
authorTom de Vries <tdevries@suse.de>
Wed, 21 Jul 2021 12:22:16 +0000 (14:22 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 21 Jul 2021 12:22:16 +0000 (14:22 +0200)
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-21  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/ChangeLog
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

index 0454c0675c145f56112803dfe6e6d6795610d41f..c23d830ead7c8d5f9b80ede7a5631504cc553f86 100644 (file)
@@ -1,3 +1,13 @@
+2021-07-21  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.
+
 2021-07-21  Tom de Vries  <tdevries@suse.de>
 
        * gdb.ada/arrayptr.exp: Add KFAILs for PR20991 and PR28115.
index dc21e34752f43619323694c5cc0a3ed58657fcf6..7678fc6a6666b3beaeb012b1c971a29651f3a085 100644 (file)
@@ -185,6 +185,9 @@ struct static_member
   int abc;
 };
 
+/* Work around PR gcc/101452.  */
+static_member static_member::Empty;
+
 struct empty_member
 {
   struct { } empty;
index 8260ca377f58068e0d6d878c2ff73617da489b48..15932038487919deb2c74b914bdb26af81bea975 100644 (file)
@@ -31,8 +31,14 @@ if [get_compiler_info] {
     return -1
 }
 
+set flags [list debug c++]
+if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
+    # Work around PR gcc/101452.
+    lappend flags additional_flags=-fno-eliminate-unused-debug-types
+}
+
 if {[prepare_for_testing "failed to prepare" $testfile \
-        [list $srcfile $srcfile2] {debug c++}]} {
+        [list $srcfile $srcfile2] $flags]} {
     return -1
 }
 
index dab52fd428c4041c49bb6e5e5e18dbebb144d169..da596f120f621f6812f32981e4cdba9a70197f29 100644 (file)
@@ -32,7 +32,13 @@ if [get_compiler_info "c++"] {
     return -1
 }
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set flags [list debug c++]
+if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
+    # Work around PR gcc/101452.
+    lappend flags additional_flags=-fno-eliminate-unused-debug-types
+}
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
     return -1
 }
 
index 34508f70e6ce724a81cbd3291399b78b1e4418b2..d88c75d8a121fd11616283c0e2b5f89bbb4f9cf6 100644 (file)
 
 standard_testfile .cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set flags [list debug c++]
+if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
+    # Work around PR gcc/101452.
+    lappend flags additional_flags=-fno-eliminate-unused-debug-types
+}
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
     return -1
 }
 
index 4d589426c28306f3a61cddae7707875ffade8f8d..8b905e4254fb210e20978f501e007735c14454c3 100644 (file)
@@ -27,7 +27,13 @@ if [get_compiler_info "c++"] {
     return -1
 }
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set flags [list debug c++]
+if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
+    # Work around PR gcc/101452.
+    lappend flags additional_flags=-DGCC_BUG
+}
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
     return -1
 }
 
index 001d18851d929147dedc80609c479e8c2373ad4f..c8be0a373a1de383538980b2d6c4312e2a25a4b9 100644 (file)
@@ -3973,6 +3973,27 @@ proc test_compiler_info { {compiler ""} } {
     return [string match $compiler $compiler_info]
 }
 
+# Return the gcc major version, or -1.
+# For gcc 4.8.5, the major version is 4.8.
+# For gcc 7.5.0, the major version 7.
+
+proc gcc_major_version { } {
+    global compiler_info
+    global decimal
+    if { ![test_compiler_info "gcc-*"] } {
+       return -1
+    }
+    set res [regexp gcc-($decimal)-($decimal)- $compiler_info \
+                dummy_var major minor]
+    if { $res != 1 } {
+       return -1
+    }
+    if { $major >= 5} {
+       return $major
+    }
+    return $major.$minor
+}
+
 proc current_target_name { } {
     global target_info
     if [info exists target_info(target,name)] {
This page took 0.036981 seconds and 4 git commands to generate.