Commit | Line | Data |
---|---|---|
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 | ||
20 | if $tracelevel then { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | set prms_id 0 | |
25 | set bug_id 0 | |
26 | ||
27 | set testfile "mb-templates" | |
28 | set srcfile ${testfile}.cc | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
30 | ||
31 | if [get_compiler_info ${binfile} "c++"] { | |
32 | return -1 | |
33 | } | |
34 | ||
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { | |
36 | untested mb-templates.exp | |
37 | return -1 | |
38 | } | |
39 | ||
40 | gdb_exit | |
41 | gdb_start | |
42 | gdb_reinitialize_dir $srcdir/$subdir | |
43 | gdb_load ${binfile} | |
44 | ||
45 | set bp_location [gdb_get_line_number "set breakpoint here"] | |
46 | ||
47 | # Set a breakpoint with multiple locations | |
48 | # and a condition. | |
49 | ||
50 | gdb_test "break $srcfile:$bp_location if i==1" \ | |
51 | "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ | |
52 | "initial condition: set breakpoint" | |
53 | ||
54 | gdb_run_cmd | |
55 | gdb_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 | ||
67 | gdb_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. | |
73 | gdb_exit | |
74 | gdb_start | |
75 | gdb_reinitialize_dir $srcdir/$subdir | |
76 | gdb_load ${binfile} | |
77 | ||
78 | gdb_test "break $srcfile:$bp_location" \ | |
79 | "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ | |
80 | "separate condition: set breakpoint" | |
81 | ||
82 | gdb_test "condition 1 i==1" "" \ | |
83 | "separate condition: set condition" | |
84 | ||
85 | gdb_run_cmd | |
86 | gdb_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 | ||
98 | gdb_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". | |
105 | gdb_test "disable 1.1" "" "disabling location: disable" | |
106 | ||
107 | gdb_run_cmd | |
108 | gdb_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 | |
121 | gdb_test "enable 1.1" "" "disabling location: enable" | |
122 | ||
123 | ||
124 | gdb_test "disable 1" "" "disable breakpoint: disable" | |
125 | ||
126 | gdb_run_cmd | |
127 | gdb_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. | |
140 | delete_breakpoints | |
141 | gdb_test "break 'void foo<int>(int)'" ".*" \ | |
142 | "instantiation: set breakpoint" | |
143 | ||
144 | ||
145 | gdb_run_cmd | |
146 | gdb_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 | ||
158 | gdb_test "continue" \ | |
159 | ".*Breakpoint.*foo<int> \\(i=1\\).*" \ | |
160 | "instantiation: run to breakpoint 2" | |
161 |