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

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