Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
1 # Copyright 2007, 2008, 2009, 2010 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 # This test verifies that setting breakpoint on line in template
17 # function will fire in all instantiations of that template.
18
19 if $tracelevel then {
20 strace $tracelevel
21 }
22
23 if { [skip_cplus_tests] } { continue }
24
25 # On SPU this test fails because the executable exceeds local storage size.
26 if { [istarget "spu*-*-*"] } {
27 return 0
28 }
29
30 set prms_id 0
31 set bug_id 0
32
33 set testfile "mb-templates"
34 set srcfile ${testfile}.cc
35 set binfile ${objdir}/${subdir}/${testfile}
36
37 if [get_compiler_info ${binfile} "c++"] {
38 return -1
39 }
40
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
42 untested mb-templates.exp
43 return -1
44 }
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load ${binfile}
50
51 set bp_location [gdb_get_line_number "set breakpoint here"]
52
53 # Set a breakpoint with multiple locations
54 # and a condition.
55
56 gdb_test "break $srcfile:$bp_location if i==1" \
57 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
58 "initial condition: set breakpoint"
59
60 gdb_run_cmd
61 gdb_expect {
62 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
63 pass "initial condition: run to breakpoint"
64 }
65 -re "$gdb_prompt $" {
66 fail "initial condition: run to breakpoint"
67 }
68 timeout {
69 fail "initial condition: run to breakpoint (timeout)"
70 }
71 }
72
73 gdb_test "continue" \
74 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
75 "initial condition: run to breakpoint 2"
76
77 # Set breakpoint with multiple locations.
78 # Separately set the condition.
79 gdb_exit
80 gdb_start
81 gdb_reinitialize_dir $srcdir/$subdir
82 gdb_load ${binfile}
83
84 gdb_test "break $srcfile:$bp_location" \
85 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
86 "separate condition: set breakpoint"
87
88 gdb_test "condition 1 i==1" "" \
89 "separate condition: set condition"
90
91 gdb_run_cmd
92 gdb_expect {
93 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
94 pass "separate condition: run to breakpoint"
95 }
96 -re "$gdb_prompt $" {
97 fail "separate condition: run to breakpoint"
98 }
99 timeout {
100 fail "separate condition: run to breakpoint (timeout)"
101 }
102 }
103
104 gdb_test "continue" \
105 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
106 "separate condition: run to breakpoint 2"
107
108 # Try disabling a single location. We also test
109 # that at least in simple cases, the enable/disable
110 # state of locations surive "run".
111 gdb_test "disable 1.1" "" "disabling location: disable"
112
113 gdb_run_cmd
114 gdb_expect {
115 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
116 pass "disabling location: run to breakpoint"
117 }
118 -re "$gdb_prompt $" {
119 fail "disabling location: run to breakpoint"
120 }
121 timeout {
122 fail "disabling location: run to breakpoint (timeout)"
123 }
124 }
125
126 # Try disabling entire breakpoint
127 gdb_test "enable 1.1" "" "disabling location: enable"
128
129
130 gdb_test "disable 1" "" "disable breakpoint: disable"
131
132 gdb_run_cmd
133 gdb_expect {
134 -re "Program exited normally.*$gdb_prompt $" {
135 pass "disable breakpoint: run to breakpoint"
136 }
137 -re "$gdb_prompt $" {
138 fail "disable breakpoint: run to breakpoint"
139 }
140 timeout {
141 fail "disable breakpoint: run to breakpoint (timeout)"
142 }
143 }
144
145 # Make sure breakpoint can be set on a specific instantion.
146 delete_breakpoints
147 gdb_test "break 'void foo<int>(int)'" ".*" \
148 "instantiation: set breakpoint"
149
150
151 gdb_run_cmd
152 gdb_expect {
153 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
154 pass "instantiation: run to breakpoint"
155 }
156 -re "$gdb_prompt $" {
157 fail "instantiation: run to breakpoint"
158 }
159 timeout {
160 fail "instantiation: run to breakpoint (timeout)"
161 }
162 }
163
164 gdb_test "continue" \
165 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
166 "instantiation: run to breakpoint 2"
167
168
169 # Make sure we can set a breakpoint on a source statement that spans
170 # multiple lines.
171
172 delete_breakpoints
173
174 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
175
176 if { ![runto_main] } {
177 fail "Can't run to main for multi_line_foo tests."
178 return 0
179 }
180
181 gdb_test "break $srcfile:$bp_location" \
182 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
183 "set multi_line_foo breakpoint"
184 gdb_test "continue" \
185 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
186 "run to multi_line_foo breakpoint 2 <int>"
187 gdb_test "continue" \
188 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
189 "run to multi_line_foo breakpoint 2 <double>"
This page took 0.034463 seconds and 4 git commands to generate.