From: Tom de Vries Date: Mon, 4 May 2020 06:40:38 +0000 (+0200) Subject: [gdb/testsuite] Fix gdb.base/async.exp with gcc-8 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=6015a0674901be2c3fd24867e1a610d2abf8c1a0;p=deliverable%2Fbinutils-gdb.git [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 --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2984996641..409f44ca9d 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 bc46f4b512..bf124ca56a 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"]