[gdb/testsuite] Fix gdb.base/async.exp with gcc-8
authorTom de Vries <tdevries@suse.de>
Mon, 4 May 2020 06:40:38 +0000 (08:40 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 4 May 2020 06:40:38 +0000 (08:40 +0200)
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  <tdevries@suse.de>

* gdb.base/async.exp: Check whether instruction addresses are a
"recommended breakpoint location".

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/async.exp

index 2984996641f2fa84bb094e549f8e0a536ba8e08b..409f44ca9d0d527086de4bf886475a59c4d829e7 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-04  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.base/async.exp: Check whether instruction addresses are a
+       "recommended breakpoint location".
+
 2020-05-03  Tom Tromey  <tom@tromey.com>
 
        * gdb.base/sepdebug.exp: Remove "catch" test.
index bc46f4b51283ecaf987f6dc89ad199f4e2f11e73..bf124ca56a9980c265c5f4fee6778fdeb91c0864 100644 (file)
@@ -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"]
This page took 0.032552 seconds and 4 git commands to generate.