Blame SOURCES/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch

ed07ac
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
ed07ac
From: Kevin Buettner <kevinb@redhat.com>
ed07ac
Date: Mon, 11 Oct 2021 11:22:04 -0700
ed07ac
Subject: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
ed07ac
ed07ac
;; Backport gdb.fortran testsuite changes in order to avoid Fortran
ed07ac
;; lexical analyzer bug.
ed07ac
ed07ac
[gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp
ed07ac
ed07ac
When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed
ed07ac
(with glibc 2.34) I run into:
ed07ac
...
ed07ac
(gdb) ^M
ed07ac
PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array
ed07ac
Expecting: ^(-var-create array \* array[^M
ed07ac
]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M
ed07ac
]+[(]gdb[)] ^M
ed07ac
[ ]*)
ed07ac
-var-create array * array^M
ed07ac
&"Attempt to use a type name as an expression.\n"^M
ed07ac
^error,msg="-var-create: unable to create variable object"^M
ed07ac
(gdb) ^M
ed07ac
FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output)
ed07ac
...
ed07ac
ed07ac
The problem is that the name array is used both:
ed07ac
- as the name for a local variable
ed07ac
- as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included
ed07ac
  by nss/nss_files/files-hosts.c.
ed07ac
ed07ac
Fix this by ignoring the shared lib symbols.
ed07ac
ed07ac
Likewise in a couple of other fortran tests.
ed07ac
ed07ac
Tested on x86_64-linux.
ed07ac
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/allocated.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/allocated.exp
ed07ac
@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid shared lib symbols.
ed07ac
+gdb_test_no_output "set auto-solib-add off"
ed07ac
+
ed07ac
 if ![fortran_runto_main] {
ed07ac
     untested "could not run to main"
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
 # Set all the breakpoints.
ed07ac
 for { set i 1 } { $i < 6 } { incr i } {
ed07ac
     gdb_breakpoint [gdb_get_line_number "Breakpoint $i"]
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
ed07ac
@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid shared lib symbols.
ed07ac
+gdb_test_no_output "set auto-solib-add off"
ed07ac
+
ed07ac
 if ![fortran_runto_main] {
ed07ac
     untested "could not run to main"
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
 # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
ed07ac
 gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
ed07ac
 gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
ed07ac
@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid shared lib symbols.
ed07ac
+gdb_test_no_output "set auto-solib-add off"
ed07ac
+
ed07ac
 if ![fortran_runto_main] {
ed07ac
     untested "could not run to main"
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
 # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
ed07ac
 gdb_breakpoint [gdb_get_line_number "Stop Here"]
ed07ac
 gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
ed07ac
@@ -55,11 +55,17 @@ proc run_test { repack } {
ed07ac
 
ed07ac
     clean_restart ${binfile}
ed07ac
 
ed07ac
+    # Avoid shared lib symbols.
ed07ac
+    gdb_test_no_output "set auto-solib-add off"
ed07ac
+
ed07ac
     if ![fortran_runto_main] {
ed07ac
 	untested "could not run to main"
ed07ac
 	return -1
ed07ac
     }
ed07ac
 
ed07ac
+    # Avoid libc symbols, in particular the 'array' type.
ed07ac
+    gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
     gdb_test_no_output "set fortran repack-array-slices $repack"
ed07ac
 
ed07ac
     # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
ed07ac
@@ -25,12 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid shared lib symbols.
ed07ac
+gdb_test_no_output "set auto-solib-add off"
ed07ac
 
ed07ac
 if ![fortran_runto_main] {
ed07ac
     untested "could not run to main"
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
 gdb_breakpoint [gdb_get_line_number "Test Breakpoint"]
ed07ac
 gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
ed07ac
 
ed07ac
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
ed07ac
--- a/gdb/testsuite/gdb.fortran/subarray.exp
ed07ac
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
ed07ac
@@ -27,16 +27,17 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
ed07ac
     return -1
ed07ac
 }
ed07ac
 
ed07ac
-gdb_exit
ed07ac
-gdb_start
ed07ac
-gdb_reinitialize_dir $srcdir/$subdir
ed07ac
-gdb_load ${binfile}
ed07ac
+# Avoid shared lib symbols.
ed07ac
+gdb_test_no_output "set auto-solib-add off"
ed07ac
 
ed07ac
 if ![fortran_runto_main] then {
ed07ac
     perror "couldn't run to main"
ed07ac
     continue
ed07ac
 }
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+gdb_test_no_output "nosharedlibrary"
ed07ac
+
ed07ac
 # Try to set breakpoint at the last write statement.
ed07ac
 
ed07ac
 set bp_location [gdb_get_line_number "str(:)"]
ed07ac
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
ed07ac
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
ed07ac
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
ed07ac
@@ -36,8 +36,14 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
ed07ac
 mi_gdb_reinitialize_dir $srcdir/$subdir
ed07ac
 mi_gdb_load ${binfile}
ed07ac
 
ed07ac
+# Avoid shared lib symbols.
ed07ac
+mi_gdb_test "-gdb-set auto-solib-add off" "\\^done"
ed07ac
+
ed07ac
 mi_runto prog_array
ed07ac
 
ed07ac
+# Avoid libc symbols, in particular the 'array' type.
ed07ac
+mi_gdb_test "nosharedlibrary" ".*\\^done"
ed07ac
+
ed07ac
 mi_create_varobj "array" "array" "create local variable array"
ed07ac
 
ed07ac