2007-10-15 Wu Zhou <woodzltc@cn.ibm.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
ed0616c6
VP
1# Copyright 2007
2# Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17# This test verifies that setting breakpoint on line in template
18# function will fire in all instantiations of that template.
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
24set prms_id 0
25set bug_id 0
26
27set testfile "mb-templates"
28set srcfile ${testfile}.cc
29set binfile ${objdir}/${subdir}/${testfile}
30
31if [get_compiler_info ${binfile} "c++"] {
32 return -1
33}
34
35if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
36 untested mb-templates.exp
37 return -1
38}
39
40gdb_exit
41gdb_start
42gdb_reinitialize_dir $srcdir/$subdir
43gdb_load ${binfile}
44
45set bp_location [gdb_get_line_number "set breakpoint here"]
46
47# Set a breakpoint with multiple locations
48# and a condition.
49
50gdb_test "break $srcfile:$bp_location if i==1" \
51 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
52 "initial condition: set breakpoint"
53
54gdb_run_cmd
55gdb_expect {
56 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
57 pass "initial condition: run to breakpoint"
58 }
59 -re "$gdb_prompt $" {
60 fail "initial condition: run to breakpoint"
61 }
62 timeout {
63 fail "initial condition: run to breakpoint (timeout)"
64 }
65}
66
67gdb_test "continue" \
68 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
69 "initial condition: run to breakpoint 2"
70
71# Set breakpoint with multiple locations.
72# Separately set the condition.
73gdb_exit
74gdb_start
75gdb_reinitialize_dir $srcdir/$subdir
76gdb_load ${binfile}
77
78gdb_test "break $srcfile:$bp_location" \
79 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
80 "separate condition: set breakpoint"
81
82gdb_test "condition 1 i==1" "" \
83 "separate condition: set condition"
84
85gdb_run_cmd
86gdb_expect {
87 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
88 pass "separate condition: run to breakpoint"
89 }
90 -re "$gdb_prompt $" {
91 fail "separate condition: run to breakpoint"
92 }
93 timeout {
94 fail "separate condition: run to breakpoint (timeout)"
95 }
96}
97
98gdb_test "continue" \
99 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
100 "separate condition: run to breakpoint 2"
101
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".
105gdb_test "disable 1.1" "" "disabling location: disable"
106
107gdb_run_cmd
108gdb_expect {
109 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
110 pass "disabling location: run to breakpoint"
111 }
112 -re "$gdb_prompt $" {
113 fail "disabling location: run to breakpoint"
114 }
115 timeout {
116 fail "disabling location: run to breakpoint (timeout)"
117 }
118}
119
120# Try disabling entire breakpoint
121gdb_test "enable 1.1" "" "disabling location: enable"
122
123
124gdb_test "disable 1" "" "disable breakpoint: disable"
125
126gdb_run_cmd
127gdb_expect {
128 -re "Program exited normally.*$gdb_prompt $" {
129 pass "disable breakpoint: run to breakpoint"
130 }
131 -re "$gdb_prompt $" {
132 fail "disable breakpoint: run to breakpoint"
133 }
134 timeout {
135 fail "disable breakpoint: run to breakpoint (timeout)"
136 }
137}
138
139# Make sure breakpoint can be set on a specific instantion.
140delete_breakpoints
141gdb_test "break 'void foo<int>(int)'" ".*" \
142 "instantiation: set breakpoint"
143
144
145gdb_run_cmd
146gdb_expect {
147 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
148 pass "instantiation: run to breakpoint"
149 }
150 -re "$gdb_prompt $" {
151 fail "instantiation: run to breakpoint"
152 }
153 timeout {
154 fail "instantiation: run to breakpoint (timeout)"
155 }
156}
157
158gdb_test "continue" \
159 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
160 "instantiation: run to breakpoint 2"
161
This page took 0.038933 seconds and 4 git commands to generate.