[committed,gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp

Message ID 20211011150013.GA13792@delia.home
State New
Headers show
Series
  • [committed,gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp
Related show

Commit Message

Philippe Waroquiers via Gdb-patches Oct. 11, 2021, 3 p.m.
Hi,

When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed
(with glibc 2.34) I run into:
...
(gdb) ^M
PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array
Expecting: ^(-var-create array \* array[^M
]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M
]+[(]gdb[)] ^M
[ ]*)
-var-create array * array^M
&"Attempt to use a type name as an expression.\n"^M
^error,msg="-var-create: unable to create variable object"^M
(gdb) ^M
FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output)
...

The problem is that the name array is used both:
- as the name for a local variable
- as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included
  by nss/nss_files/files-hosts.c.

Fix this by ignoring the shared lib symbols.

Likewise in a couple of other fortran tests.

Tested on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp

---
 gdb/testsuite/gdb.fortran/allocated.exp               | 6 ++++++
 gdb/testsuite/gdb.fortran/array-slices-bad.exp        | 6 ++++++
 gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp | 6 ++++++
 gdb/testsuite/gdb.fortran/array-slices.exp            | 6 ++++++
 gdb/testsuite/gdb.fortran/lbound-ubound.exp           | 5 +++++
 gdb/testsuite/gdb.fortran/subarray.exp                | 6 ++++++
 gdb/testsuite/gdb.mi/mi-var-child-f.exp               | 6 ++++++
 7 files changed, 41 insertions(+)

Comments

Philippe Waroquiers via Gdb-patches Oct. 12, 2021, 12:28 p.m. | #1
On 10/11/21 5:00 PM, Tom de Vries via Gdb-patches wrote:
> Hi,

> 

> When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed

> (with glibc 2.34) I run into:

> ...

> (gdb) ^M

> PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array

> Expecting: ^(-var-create array \* array[^M

> ]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M

> ]+[(]gdb[)] ^M

> [ ]*)

> -var-create array * array^M

> &"Attempt to use a type name as an expression.\n"^M

> ^error,msg="-var-create: unable to create variable object"^M

> (gdb) ^M

> FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output)

> ...

> 

> The problem is that the name array is used both:

> - as the name for a local variable

> - as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included

>   by nss/nss_files/files-hosts.c.

> 

> Fix this by ignoring the shared lib symbols.

> 

> Likewise in a couple of other fortran tests.

> 

> Tested on x86_64-linux.

> 

> Committed to trunk.


Hmm, I just found https://bugzilla.redhat.com/show_bug.cgi?id=2012976
PR2012976 - "GDB's Fortran lexical analyzer can mis-categorize symbol
tokens" which indicates that this is a symptom of an actual problem.

Anyway, I don't think it's useful to revert the committed patch since
there's no point in having this particular problem showing up in
hundreds of FAILs.

Thanks,
- Tom

Patch

diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp
index d9308af17b5..9f192d66e1b 100644
--- a/gdb/testsuite/gdb.fortran/allocated.exp
+++ b/gdb/testsuite/gdb.fortran/allocated.exp
@@ -25,10 +25,16 @@  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
+# Avoid shared lib symbols.
+gdb_test_no_output "set auto-solib-add off"
+
 if ![fortran_runto_main] {
     return -1
 }
 
+# Avoid libc symbols, in particular the 'array' type.
+gdb_test_no_output "nosharedlibrary"
+
 # Set all the breakpoints.
 for { set i 1 } { $i < 6 } { incr i } {
     gdb_breakpoint [gdb_get_line_number "Breakpoint $i"]
diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
index a68903498d6..c8bea995247 100644
--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
@@ -25,10 +25,16 @@  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
+# Avoid shared lib symbols.
+gdb_test_no_output "set auto-solib-add off"
+
 if ![fortran_runto_main] {
     return -1
 }
 
+# Avoid libc symbols, in particular the 'array' type.
+gdb_test_no_output "nosharedlibrary"
+
 # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
 gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
 gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
index 4264cec7a9d..c8e5232da4e 100644
--- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
@@ -25,10 +25,16 @@  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
+# Avoid shared lib symbols.
+gdb_test_no_output "set auto-solib-add off"
+
 if ![fortran_runto_main] {
     return -1
 }
 
+# Avoid libc symbols, in particular the 'array' type.
+gdb_test_no_output "nosharedlibrary"
+
 # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
 gdb_breakpoint [gdb_get_line_number "Stop Here"]
 gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 5b01e4f5e04..2c92d606e56 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -55,10 +55,16 @@  proc run_test { repack } {
 
     clean_restart ${binfile}
 
+    # Avoid shared lib symbols.
+    gdb_test_no_output "set auto-solib-add off"
+
     if ![fortran_runto_main] {
 	return -1
     }
 
+    # Avoid libc symbols, in particular the 'array' type.
+    gdb_test_no_output "nosharedlibrary"
+
     gdb_test_no_output "set fortran repack-array-slices $repack"
 
     # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
index 489c9ad24ce..3a65f7fa8ca 100644
--- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp
+++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
@@ -25,11 +25,16 @@  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
+# Avoid shared lib symbols.
+gdb_test_no_output "set auto-solib-add off"
 
 if ![fortran_runto_main] {
     return -1
 }
 
+# Avoid libc symbols, in particular the 'array' type.
+gdb_test_no_output "nosharedlibrary"
+
 gdb_breakpoint [gdb_get_line_number "Test Breakpoint"]
 gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index d41443a88b0..722ac52bdf3 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -27,11 +27,17 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
+# Avoid shared lib symbols.
+gdb_test_no_output "set auto-solib-add off"
+
 if ![fortran_runto_main] then {
     perror "couldn't run to main"
     continue
 }
 
+# Avoid libc symbols, in particular the 'array' type.
+gdb_test_no_output "nosharedlibrary"
+
 # Try to set breakpoint at the last write statement.
 
 set bp_location [gdb_get_line_number "str(:)"]
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index f35c0cdd6d3..a1aa1acb720 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,8 +36,14 @@  if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
+# Avoid shared lib symbols.
+mi_gdb_test "-gdb-set auto-solib-add off" "\\^done"
+
 mi_runto prog_array
 
+# Avoid libc symbols, in particular the 'array' type.
+mi_gdb_test "nosharedlibrary" ".*\\^done"
+
 mi_create_varobj "array" "array" "create local variable array"