[committed,gdb/testsuite] Fix FAILs due to PR gcc/101575

Message ID 20210722123738.GA23947@delia.home
State New
Headers show
Series
  • [committed,gdb/testsuite] Fix FAILs due to PR gcc/101575
Related show

Commit Message

Tom de Vries July 22, 2021, 12:37 p.m.
Hi,

When running test-case gdb.ada/formatted_ref.exp with gcc-11 and target board
unix/gdb:debug_flags=-gdwarf-4 we run into:
...
(gdb) print/x s^M
No definition of "s" in current context.^M
(gdb) FAIL: gdb.ada/formatted_ref.exp: print/x s
...
which is caused by "runto defs.adb:20" taking us to defs__struct1IP:
...
(gdb) break defs.adb:20^M
Breakpoint 1 at 0x402cfd: defs.adb:20. (2 locations)^M
(gdb) run ^M
Starting program: formatted_ref ^M
^M
Breakpoint 1, defs__struct1IP () at defs.adb:20^M
20            return s.x;                   -- Set breakpoint marker here.^M
(gdb) print s1'access^M
...
instead of the expected defs.f1:
...
(gdb) break defs.adb:20^M
Breakpoint 1 at 0x402d0e: file defs.adb, line 20.^M
(gdb) run ^M
Starting program: formatted_ref ^M
^M
Breakpoint 1, defs.f1 (s=...) at defs.adb:20^M
20            return s.x;                   -- Set breakpoint marker here.^M
...

This is caused by incorrect line info due to gcc PR 101575 - "[gcc-11,
-gdwarf-4] Missing .file <n> directive causes invalid line info".

Fix this by when landing in defs__struct1IP:
- xfailing the runto, and
- issuing a continue to land in defs.f1.

Likewise in a few other test-cases.

Tested on x86_64-linux, with:
- system gcc.
- gcc-11 and target boards unix/gdb:debug_flags=-gdwarf-4 and
  unix/gdb:debug_flags=-gdwarf-5.

Committed to trunk.

Thanks,
- Tom

[gdb/testsuite] Fix FAILs due to PR gcc/101575

gdb/testsuite/ChangeLog:

2021-07-22  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/formatted_ref.exp: Add xfail for PR gcc/101575.
	* gdb.ada/iwide.exp: Same.
	* gdb.ada/pkd_arr_elem.exp: Same.

---
 gdb/testsuite/gdb.ada/formatted_ref.exp | 25 ++++++++++++++++++++++++-
 gdb/testsuite/gdb.ada/iwide.exp         | 25 +++++++++++++++++++++++--
 gdb/testsuite/gdb.ada/pkd_arr_elem.exp  | 26 ++++++++++++++++++++++++--
 3 files changed, 71 insertions(+), 5 deletions(-)

Patch

diff --git a/gdb/testsuite/gdb.ada/formatted_ref.exp b/gdb/testsuite/gdb.ada/formatted_ref.exp
index bc4b36309bd..ea4a7803198 100644
--- a/gdb/testsuite/gdb.ada/formatted_ref.exp
+++ b/gdb/testsuite/gdb.ada/formatted_ref.exp
@@ -90,7 +90,30 @@  proc test_p_op1_equals_op2 {op1 op2} {
 
 clean_restart ${testfile}
 
-runto defs.adb:[gdb_get_line_number "marker here" ${testdir}/defs.adb ]
+set bp_location \
+    defs.adb:[gdb_get_line_number "marker here" ${testdir}/defs.adb]
+
+# Workaround gcc PR101575.
+#runto $bp_location
+gdb_breakpoint "$bp_location"
+gdb_run_cmd
+set re "Breakpoint $decimal, defs.f1 \\(.*\\) at .*:$decimal.*"
+set re_xfail "Breakpoint $decimal, defs__struct1IP \\(\\) at .*:$decimal.*"
+set ok 1
+gdb_test_multiple "" "Runto to $bp_location" {
+    -re -wrap $re {
+	if { $ok } {
+	    pass $gdb_test_name
+	} else {
+	    xfail $gdb_test_name
+	}
+    }
+    -re -wrap $re_xfail {
+	set ok 0
+	send_gdb "continue\n"
+	exp_continue
+    }
+}
 
 set s1_address  [get_address "s1"]
 
diff --git a/gdb/testsuite/gdb.ada/iwide.exp b/gdb/testsuite/gdb.ada/iwide.exp
index 3bb854aad72..0742c504cbf 100644
--- a/gdb/testsuite/gdb.ada/iwide.exp
+++ b/gdb/testsuite/gdb.ada/iwide.exp
@@ -25,8 +25,29 @@  if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
 
 clean_restart ${testfile}
 
-set bp_location [gdb_get_line_number "BREAK" ${testdir}/p.adb]
-runto "p.adb:$bp_location"
+set bp_location p.adb:[gdb_get_line_number "BREAK" ${testdir}/p.adb]
+
+# Workaround gcc PR101575.
+#runto "$bp_location"
+gdb_breakpoint "$bp_location"
+gdb_run_cmd
+set re "Breakpoint $decimal, p \\(\\) at .*:$decimal.*"
+set re_xfail "Breakpoint $decimal, p__P5b.0 \\(\\) at .*:$decimal.*"
+set ok 1
+gdb_test_multiple "" "Runto to $bp_location" {
+    -re -wrap $re {
+	if { $ok } {
+	    pass $gdb_test_name
+	} else {
+	    xfail $gdb_test_name
+	}
+    }
+    -re -wrap $re_xfail {
+	set ok 0
+	send_gdb "continue\n"
+	exp_continue
+    }
+}
 
 gdb_test "print My_Drawable" \
          "= \\(center => \\(x => 1, y => 2\\), radius => 3\\)"
diff --git a/gdb/testsuite/gdb.ada/pkd_arr_elem.exp b/gdb/testsuite/gdb.ada/pkd_arr_elem.exp
index 31f78bddc39..2d644c60793 100644
--- a/gdb/testsuite/gdb.ada/pkd_arr_elem.exp
+++ b/gdb/testsuite/gdb.ada/pkd_arr_elem.exp
@@ -25,8 +25,30 @@  if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
 
 clean_restart ${testfile}
 
-set bp_location [gdb_get_line_number "START" ${testdir}/failure.adb]
-runto "failure.adb:$bp_location"
+set bp_location \
+    failure.adb:[gdb_get_line_number "START" ${testdir}/failure.adb]
+
+# Workaround gcc PR101575.
+#runto "$bp_location"
+gdb_breakpoint "$bp_location"
+gdb_run_cmd
+set re "Breakpoint $decimal, failure \\(\\) at .*:$decimal.*"
+set re_xfail "Breakpoint $decimal, failure__bounded_funny_stringIP.0 \\(\\) at .*:$decimal.*"
+set ok 1
+gdb_test_multiple "" "Runto to $bp_location" {
+    -re -wrap $re {
+	if { $ok } {
+	    pass $gdb_test_name
+	} else {
+	    xfail $gdb_test_name
+	}
+    }
+    -re -wrap $re_xfail {
+	set ok 0
+	send_gdb "continue\n"
+	exp_continue
+    }
+}
 
 # Print Test.  The order of the components depends on which version of
 # the compiler being used, as newer version can re-order the order