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