1 # Copyright 2007-2012 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.
19 if { [skip_stl_tests] } { continue }
21 # On SPU this test fails because the executable exceeds local storage size.
22 if { [istarget "spu*-*-*"] } {
27 set testfile "mb-templates"
28 set srcfile ${testfile}.cc
29 set binfile ${objdir}/${subdir}/${testfile}
31 if [get_compiler_info ${binfile} "c++"] {
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
36 untested mb-templates.exp
42 gdb_reinitialize_dir $srcdir/$subdir
45 set bp_location [gdb_get_line_number "set breakpoint here"]
47 # Set a breakpoint with multiple locations
50 gdb_test "break $srcfile:$bp_location if i==1" \
51 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
52 "initial condition: set breakpoint"
56 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
57 pass "initial condition: run to breakpoint"
60 fail "initial condition: run to breakpoint"
63 fail "initial condition: run to breakpoint (timeout)"
68 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
69 "initial condition: run to breakpoint 2"
71 # Set breakpoint with multiple locations.
72 # Separately set the condition.
75 gdb_reinitialize_dir $srcdir/$subdir
78 gdb_test "break $srcfile:$bp_location" \
79 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
80 "separate condition: set breakpoint"
82 gdb_test_no_output "condition 1 i==1" \
83 "separate condition: set condition"
87 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
88 pass "separate condition: run to breakpoint"
91 fail "separate condition: run to breakpoint"
94 fail "separate condition: run to breakpoint (timeout)"
99 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
100 "separate condition: run to breakpoint 2"
102 # Try disabling a single location. We also test
103 # that at least in simple cases, the enable/disable
104 # state of locations surive "run".
105 gdb_test_no_output "disable 1.1" "disabling location: disable"
109 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
110 pass "disabling location: run to breakpoint"
112 -re "$gdb_prompt $" {
113 fail "disabling location: run to breakpoint"
116 fail "disabling location: run to breakpoint (timeout)"
120 # Try disabling entire breakpoint
121 gdb_test_no_output "enable 1.1" "disabling location: enable"
124 gdb_test_no_output "disable 1" "disable breakpoint: disable"
128 -re "$inferior_exited_re normally.*$gdb_prompt $" {
129 pass "disable breakpoint: run to breakpoint"
131 -re "$gdb_prompt $" {
132 fail "disable breakpoint: run to breakpoint"
135 fail "disable breakpoint: run to breakpoint (timeout)"
139 # Make sure breakpoint can be set on a specific instantion.
141 gdb_test "break 'void foo<int>(int)'" ".*" \
142 "instantiation: set breakpoint"
147 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
148 pass "instantiation: run to breakpoint"
150 -re "$gdb_prompt $" {
151 fail "instantiation: run to breakpoint"
154 fail "instantiation: run to breakpoint (timeout)"
158 gdb_test "continue" \
159 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
160 "instantiation: run to breakpoint 2"
163 # Make sure we can set a breakpoint on a source statement that spans
168 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
170 if { ![runto_main] } {
171 fail "Can't run to main for multi_line_foo tests."
175 gdb_test "break $srcfile:$bp_location" \
176 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
177 "set multi_line_foo breakpoint"
178 gdb_test "continue" \
179 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
180 "run to multi_line_foo breakpoint 2 <int>"
181 gdb_test "continue" \
182 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
183 "run to multi_line_foo breakpoint 2 <double>"