public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported Date: Thu, 12 Sep 2019 20:36:00 -0000 [thread overview] Message-ID: <20190912203644.127700.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=25e5c20918a0ec69e37c1987db52062b0eab7194 commit 25e5c20918a0ec69e37c1987db52062b0eab7194 Author: Tom de Vries <tdevries@suse.de> 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 = <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. 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 <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. 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 " = <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."
reply other threads:[~2019-09-12 20:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190912203644.127700.qmail@sourceware.org \ --to=vries@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).