From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 4FC173858D35; Mon, 4 May 2020 06:40:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FC173858D35 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] Fix gdb.base/async.exp with gcc-8 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 9c7b8e9b92696f38ff29efeeb12eb166994c0a23 X-Git-Newrev: 6015a0674901be2c3fd24867e1a610d2abf8c1a0 Message-Id: <20200504064041.4FC173858D35@sourceware.org> Date: Mon, 4 May 2020 06:40:41 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2020 06:40:41 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6015a0674901be2c3fd24867e1a610d2abf8c1a0 commit 6015a0674901be2c3fd24867e1a610d2abf8c1a0 Author: Tom de Vries Date: Mon May 4 08:40:38 2020 +0200 [gdb/testsuite] Fix gdb.base/async.exp with gcc-8 When running test-case gdb.base/async.exp with gcc-8, we run into: ... FAIL: gdb.base/async.exp: stepi& ... The problem is that with gcc-8, the instruction address is no longer printed: ... stepi& -(gdb) 0x00000000004004b2 9 x = 5; x = 5; x = 5; +(gdb) 9 x = 5; x = 5; x = 5; completed. -PASS: gdb.base/async.exp: stepi& +FAIL: gdb.base/async.exp: stepi& ... This is due to the fact that gcc-8 contains more precise line info, making the address being stepped to a "recommended breakpoint location", and consequently gdb doesn't print the address prefix anymore. Given that: - we step through statements on the same line, and - there's no addres prefix anymore, this gives the impression of lack of progress, which could be improved upon, filed as enhancement PR25911 - "Show column when stepping through line". Fix the FAIL by checking in the test-case whether addresses are at "recommended breakpoint location" or not. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-04 Tom de Vries * gdb.base/async.exp: Check whether instruction addresses are a "recommended breakpoint location". Diff: --- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/async.exp | 54 +++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2984996641f..409f44ca9d0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-04 Tom de Vries + + * gdb.base/async.exp: Check whether instruction addresses are a + "recommended breakpoint location". + 2020-05-03 Tom Tromey * gdb.base/sepdebug.exp: Remove "catch" test. diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index bc46f4b5128..bf124ca56a9 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -79,7 +79,16 @@ test_background "step&" "" ".*y = foo \\(\\).*" "step& #1" test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2" -test_background "stepi&" "" ".*$hex.*x = 5.*" +set is_stmt [list] +gdb_test_multiple "maint info line-table async.c" "" { + -re "\r\n$decimal\[ \t\]+$decimal\[ \t\]+($hex)\[ \t\]+Y\[^\r\n\]*" { + lappend is_stmt $expect_out(1,string) + exp_continue + } + -re -wrap "" { + pass $gdb_test_name + } +} # Get the next instruction address. set next_insn_addr "" @@ -90,13 +99,46 @@ gdb_test_multiple {x/2i $pc} "$test" { pass "$test" } } +set next_insn_is_stmt \ + [expr [lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1] + +if { $next_insn_is_stmt } { + set prefix "" +} else { + # The current PC is printed out. + set prefix "0x0*$next_insn_addr.*" +} +test_background "stepi&" "" ".*$prefix x = 5; .*" -# We nexti into the same source line. The current PC is printed out. -test_background "nexti&" "" ".* 0x0*$next_insn_addr.* x = 5; .*" - -# PC is in the middle of a source line, so the PC address is displayed. +# Get the next instruction address. +set next_insn_addr "" +set test "get next insn" +gdb_test_multiple {x/2i $pc} "$test" { + -re "=> $hex .* 0x(\[0-9a-f\]*) .*$gdb_prompt $" { + set next_insn_addr $expect_out(1,string) + pass "$test" + } +} +set next_insn_is_stmt \ + [expr [lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1] + +if { $next_insn_is_stmt } { + set prefix "" +} else { + # The current PC is printed out. + set prefix "0x0*$next_insn_addr.*" +} +# We nexti into the same source line. +test_background "nexti&" "" ".*$prefix x = 5; .*" + +if { $next_insn_is_stmt } { + set prefix "" +} else { + # PC is in the middle of a source line, so the PC address is displayed. + set prefix "0x0*$next_insn_addr in " +} test_background "finish&" \ - "Run till exit from #0 $hex in foo \\(\\) at.*async.c.*\r\n" \ + "Run till exit from #0 ${prefix}foo \\(\\) at.*async.c.*\r\n" \ ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*" set jump_here [gdb_get_line_number "jump here"]