[gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported
authorTom de Vries <tdevries@suse.de>
Thu, 12 Sep 2019 20:36:37 +0000 (22:36 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 12 Sep 2019 20:36:37 +0000 (22:36 +0200)
The test-case gdb.base/store.exp fails with gcc 7.4.0:
...
nr of unexpected failures        27
...

The first FAIL:
...
110       l = add_float (l, r);
(gdb) PASS: gdb.base/store.exp: continue to wack_float
print l
$21 = <optimized out>
FAIL: gdb.base/store.exp: var float l; print old l, expecting -1
...
relates to this bit in the test-case (compiled at -O0):
...
   106  float
   107  wack_float (register float u, register float v)
   108  {
   109    register float l = u, r = v;
   110    l = add_float (l, r);
   111    return l + r;
   112  }
...
and it expects to be able to read and modify variable l before executing line
110, but it already fails to read the value, because l has no DW_AT_location
attribute in the debug info.

Variable l is declared with the register keyword, and GCC implements the
register keyword at -O0 like so:
...
the compiler allocates distinct stack memory for all variables that do not
have the register storage-class specifier; if register is specified, the
variable may have a shorter lifespan than the code would indicate and may
never be placed in memory.
...

The fact that l has no DW_AT_location attribute, matches with the documented
"variable may have a shorter lifespan that code would indicate", (though it
is the most extreme case of it) so the gcc behaviour is valid.  We can of
course improve gcc to generate better debuginfo (filed gcc PR91611), but
this not a wrong-debug problem.

[ The test-case passes with gcc 4.2.1, but for the failing test discussed
above, it passes simply because it doesn't store l in a register. ]

With the debug info missing for l, reading and setting l is unsupported, so
fix the FAIL by marking the test UNSUPPORTED instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-12  Tom de Vries  <tdevries@suse.de>

* gdb.base/store.exp: Allow register variables to be optimized out at
-O0.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/store.exp

index bf3fcc7d844bc34d4d403125f5926e665fb5fa89..7352e9f0342b95902490140d1c8c23dd94fccaed 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-12  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.base/store.exp: Allow register variables to be optimized out at
+       -O0.
+
 2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.ada/rdv_wait.exp: Update to new task names.
index c5a7584101a4cadc21f906b19fbb9d1e9cb69727..9c19ce15a7be460babfd5f146762c9cbe31f839c 100644 (file)
@@ -55,18 +55,29 @@ proc check_set { t l r new add } {
        }
     }
 
-    gdb_test "print l" " = ${l}" \
-       "${prefix}; print old l, expecting ${l}"
-    gdb_test "print r" " = ${r}" \
-       "${prefix}; print old r, expecting ${r}"
-    gdb_test_no_output "set variable l = 4" \
-       "${prefix}; setting l to 4"
-    gdb_test "print l" " = ${new}" \
-       "${prefix}; print new l, expecting ${new}"
-    gdb_test "next" "return l \\+ r;" \
-       "${prefix}; next over add call"
-    gdb_test "print l" " = ${add}" \
-       "${prefix}; print incremented l, expecting ${add}"
+    set supported 1
+    set test "${prefix}; print old l, expecting ${l}"
+    gdb_test_multiple "print l" "$test"  {
+       -re " = <optimized out>\r\n$gdb_prompt $" {
+           unsupported $test
+           set supported 0
+       }
+       -re " = ${l}\r\n$gdb_prompt $" {
+           pass $test
+       }
+    }
+    if { $supported } {
+       gdb_test "print r" " = ${r}" \
+           "${prefix}; print old r, expecting ${r}"
+       gdb_test_no_output "set variable l = 4" \
+           "${prefix}; setting l to 4"
+       gdb_test "print l" " = ${new}" \
+           "${prefix}; print new l, expecting ${new}"
+       gdb_test "next" "return l \\+ r;" \
+           "${prefix}; next over add call"
+       gdb_test "print l" " = ${add}" \
+           "${prefix}; print incremented l, expecting ${add}"
+    }
 }
 
 check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002."
@@ -81,20 +92,34 @@ check_set "doublest" "-1" "-2" "4" "2"
 #
 
 proc up_set { t l r new } {
+    global gdb_prompt
+
     set prefix "upvar ${t} l"
     gdb_test "tbreak add_${t}"
     gdb_test "continue" "return u . v;" \
        "continue to add_${t}"
     gdb_test "up" "l = add_${t} .l, r.;" \
        "${prefix}; up"
-    gdb_test "print l" " = ${l}" \
-       "${prefix}; print old l, expecting ${l}"
-    gdb_test "print r" " = ${r}" \
-       "${prefix}; print old r, expecting ${r}"
-    gdb_test_no_output "set variable l = 4" \
-       "${prefix}; set l to 4"
-    gdb_test "print l" " = ${new}" \
-       "${prefix}; print new l, expecting ${new}"
+
+    set supported 1
+    set test "${prefix}; print old l, expecting ${l}"
+    gdb_test_multiple "print l" "$test"  {
+       -re " = <optimized out>\r\n$gdb_prompt $" {
+           unsupported $test
+           set supported 0
+       }
+       -re " = ${l}\r\n$gdb_prompt $" {
+           pass $test
+       }
+    }
+    if { $supported } {
+       gdb_test "print r" " = ${r}" \
+           "${prefix}; print old r, expecting ${r}"
+       gdb_test_no_output "set variable l = 4" \
+           "${prefix}; set l to 4"
+       gdb_test "print l" " = ${new}" \
+           "${prefix}; print new l, expecting ${new}"
+    }
 }
 
 up_set "charest" "-1 .*" "-2 .*" "4 ..004."
This page took 0.046348 seconds and 4 git commands to generate.