Files
binutils-gdb/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
Tom de Vries 3ee50921cb [gdb/testsuite] Don't use set auto-solib-add off
In test-case gdb.mi/mi-var-child-f.exp, we have:
...
mi_gdb_test "-gdb-set auto-solib-add off" "\\^done"
mi_runto prog_array
mi_gdb_test "nosharedlibrary" ".*\\^done"
...

This was added to avoid a name clash between the array variable as defined in
gdb.mi/array.f90 and debug info in shared libraries, and used in other places
in the testsuite.

The same workaround is also used to ignore symbols from shared libraries when
excercising for instance a command that prints all symbols.

However, this approach can cause problems for targets like arm that require
symbol info for some libraries like ld.so and libc to fully function.

While absense of debug info for shared libraries should be handled gracefully
(which does need fixing, see PR31817), failure to do so should not result
in failures in unrelated test-cases.

Fix this by removing "set auto-solib-add off".

This ensures that we don't run into PR31817, while the presence of
nosharedlibrary still ensures that in the rest of the test-case we're not
bothered by shared library symbols.

Likewise in other test-cases.

Approved-by: Kevin Buettner <kevinb@redhat.com>

Tested on arm-linux.
2024-06-10 10:43:10 +02:00

114 lines
3.9 KiB
Plaintext

# Copyright 2020-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/> .
# Create a slice of an array, then take a slice of that slice.
require allow_fortran_tests
standard_testfile ".f90"
load_lib fortran.exp
if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
{debug f90}]} {
return -1
}
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"]
# We're going to print some reasonably large arrays.
gdb_test_no_output "set print elements unlimited"
gdb_continue_to_breakpoint "Stop Here"
# Print a slice, capture the convenience variable name created.
set cmd "print array (1:10:2, 1:10:2)"
gdb_test_multiple $cmd $cmd {
-re "\r\n\\\$(\\d+) = .*\r\n$gdb_prompt $" {
set varname "\$$expect_out(1,string)"
}
}
# Now check that we can correctly extract all the elements from this
# slice.
for { set j 1 } { $j < 6 } { incr j } {
for { set i 1 } { $i < 6 } { incr i } {
set val [expr ((($i - 1) * 2) + (($j - 1) * 20)) + 1]
gdb_test "print ${varname} ($i,$j)" " = $val"
}
}
# Now take a slice of the slice.
gdb_test "print ${varname} (3:5, 3:5)" \
" = \\(\\(45, 47, 49\\) \\(65, 67, 69\\) \\(85, 87, 89\\)\\)"
# Now take a different slice of a slice.
set cmd "print ${varname} (1:5:2, 1:5:2)"
gdb_test_multiple $cmd $cmd {
-re "\r\n\\\$(\\d+) = \\(\\(1, 5, 9\\) \\(41, 45, 49\\) \\(81, 85, 89\\)\\)\r\n$gdb_prompt $" {
set varname "\$$expect_out(1,string)"
pass $gdb_test_name
}
}
# Now take a slice from the slice, of a slice!
set cmd "print ${varname} (1:3:2, 1:3:2)"
gdb_test_multiple $cmd $cmd {
-re "\r\n\\\$(\\d+) = \\(\\(1, 9\\) \\(81, 89\\)\\)\r\n$gdb_prompt $" {
set varname "\$$expect_out(1,string)"
pass $gdb_test_name
}
}
# And again!
set cmd "print ${varname} (1:2:2, 1:2:2)"
gdb_test_multiple $cmd $cmd {
-re "\r\n\\\$(\\d+) = \\(\\(1\\)\\)\r\n$gdb_prompt $" {
set varname "\$$expect_out(1,string)"
pass $gdb_test_name
}
}
# Test taking a slice with stride of a string. This isn't actually
# supported within gfortran (at least), but naturally drops out of how
# GDB models arrays and strings in a similar way, so we may as well
# test that this is still working.
gdb_test "print str (1:26:2)" " = 'acegikmoqsuwy'"
gdb_test "print str (26:1:-1)" " = 'zyxwvutsrqponmlkjihgfedcba'"
gdb_test "print str (26:1:-2)" " = 'zxvtrpnljhfdb'"
# Now test the memory requirements of taking a slice from an array.
# The idea is that we shouldn't require more memory to extract a slice
# than the size of the slice.
#
# This will only work if array repacking is turned on, otherwise GDB
# will create the slice by generating a new type that sits over the
# existing value in memory.
gdb_test_no_output "set fortran repack-array-slices on"
set element_size [get_integer_valueof "sizeof (array (1,1))" "unknown"]
set slice_size [expr $element_size * 4]
gdb_test_no_output "set max-value-size $slice_size"
gdb_test "print array (1:2, 1:2)" "= \\(\\(1, 2\\) \\(11, 12\\)\\)"
gdb_test "print array (2:3, 2:3)" "= \\(\\(12, 13\\) \\(22, 23\\)\\)"
gdb_test "print array (2:5:2, 2:5:2)" "= \\(\\(12, 14\\) \\(32, 34\\)\\)"