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*-*-*"] } {
29 if [get_compiler_info "c++"] {
33 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
37 set bp_location [gdb_get_line_number "set breakpoint here"]
39 # Set a breakpoint with multiple locations
42 gdb_test "break $srcfile:$bp_location if i==1" \
43 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
44 "initial condition: set breakpoint"
48 set test "initial condition: run to breakpoint"
49 gdb_test_multiple "" $test {
50 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
57 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
58 "initial condition: run to breakpoint 2"
60 # Set breakpoint with multiple locations.
61 # Separately set the condition.
64 gdb_test "kill" "" "kill" \
65 {Kill the program being debugged\? \(y or n\) } "y"
67 gdb_test "break $srcfile:$bp_location" \
68 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
69 "separate condition: set breakpoint"
71 gdb_test_no_output {condition $bpnum i==1} \
72 "separate condition: set condition"
76 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
77 pass "separate condition: run to breakpoint"
80 fail "separate condition: run to breakpoint"
83 fail "separate condition: run to breakpoint (timeout)"
88 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
89 "separate condition: run to breakpoint 2"
91 # Try disabling a single location. We also test
92 # that at least in simple cases, the enable/disable
93 # state of locations surive "run".
94 gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
98 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
99 pass "disabling location: run to breakpoint"
101 -re "$gdb_prompt $" {
102 fail "disabling location: run to breakpoint"
105 fail "disabling location: run to breakpoint (timeout)"
109 # Try disabling entire breakpoint
110 gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
113 gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
117 -re "$inferior_exited_re normally.*$gdb_prompt $" {
118 pass "disable breakpoint: run to breakpoint"
120 -re "$gdb_prompt $" {
121 fail "disable breakpoint: run to breakpoint"
124 fail "disable breakpoint: run to breakpoint (timeout)"
128 # Make sure breakpoint can be set on a specific instantion.
130 gdb_test "break 'void foo<int>(int)'" ".*" \
131 "instantiation: set breakpoint"
136 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
137 pass "instantiation: run to breakpoint"
139 -re "$gdb_prompt $" {
140 fail "instantiation: run to breakpoint"
143 fail "instantiation: run to breakpoint (timeout)"
147 gdb_test "continue" \
148 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
149 "instantiation: run to breakpoint 2"
152 # Make sure we can set a breakpoint on a source statement that spans
157 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
159 if { ![runto_main] } {
160 fail "Can't run to main for multi_line_foo tests."
164 gdb_test "break $srcfile:$bp_location" \
165 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
166 "set multi_line_foo breakpoint"
167 gdb_test "continue" \
168 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
169 "run to multi_line_foo breakpoint 2 <int>"
170 gdb_test "continue" \
171 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
172 "run to multi_line_foo breakpoint 2 <double>"