Commit | Line | Data |
---|---|---|
28e7fd62 | 1 | # Copyright 1997-2013 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This test was written by Rich Title. |
17 | # Purpose is to test conditional breakpoints. | |
18 | # Modeled after "break.exp". | |
19 | ||
c906108c SS |
20 | # |
21 | # test running programs | |
22 | # | |
c906108c | 23 | |
c2c6d25f | 24 | set testfile "break" |
c906108c | 25 | set srcfile ${testfile}.c |
a1dea79a | 26 | set srcfile1 ${testfile}1.c |
c906108c SS |
27 | set binfile ${objdir}/${subdir}/${testfile} |
28 | ||
fc91c6c2 | 29 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { |
b60f0898 JB |
30 | untested condbreak.exp |
31 | return -1 | |
a1dea79a FF |
32 | } |
33 | ||
fc91c6c2 | 34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { |
b60f0898 JB |
35 | untested condbreak.exp |
36 | return -1 | |
a1dea79a FF |
37 | } |
38 | ||
fc91c6c2 | 39 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
40 | untested condbreak.exp |
41 | return -1 | |
c906108c SS |
42 | } |
43 | ||
4c93b1db | 44 | if [get_compiler_info] { |
ae59b1da | 45 | return -1 |
085dd6e6 JM |
46 | } |
47 | ||
c906108c SS |
48 | gdb_exit |
49 | gdb_start | |
50 | gdb_reinitialize_dir $srcdir/$subdir | |
51 | gdb_load ${binfile} | |
52 | ||
53 | ||
a1dea79a FF |
54 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] |
55 | set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] | |
56 | set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] | |
57 | set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] | |
429374b8 JK |
58 | set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] |
59 | set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] | |
a1dea79a FF |
60 | set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1] |
61 | set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1] | |
429374b8 JK |
62 | set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1] |
63 | set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1] | |
a1dea79a | 64 | |
c906108c SS |
65 | # |
66 | # test break at function | |
67 | # | |
68 | gdb_test "break main" \ | |
69 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
70 | "breakpoint function" | |
71 | ||
72 | # | |
73 | # test conditional break at function | |
74 | # | |
75 | gdb_test "break marker1 if 1==1" \ | |
a1dea79a | 76 | "Breakpoint.*at.* file .*$srcfile1, line.*" |
c906108c | 77 | |
27d3a1a2 | 78 | gdb_test_no_output "delete 2" |
c906108c SS |
79 | |
80 | # | |
81 | # test conditional break at line number | |
82 | # | |
a1dea79a FF |
83 | gdb_test "break $srcfile:$bp_location1 if 1==1" \ |
84 | "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." | |
c906108c | 85 | |
27d3a1a2 | 86 | gdb_test_no_output "delete 3" |
c906108c SS |
87 | |
88 | # | |
89 | # test conditional break at function | |
90 | # | |
91 | gdb_test "break marker1 if (1==1)" \ | |
a1dea79a | 92 | "Breakpoint.*at.* file .*$srcfile1, line.*" |
c906108c SS |
93 | |
94 | # | |
95 | # test conditional break at line number | |
96 | # | |
a1dea79a FF |
97 | gdb_test "break $srcfile:$bp_location1 if (1==1)" \ |
98 | "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." | |
c906108c SS |
99 | |
100 | gdb_test "break marker2 if (a==43)" \ | |
a1dea79a | 101 | "Breakpoint.*at.* file .*$srcfile1, line.*" |
c906108c | 102 | |
429374b8 JK |
103 | # |
104 | # Check break involving inferior function call. | |
105 | # Ensure there is at least one additional breakpoint with higher VMA. | |
106 | # | |
107 | gdb_test "break marker3 if (multi_line_if_conditional(1,1,1)==0)" \ | |
108 | "Breakpoint.*at.* file .*$srcfile1, line.*" | |
109 | gdb_test "break marker4" \ | |
110 | "Breakpoint.*at.* file .*$srcfile1, line.*" | |
111 | ||
c906108c SS |
112 | # |
113 | # check to see what breakpoints are set | |
114 | # | |
115 | ||
085dd6e6 JM |
116 | if {$hp_aCC_compiler} { |
117 | set marker1_proto "\\(void\\)" | |
118 | set marker2_proto "\\(int\\)" | |
429374b8 JK |
119 | # Not checked. |
120 | set marker3_proto "\\(char \\*, char \\*\\)" | |
121 | set marker4_proto "\\(long\\)" | |
085dd6e6 JM |
122 | } else { |
123 | set marker1_proto "" | |
124 | set marker2_proto "" | |
429374b8 JK |
125 | set marker3_proto "" |
126 | set marker4_proto "" | |
085dd6e6 JM |
127 | } |
128 | ||
c906108c | 129 | gdb_test "info break" \ |
54e52265 | 130 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* |
a1dea79a FF |
131 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location6.* |
132 | \[0-9\]+\[\t \]+breakpoint keep y.* in marker1$marker1_proto at .*$srcfile1:($bp_location15|$bp_location16).* | |
0d381245 | 133 | \[\t \]+stop only if \\(1==1\\).* |
a1dea79a | 134 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* |
0d381245 | 135 | \[\t \]+stop only if \\(1==1\\).* |
a1dea79a | 136 | \[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile1:($bp_location8|$bp_location9).* |
429374b8 JK |
137 | \[\t \]+stop only if \\(a==43\\).* |
138 | \[0-9\]+\[\t \]+breakpoint keep y.* in marker3$marker3_proto at .*$srcfile1:($bp_location17|$bp_location18).* | |
139 | \[\t \]+stop only if \\(multi_line_if_conditional\\(1,1,1\\)==0\\).* | |
140 | \[0-9\]+\[\t \]+breakpoint keep y.* in marker4$marker4_proto at .*$srcfile1:($bp_location13|$bp_location14).*" \ | |
c906108c SS |
141 | "breakpoint info" |
142 | ||
143 | ||
144 | # | |
7a292a7a | 145 | # run until the breakpoint at main is hit. |
c906108c | 146 | # |
7a292a7a SS |
147 | |
148 | ||
cce74817 | 149 | rerun_to_main |
c906108c SS |
150 | |
151 | # | |
152 | # run until the breakpoint at a line number | |
153 | # | |
a1dea79a | 154 | gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ |
c906108c SS |
155 | "run until breakpoint set at a line number" |
156 | ||
157 | # | |
158 | # run until the breakpoint at marker1 | |
159 | # | |
11cf8741 JM |
160 | # If the inferior stops at the first instruction of a source line, GDB |
161 | # won't print the actual PC value; the source line is enough to | |
162 | # exactly specify the PC. But if the inferior is instead stopped in | |
163 | # the midst of a source line, GDB will include the PC in the | |
164 | # breakpoint hit message. This way, GDB always provides the exact | |
165 | # stop location, but avoids clutter when possible. | |
166 | # | |
167 | # Suppose you have a function written completely on one source line, like: | |
2c415c0f | 168 | # int foo (int x) { return 0; } |
11cf8741 JM |
169 | # Setting a breakpoint at `foo' actually places the breakpoint after |
170 | # foo's prologue. | |
171 | # | |
172 | # GCC's STABS writer always emits a line entry attributing the | |
173 | # prologue instructions to the line containing the function's open | |
174 | # brace, even if the first user instruction is also on that line. | |
175 | # This means that, in the case of a one-line function, you will get | |
176 | # two line entries in the debug info for the same line: one at the | |
177 | # function's entry point, and another at the first user instruction. | |
178 | # GDB preserves these duplicated line entries, and prefers the later | |
179 | # one; thus, when the program stops after the prologue, at the first | |
180 | # user instruction, GDB's search finds the second line entry, decides | |
181 | # that the PC is indeed at the beginning of a source line, and doesn't | |
182 | # print an address in the breakpoint hit message. | |
183 | # | |
184 | # GCC's Dwarf2 writer, on the other hand, squeezes out duplicate line | |
185 | # entries, so GDB considers the source line to begin at the start of | |
186 | # the function's prologue. Thus, if the program stops at the | |
187 | # breakpoint, GDB will decide that the PC is not at the beginning of a | |
188 | # source line, and will print an address. | |
189 | # | |
190 | # I think the Dwarf2 writer's behavior is arguably correct, but not | |
191 | # helpful. If the user sets a breakpoint at that source line, they | |
192 | # want that breakpoint to fall after the prologue. Identifying the | |
193 | # prologue's code with the opening brace is nice, but it shouldn't | |
194 | # take precedence over real code. | |
195 | # | |
196 | # Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior. | |
ad3986f0 | 197 | gdb_test_multiple "continue" "run until breakpoint at marker1" { |
a1dea79a | 198 | -re "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" { |
11cf8741 JM |
199 | pass "run until breakpoint at marker1" |
200 | } | |
a1dea79a | 201 | -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" { |
11cf8741 JM |
202 | xfail "run until breakpoint at marker1" |
203 | } | |
11cf8741 | 204 | } |
c906108c | 205 | |
c906108c | 206 | # run until the breakpoint at marker2 |
dfcd3bfb | 207 | # Same issues here as above. |
a0b3c4fd | 208 | setup_xfail hppa2.0w-*-* 11512CLLbs |
ad3986f0 | 209 | gdb_test_multiple "continue" "run until breakpoint at marker2" { |
b6199126 | 210 | -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" { |
dfcd3bfb JM |
211 | pass "run until breakpoint at marker2" |
212 | } | |
b6199126 | 213 | -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" { |
dfcd3bfb JM |
214 | xfail "run until breakpoint at marker2" |
215 | } | |
dfcd3bfb | 216 | } |
b6199126 DJ |
217 | |
218 | # Test combinations of conditional and thread-specific breakpoints. | |
219 | gdb_test "break main if (1==1) thread 999" \ | |
220 | "Unknown thread 999\\." | |
221 | gdb_test "break main thread 999 if (1==1)" \ | |
222 | "Unknown thread 999\\." | |
223 | ||
224 | # Verify that both if and thread can be distinguished from a breakpoint | |
225 | # address expression. | |
226 | gdb_test "break *main if (1==1) thread 999" \ | |
227 | "Unknown thread 999\\." | |
228 | gdb_test "break *main thread 999 if (1==1)" \ | |
229 | "Unknown thread 999\\." | |
230 | ||
231 | # Similarly for task. | |
232 | gdb_test "break *main if (1==1) task 999" \ | |
233 | "Unknown task 999\\." | |
234 | gdb_test "break *main task 999 if (1==1)" \ | |
235 | "Unknown task 999\\." | |
236 | ||
237 | # GDB accepts abbreviations for "thread" and "task". | |
238 | gdb_test "break *main if (1==1) t 999" \ | |
239 | "Unknown thread 999\\." | |
240 | gdb_test "break *main if (1==1) th 999" \ | |
241 | "Unknown thread 999\\." | |
242 | gdb_test "break *main if (1==1) ta 999" \ | |
243 | "Unknown task 999\\." | |
429374b8 JK |
244 | |
245 | set test "run until breakpoint at marker3" | |
246 | gdb_test_multiple "continue" $test { | |
247 | -re "Continuing\\..*Breakpoint \[0-9\]+, marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile1:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" { | |
248 | pass $test | |
249 | } | |
250 | -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile1:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" { | |
251 | xfail $test | |
252 | } | |
253 | } | |
254 | ||
255 | set test "run until breakpoint at marker4" | |
256 | gdb_test_multiple "continue" $test { | |
257 | -re "Continuing\\..*Breakpoint \[0-9\]+, marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" { | |
258 | pass $test | |
259 | } | |
260 | -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" { | |
261 | xfail $test | |
262 | } | |
263 | } | |
d55637df TT |
264 | |
265 | gdb_test "complete cond 1" "cond 1" | |
266 | gdb_test "set variable \$var = 1" | |
267 | gdb_test "complete cond \$v" "cond \\\$var" | |
268 | gdb_test "complete cond 1 values\[0\].a" "cond 1 values.0..a_field" |