]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/mb-templates.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
9b254dd1 1# Copyright 2007, 2008 Free Software Foundation, Inc.
ed0616c6
VP
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
19if $tracelevel then {
20 strace $tracelevel
21}
22
c3ea9a14
DE
23if { [skip_cplus_tests] } { continue }
24
ed0616c6
VP
25set prms_id 0
26set bug_id 0
27
28set testfile "mb-templates"
29set srcfile ${testfile}.cc
30set binfile ${objdir}/${subdir}/${testfile}
31
32if [get_compiler_info ${binfile} "c++"] {
33 return -1
34}
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37 untested mb-templates.exp
38 return -1
39}
40
41gdb_exit
42gdb_start
43gdb_reinitialize_dir $srcdir/$subdir
44gdb_load ${binfile}
45
46set bp_location [gdb_get_line_number "set breakpoint here"]
47
48# Set a breakpoint with multiple locations
49# and a condition.
50
51gdb_test "break $srcfile:$bp_location if i==1" \
52 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
53 "initial condition: set breakpoint"
54
55gdb_run_cmd
56gdb_expect {
57 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
58 pass "initial condition: run to breakpoint"
59 }
60 -re "$gdb_prompt $" {
61 fail "initial condition: run to breakpoint"
62 }
63 timeout {
64 fail "initial condition: run to breakpoint (timeout)"
65 }
66}
67
68gdb_test "continue" \
69 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
70 "initial condition: run to breakpoint 2"
71
72# Set breakpoint with multiple locations.
73# Separately set the condition.
74gdb_exit
75gdb_start
76gdb_reinitialize_dir $srcdir/$subdir
77gdb_load ${binfile}
78
79gdb_test "break $srcfile:$bp_location" \
80 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
81 "separate condition: set breakpoint"
82
83gdb_test "condition 1 i==1" "" \
84 "separate condition: set condition"
85
86gdb_run_cmd
87gdb_expect {
88 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
89 pass "separate condition: run to breakpoint"
90 }
91 -re "$gdb_prompt $" {
92 fail "separate condition: run to breakpoint"
93 }
94 timeout {
95 fail "separate condition: run to breakpoint (timeout)"
96 }
97}
98
99gdb_test "continue" \
100 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
101 "separate condition: run to breakpoint 2"
102
103# Try disabling a single location. We also test
104# that at least in simple cases, the enable/disable
105# state of locations surive "run".
106gdb_test "disable 1.1" "" "disabling location: disable"
107
108gdb_run_cmd
109gdb_expect {
110 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
111 pass "disabling location: run to breakpoint"
112 }
113 -re "$gdb_prompt $" {
114 fail "disabling location: run to breakpoint"
115 }
116 timeout {
117 fail "disabling location: run to breakpoint (timeout)"
118 }
119}
120
121# Try disabling entire breakpoint
122gdb_test "enable 1.1" "" "disabling location: enable"
123
124
125gdb_test "disable 1" "" "disable breakpoint: disable"
126
127gdb_run_cmd
128gdb_expect {
129 -re "Program exited normally.*$gdb_prompt $" {
130 pass "disable breakpoint: run to breakpoint"
131 }
132 -re "$gdb_prompt $" {
133 fail "disable breakpoint: run to breakpoint"
134 }
135 timeout {
136 fail "disable breakpoint: run to breakpoint (timeout)"
137 }
138}
139
140# Make sure breakpoint can be set on a specific instantion.
141delete_breakpoints
142gdb_test "break 'void foo<int>(int)'" ".*" \
143 "instantiation: set breakpoint"
144
145
146gdb_run_cmd
147gdb_expect {
148 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
149 pass "instantiation: run to breakpoint"
150 }
151 -re "$gdb_prompt $" {
152 fail "instantiation: run to breakpoint"
153 }
154 timeout {
155 fail "instantiation: run to breakpoint (timeout)"
156 }
157}
158
159gdb_test "continue" \
160 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
161 "instantiation: run to breakpoint 2"
162