1 # Copyright 2007, 2008, 2009, 2010 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/>.
16 # This test verifies that setting breakpoint on line in template
17 # function will fire in all instantiations of that template.
23 if { [skip_stl_tests] } { continue }
25 # On SPU this test fails because the executable exceeds local storage size.
26 if { [istarget "spu*-*-*"] } {
31 set testfile "mb-templates"
32 set srcfile ${testfile}.cc
33 set binfile ${objdir}/${subdir}/${testfile}
35 if [get_compiler_info ${binfile} "c++"] {
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
40 untested mb-templates.exp
46 gdb_reinitialize_dir $srcdir/$subdir
49 set bp_location [gdb_get_line_number "set breakpoint here"]
51 # Set a breakpoint with multiple locations
54 gdb_test "break $srcfile:$bp_location if i==1" \
55 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
56 "initial condition: set breakpoint"
60 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
61 pass "initial condition: run to breakpoint"
64 fail "initial condition: run to breakpoint"
67 fail "initial condition: run to breakpoint (timeout)"
72 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
73 "initial condition: run to breakpoint 2"
75 # Set breakpoint with multiple locations.
76 # Separately set the condition.
79 gdb_reinitialize_dir $srcdir/$subdir
82 gdb_test "break $srcfile:$bp_location" \
83 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
84 "separate condition: set breakpoint"
86 gdb_test_no_output "condition 1 i==1" \
87 "separate condition: set condition"
91 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
92 pass "separate condition: run to breakpoint"
95 fail "separate condition: run to breakpoint"
98 fail "separate condition: run to breakpoint (timeout)"
102 gdb_test "continue" \
103 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
104 "separate condition: run to breakpoint 2"
106 # Try disabling a single location. We also test
107 # that at least in simple cases, the enable/disable
108 # state of locations surive "run".
109 gdb_test_no_output "disable 1.1" "disabling location: disable"
113 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
114 pass "disabling location: run to breakpoint"
116 -re "$gdb_prompt $" {
117 fail "disabling location: run to breakpoint"
120 fail "disabling location: run to breakpoint (timeout)"
124 # Try disabling entire breakpoint
125 gdb_test_no_output "enable 1.1" "disabling location: enable"
128 gdb_test_no_output "disable 1" "disable breakpoint: disable"
132 -re "Program exited normally.*$gdb_prompt $" {
133 pass "disable breakpoint: run to breakpoint"
135 -re "$gdb_prompt $" {
136 fail "disable breakpoint: run to breakpoint"
139 fail "disable breakpoint: run to breakpoint (timeout)"
143 # Make sure breakpoint can be set on a specific instantion.
145 gdb_test "break 'void foo<int>(int)'" ".*" \
146 "instantiation: set breakpoint"
151 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
152 pass "instantiation: run to breakpoint"
154 -re "$gdb_prompt $" {
155 fail "instantiation: run to breakpoint"
158 fail "instantiation: run to breakpoint (timeout)"
162 gdb_test "continue" \
163 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
164 "instantiation: run to breakpoint 2"
167 # Make sure we can set a breakpoint on a source statement that spans
172 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
174 if { ![runto_main] } {
175 fail "Can't run to main for multi_line_foo tests."
179 gdb_test "break $srcfile:$bp_location" \
180 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
181 "set multi_line_foo breakpoint"
182 gdb_test "continue" \
183 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
184 "run to multi_line_foo breakpoint 2 <int>"
185 gdb_test "continue" \
186 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
187 "run to multi_line_foo breakpoint 2 <double>"