Files
binutils-gdb/gdb/testsuite/gdb.ada/local-enum.exp
Tom Tromey cabd5456c7 Allow unqualified names in Ada tests
Currently, when a type is declared in a subprogram that isn't part of
a package, gdb will give this type a qualified name.  E.g., in the
program for gdb.ada/arr_arr.exp:

    procedure Foo is
       type Array2_First is array (24 .. 26) of Integer;

gdb will name this type 'foo.array2_first'.

However, with some coming changes to GNAT (and with the remainder of
this series applied as well), this will no longer happen.  Instead,
such types will be given their local name.  IMO this makes more sense
anyway.

This patch updates most of the Ada tests to allow either form in the
spots where it matters.  Both are accepted so that the tests continue
to work with older versions of GNAT.  (A few tests are handled in
separate patches; this patch only contains the straightforward
changes.)
2025-03-06 14:17:17 -07:00

89 lines
2.5 KiB
Plaintext

# Copyright 2021-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/>.
load_lib "ada.exp"
require allow_ada_tests
standard_ada_testfile local
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
return -1
}
clean_restart ${testfile}
set bp_location [gdb_get_line_number "STOP" ${testdir}/local.adb]
if {![runto "local.adb:$bp_location"]} {
return
}
# The test has two constants named 'three', with different values.
# This prints one of them and checks the value. WHICH_ENUM is the
# name of the enum, either "e1" or "e2".
proc print_three {which_enum value} {
# We don't know which in order gdb will print the constants, so
# adapt to either. Accept "local." prefix for older versions of
# GNAT.
set menu1 [multi_line \
"Multiple matches for three" \
"\\\[0\\\] cancel" \
"\\\[1\\\] (local\\.)?e2'\\(three\\) \\(enumeral\\)" \
"\\\[2\\\] (local\\.)?e1'\\(three\\) \\(enumeral\\)" \
"> $"]
set menu2 [multi_line \
"Multiple matches for three" \
"\\\[0\\\] cancel" \
"\\\[1\\\] (local\\.)?e1'\\(three\\) \\(enumeral\\)" \
"\\\[2\\\] (local\\.)?e2'\\(three\\) \\(enumeral\\)" \
"> $"]
set index -1
set test_name "menu for test index $which_enum"
gdb_test_multiple "print/d three" $test_name {
-re $menu1 {
pass $test_name
if {$which_enum == "e1"} {
set index 2
} else {
set index 1
}
}
-re $menu2 {
pass $test_name
if {$which_enum == "e1"} {
set index 1
} else {
set index 2
}
}
default {
fail $test_name
}
}
if {$index != -1} {
gdb_test $index " = $value"
}
}
print_three e2 0
print_three e1 2
# These will not result in a menu, as expression resolution should
# disambiguate the meaning of 'three'.
gdb_test "print v1(three)" " = 2" "print v1 element"
gdb_test "print v2(three)" " = 3" "print v2 element"