1 # Copyright 2007, 2008, 2009 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_cplus_tests] } { continue }
25 # On SPU this test fails because the executable exceeds local storage size.
26 if { [istarget "spu*-*-*"] } {
33 set testfile "mb-templates"
34 set srcfile ${testfile}.cc
35 set binfile ${objdir}/${subdir}/${testfile}
37 if [get_compiler_info ${binfile} "c++"] {
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
42 untested mb-templates.exp
48 gdb_reinitialize_dir $srcdir/$subdir
51 set bp_location [gdb_get_line_number "set breakpoint here"]
53 # Set a breakpoint with multiple locations
56 gdb_test "break $srcfile:$bp_location if i==1" \
57 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
58 "initial condition: set breakpoint"
62 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
63 pass "initial condition: run to breakpoint"
66 fail "initial condition: run to breakpoint"
69 fail "initial condition: run to breakpoint (timeout)"
74 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
75 "initial condition: run to breakpoint 2"
77 # Set breakpoint with multiple locations.
78 # Separately set the condition.
81 gdb_reinitialize_dir $srcdir/$subdir
84 gdb_test "break $srcfile:$bp_location" \
85 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
86 "separate condition: set breakpoint"
88 gdb_test "condition 1 i==1" "" \
89 "separate condition: set condition"
93 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
94 pass "separate condition: run to breakpoint"
97 fail "separate condition: run to breakpoint"
100 fail "separate condition: run to breakpoint (timeout)"
104 gdb_test "continue" \
105 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
106 "separate condition: run to breakpoint 2"
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"
115 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
116 pass "disabling location: run to breakpoint"
118 -re "$gdb_prompt $" {
119 fail "disabling location: run to breakpoint"
122 fail "disabling location: run to breakpoint (timeout)"
126 # Try disabling entire breakpoint
127 gdb_test "enable 1.1" "" "disabling location: enable"
130 gdb_test "disable 1" "" "disable breakpoint: disable"
134 -re "Program exited normally.*$gdb_prompt $" {
135 pass "disable breakpoint: run to breakpoint"
137 -re "$gdb_prompt $" {
138 fail "disable breakpoint: run to breakpoint"
141 fail "disable breakpoint: run to breakpoint (timeout)"
145 # Make sure breakpoint can be set on a specific instantion.
147 gdb_test "break 'void foo<int>(int)'" ".*" \
148 "instantiation: set breakpoint"
153 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
154 pass "instantiation: run to breakpoint"
156 -re "$gdb_prompt $" {
157 fail "instantiation: run to breakpoint"
160 fail "instantiation: run to breakpoint (timeout)"
164 gdb_test "continue" \
165 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
166 "instantiation: run to breakpoint 2"