Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / homonym.exp
1 # Copyright 2008-2022 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15
16 load_lib "ada.exp"
17
18 if { [skip_ada_tests] } { return -1 }
19
20 standard_ada_testfile homonym_main
21
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
23 return -1
24 }
25
26 clean_restart ${testfile}
27
28
29 # Do these tests before running, so we are operating in a known
30 # environment.
31
32 gdb_test "break Get_Value" \
33 "Breakpoint \[0-9\]+ at $hex: Get_Value. .2 locations." \
34 "set breakpoint at Get_Value"
35
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"
39
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>"
43
44 delete_breakpoints
45
46 set bp_location [gdb_get_line_number "BREAK_1" ${testdir}/homonym.adb]
47 runto "homonym.adb:$bp_location"
48
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.
52
53 gdb_test "ptype local_type" \
54 "type = range -100 \\.\\. 100" \
55 "ptype local_type at BREAK_1"
56
57 gdb_test "ptype local_type_subtype" \
58 "type = range -100 \\.\\. 100" \
59 "ptype local_type_subtype at BREAK_1"
60
61 gdb_test "ptype int_type" \
62 "type = range -100 \\.\\. 100" \
63 "ptype int_type at BREAK_1"
64
65 gdb_test "ptype lcl" \
66 "type = range -100 \\.\\. 100" \
67 "ptype lcl at BREAK_1"
68
69 gdb_test "print lcl" \
70 "= 29" \
71 "print lcl at BREAK_1"
72
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.
76
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\]+\." \
80 "break at BREAK_2"
81
82 gdb_test "continue" \
83 ".*Breakpoint \[0-9\]+, homonym\\.get_value \\(\\) at .*homonym\\.adb:.*" \
84 "continue until BREAK_2"
85
86 gdb_test "ptype local_type" \
87 "type = range 1 \\.\\. 19740804" \
88 "ptype local_type at BREAK_2"
89
90 gdb_test "ptype local_type_subtype" \
91 "type = range 1 \\.\\. 19740804" \
92 "ptype local_type_subtype at BREAK_2"
93
94 gdb_test "ptype lcl" \
95 "type = range 1 \\.\\. 19740804" \
96 "ptype lcl at BREAK_2"
97
98 gdb_test "print lcl" \
99 "= 17" \
100 "print lcl at BREAK_2"
This page took 0.043221 seconds and 4 git commands to generate.