the "ambiguous linespec" series
[binutils-gdb.git] / gdb / testsuite / gdb.ada / homonym.exp
1 # Copyright 2008, 2009, 2010, 2011 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 if $tracelevel then {
17 strace $tracelevel
18 }
19
20 load_lib "ada.exp"
21
22 set testdir "homonym"
23 set testfile "${testdir}/homonym_main"
24 set srcfile ${srcdir}/${subdir}/${testfile}.adb
25 set binfile ${objdir}/${subdir}/${testfile}
26
27 file mkdir ${objdir}/${subdir}/${testdir}
28 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
29 return -1
30 }
31
32 clean_restart ${testfile}
33
34
35 # Do these tests before running, so we are operating in a known
36 # environment.
37
38 gdb_test "break Get_Value" \
39 "Breakpoint \[0-9\]+ at $hex: Get_Value. .2 locations." \
40 "set breakpoint at Get_Value"
41
42 gdb_test "break homonym.adb:Get_Value" \
43 "Breakpoint \[0-9\]+ at $hex: homonym.adb:Get_Value. .2 locations." \
44 "set breakpoint at homonym.adb:Get_Value"
45
46 gdb_test "break <homonym__get_value>" \
47 "Breakpoint \[0-9\]+ at $hex: <homonym__get_value>. .2 locations." \
48 "set breakpoint at <homonym__get_value>"
49
50 delete_breakpoints
51
52 set bp_location [gdb_get_line_number "BREAK_1" ${testdir}/homonym.adb]
53 runto "homonym.adb:$bp_location"
54
55 # Check the variables and types defined inside the current scope.
56 # There are some homonyms in a different scope, so we want to make
57 # sure that the debugger doesn't get mixed up.
58
59 gdb_test "ptype local_type" \
60 "type = range -100 \\.\\. 100" \
61 "ptype local_type at BREAK_1"
62
63 gdb_test "ptype local_type_subtype" \
64 "type = range -100 \\.\\. 100" \
65 "ptype local_type_subtype at BREAK_1"
66
67 gdb_test "ptype int_type" \
68 "type = range -100 \\.\\. 100" \
69 "ptype int_type at BREAK_1"
70
71 gdb_test "ptype lcl" \
72 "type = range -100 \\.\\. 100" \
73 "ptype lcl at BREAK_1"
74
75 gdb_test "print lcl" \
76 "= 29" \
77 "print lcl at BREAK_1"
78
79 # Now, continue until reaching BREAK_2, and do the same commands
80 # as above. The result should be different since the definitions
81 # in the new scope are different.
82
83 set bp_location [gdb_get_line_number "BREAK_2" ${testdir}/homonym.adb]
84 gdb_test "break homonym.adb:$bp_location" \
85 "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: file .*homonym\.adb, line \[0-9\]+\." \
86 "break at BREAK_2"
87
88 gdb_test "continue" \
89 ".*Breakpoint \[0-9\]+, homonym\\.get_value \\(\\) at .*homonym\\.adb:.*" \
90 "continue until BREAK_2"
91
92 gdb_test "ptype local_type" \
93 "type = range 1 \\.\\. 19740804" \
94 "ptype local_type at BREAK_2"
95
96 gdb_test "ptype local_type_subtype" \
97 "type = range 1 \\.\\. 19740804" \
98 "ptype local_type_subtype at BREAK_2"
99
100 gdb_test "ptype lcl" \
101 "type = range 1 \\.\\. 19740804" \
102 "ptype lcl at BREAK_2"
103
104 gdb_test "print lcl" \
105 "= 17" \
106 "print lcl at BREAK_2"