From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127746 invoked by alias); 12 Sep 2019 20:36:45 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 127702 invoked by uid 9882); 12 Sep 2019 20:36:44 -0000 Date: Thu, 12 Sep 2019 20:36:00 -0000 Message-ID: <20190912203644.127700.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 4993045d18d69ecee41ca341cde6bbed220dc8a4 X-Git-Newrev: 25e5c20918a0ec69e37c1987db52062b0eab7194 X-SW-Source: 2019-09/txt/msg00035.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=25e5c20918a0ec69e37c1987db52062b0eab7194 commit 25e5c20918a0ec69e37c1987db52062b0eab7194 Author: Tom de Vries Date: Thu Sep 12 22:36:37 2019 +0200 [gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported 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 = 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 * gdb.base/store.exp: Allow register variables to be optimized out at -O0. Diff: --- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/store.exp | 65 +++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bf3fcc7..7352e9f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-12 Tom de Vries + + * gdb.base/store.exp: Allow register variables to be optimized out at + -O0. + 2019-09-12 Philippe Waroquiers * gdb.ada/rdv_wait.exp: Update to new task names. diff --git a/gdb/testsuite/gdb.base/store.exp b/gdb/testsuite/gdb.base/store.exp index c5a7584..9c19ce1 100644 --- a/gdb/testsuite/gdb.base/store.exp +++ b/gdb/testsuite/gdb.base/store.exp @@ -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 " = \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 " = \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."