1 # Copyright 2008-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 require allow_ada_tests
20 standard_ada_testfile homonym_main
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
26 clean_restart ${testfile}
29 # Do these tests before running, so we are operating in a known
32 gdb_test "break Get_Value" \
33 "Breakpoint \[0-9\]+ at $hex: Get_Value. .2 locations." \
34 "set breakpoint at Get_Value"
36 gdb_test "break homonym.adb:Get_Value" \
37 "Breakpoint \[0-9\]+ at $hex: homonym.adb:Get_Value. .2 locations." \
38 "set breakpoint at homonym.adb:Get_Value"
40 gdb_test "break <homonym__get_value>" \
41 "Breakpoint \[0-9\]+ at $hex: file .*homonym\\.adb, line $decimal\\." \
42 "set breakpoint at <homonym__get_value>"
46 set bp_location [gdb_get_line_number "BREAK_1" ${testdir}/homonym.adb]
47 runto "homonym.adb:$bp_location"
49 # Check the variables and types defined inside the current scope.
50 # There are some homonyms in a different scope, so we want to make
51 # sure that the debugger doesn't get mixed up.
53 gdb_test "ptype local_type" \
54 "type = range -100 \\.\\. 100" \
55 "ptype local_type at BREAK_1"
57 gdb_test "ptype local_type_subtype" \
58 "type = range -100 \\.\\. 100" \
59 "ptype local_type_subtype at BREAK_1"
61 gdb_test "ptype int_type" \
62 "type = range -100 \\.\\. 100" \
63 "ptype int_type at BREAK_1"
65 gdb_test "ptype lcl" \
66 "type = range -100 \\.\\. 100" \
67 "ptype lcl at BREAK_1"
69 gdb_test "print lcl" \
71 "print lcl at BREAK_1"
73 # Now, continue until reaching BREAK_2, and do the same commands
74 # as above. The result should be different since the definitions
75 # in the new scope are different.
77 set bp_location [gdb_get_line_number "BREAK_2" ${testdir}/homonym.adb]
78 gdb_test "break homonym.adb:$bp_location" \
79 "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: file .*homonym\\.adb, line \[0-9\]+\\." \
83 ".*Breakpoint \[0-9\]+, homonym\\.get_value \\(\\) at .*homonym\\.adb:.*" \
84 "continue until BREAK_2"
86 gdb_test "ptype local_type" \
87 "type = range 1 \\.\\. 19740804" \
88 "ptype local_type at BREAK_2"
90 gdb_test "ptype local_type_subtype" \
91 "type = range 1 \\.\\. 19740804" \
92 "ptype local_type_subtype at BREAK_2"
94 gdb_test "ptype lcl" \
95 "type = range 1 \\.\\. 19740804" \
96 "ptype lcl at BREAK_2"
98 gdb_test "print lcl" \
100 "print lcl at BREAK_2"